Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DrFaust92 committed Sep 10, 2021
1 parent 4e13dc6 commit 17d3a10
Showing 1 changed file with 72 additions and 2 deletions.
74 changes: 72 additions & 2 deletions aws/resource_aws_sagemaker_endpoint_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func TestAccAWSSagemakerEndpointConfiguration_disappears(t *testing.T) {
})
}

func TestAccAWSSagemakerEndpointConfiguration_async_client(t *testing.T) {
func TestAccAWSSagemakerEndpointConfiguration_async(t *testing.T) {
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_sagemaker_endpoint_configuration.test"

Expand All @@ -283,7 +283,37 @@ func TestAccAWSSagemakerEndpointConfiguration_async_client(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckSagemakerEndpointConfigurationExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttr(resourceName, "async_inference_config.#", "0"),
resource.TestCheckResourceAttr(resourceName, "async_inference_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "async_inference_config.0.client_config.#", "0"),
resource.TestCheckResourceAttr(resourceName, "async_inference_config.0.output_config.#", "1"),
resource.TestCheckResourceAttrSet(resourceName, "async_inference_config.0.output_config.0.s3_output_path"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAWSSagemakerEndpointConfiguration_async_client(t *testing.T) {
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_sagemaker_endpoint_configuration.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ErrorCheck: testAccErrorCheck(t, sagemaker.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckSagemakerEndpointConfigurationDestroy,
Steps: []resource.TestStep{
{
Config: testAccSagemakerEndpointConfigurationConfigAsyncClientConfig(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckSagemakerEndpointConfigurationExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttr(resourceName, "async_inference_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "async_inference_config.0.client_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "async_inference_config.0.client_config.0.max_concurrent_invocations_per_instance", "1"),
resource.TestCheckResourceAttr(resourceName, "async_inference_config.0.output_config.#", "1"),
Expand Down Expand Up @@ -552,6 +582,45 @@ resource "aws_s3_bucket" "test" {
force_destroy = true
}
resource "aws_kms_key" "test" {
description = %[1]q
deletion_window_in_days = 7
}
resource "aws_sagemaker_endpoint_configuration" "test" {
name = %[1]q
production_variants {
variant_name = "variant-1"
model_name = aws_sagemaker_model.test.name
initial_instance_count = 2
instance_type = "ml.t2.medium"
initial_variant_weight = 1
}
async_inference_config {
output_config {
s3_output_path = "s3://${aws_s3_bucket.test.bucket}/"
kms_key_id = aws_kms_key.test.arn
}
}
}
`, rName)
}

func testAccSagemakerEndpointConfigurationConfigAsyncClientConfig(rName string) string {
return testAccSagemakerEndpointConfigurationConfig_Base(rName) + fmt.Sprintf(`
resource "aws_s3_bucket" "test" {
bucket = %[1]q
acl = "private"
force_destroy = true
}
resource "aws_kms_key" "test" {
description = %[1]q
deletion_window_in_days = 7
}
resource "aws_sagemaker_endpoint_configuration" "test" {
name = %[1]q
Expand All @@ -570,6 +639,7 @@ resource "aws_sagemaker_endpoint_configuration" "test" {
output_config {
s3_output_path = "s3://${aws_s3_bucket.test.bucket}/"
kms_key_id = aws_kms_key.test.arn
}
}
}
Expand Down

0 comments on commit 17d3a10

Please sign in to comment.