From 17d3a10a290b859e6af6b0791ee1443f89d33f45 Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Tue, 7 Sep 2021 00:06:40 +0300 Subject: [PATCH] tests --- ...s_sagemaker_endpoint_configuration_test.go | 74 ++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/aws/resource_aws_sagemaker_endpoint_configuration_test.go b/aws/resource_aws_sagemaker_endpoint_configuration_test.go index 3c0831d0e93..c538d88be08 100644 --- a/aws/resource_aws_sagemaker_endpoint_configuration_test.go +++ b/aws/resource_aws_sagemaker_endpoint_configuration_test.go @@ -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" @@ -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"), @@ -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 @@ -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 } } }