From 992e0f91c68fadd6b21394ab9eb3afb03775f028 Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Fri, 29 Nov 2024 12:37:09 -0800 Subject: [PATCH 1/5] Fixes "Process exited with code 1" error for non-service acceptance tests in "Set Up" stage --- .teamcity/scripts/provider_tests/acceptance_tests.sh | 2 +- internal/generate/teamcity/acceptance_tests.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.teamcity/scripts/provider_tests/acceptance_tests.sh b/.teamcity/scripts/provider_tests/acceptance_tests.sh index 86f8286a2d5..2329d81f456 100644 --- a/.teamcity/scripts/provider_tests/acceptance_tests.sh +++ b/.teamcity/scripts/provider_tests/acceptance_tests.sh @@ -61,4 +61,4 @@ TF_ACC=1 go test \ ./internal/types/... \ ./internal/vault/... \ ./internal/verify/... \ - -json -v -count=1 -parallel "%ACCTEST_PARALLELISM%" -timeout=0 -run=TestAcc + -json -count=1 -parallel "%ACCTEST_PARALLELISM%" -timeout=0 -run=TestAcc diff --git a/internal/generate/teamcity/acceptance_tests.tmpl b/internal/generate/teamcity/acceptance_tests.tmpl index f56c31641a5..d14b7912861 100644 --- a/internal/generate/teamcity/acceptance_tests.tmpl +++ b/internal/generate/teamcity/acceptance_tests.tmpl @@ -36,4 +36,4 @@ TF_ACC=1 go test \ {{- range . }} ./internal/{{ . }}/... \ {{- end }} - -json -v -count=1 -parallel "%ACCTEST_PARALLELISM%" -timeout=0 -run=TestAcc + -json -count=1 -parallel "%ACCTEST_PARALLELISM%" -timeout=0 -run=TestAcc From 6e3a7cc4c7a7b771eddeace9d4867700235f56f1 Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Fri, 29 Nov 2024 13:04:31 -0800 Subject: [PATCH 2/5] Removes `TestAccProvider_endpoints` since each service has endpoint tests --- internal/provider/provider_acc_test.go | 76 -------------------------- 1 file changed, 76 deletions(-) diff --git a/internal/provider/provider_acc_test.go b/internal/provider/provider_acc_test.go index fd0e8e9b169..1026d0a746c 100644 --- a/internal/provider/provider_acc_test.go +++ b/internal/provider/provider_acc_test.go @@ -8,7 +8,6 @@ import ( "errors" "fmt" "reflect" - "strings" "testing" "github.com/aws/aws-sdk-go-v2/aws" @@ -159,32 +158,6 @@ func TestAccProvider_DefaultAndIgnoreTags_emptyBlocks(t *testing.T) { }) } -func TestAccProvider_endpoints(t *testing.T) { - ctx := acctest.Context(t) - var provider *schema.Provider - var endpoints strings.Builder - - // Initialize each endpoint configuration with matching name and value - for _, serviceKey := range names.ProviderPackages() { - endpoints.WriteString(fmt.Sprintf("%s = \"http://%s\"\n", serviceKey, serviceKey)) - } - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t) }, - ErrorCheck: acctest.ErrorCheck(t), - ProtoV5ProviderFactories: testAccProtoV5ProviderFactoriesInternal(ctx, t, &provider), - CheckDestroy: nil, - Steps: []resource.TestStep{ - { - Config: testAccProviderConfig_endpoints(endpoints.String()), - Check: resource.ComposeTestCheckFunc( - testAccCheckEndpoints(ctx, &provider), - ), - }, - }, - }) -} - func TestAccProvider_customEndpoint(t *testing.T) { ctx := acctest.Context(t) rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -983,55 +956,6 @@ func testAccCheckProviderDefaultTags_Tags(ctx context.Context, t *testing.T, p * } } -func testAccCheckEndpoints(_ context.Context, p **schema.Provider) resource.TestCheckFunc { - return func(s *terraform.State) error { - if p == nil || *p == nil || (*p).Meta() == nil || (*p).Meta().(*conns.AWSClient) == nil { - return fmt.Errorf("provider not initialized") - } - - providerClient := (*p).Meta().(*conns.AWSClient) - - for _, serviceKey := range names.Aliases() { - methodName := serviceClient(serviceKey) - method := reflect.ValueOf(providerClient).MethodByName(methodName) - if !method.IsValid() { - continue - } - if method.Kind() != reflect.Func { - return fmt.Errorf("value %q is not a function", methodName) - } - if !funcHasConnFuncSignature(method) { - return fmt.Errorf("function %q does not match expected signature", methodName) - } - - result := method.Call([]reflect.Value{ - reflect.ValueOf(context.Background()), - }) - if l := len(result); l != 1 { - return fmt.Errorf("expected 1 result, got %d", l) - } - providerClientField := result[0] - - if !providerClientField.IsValid() { - return fmt.Errorf("unable to match conns.AWSClient struct field name for endpoint name: %s", serviceKey) - } - - if !reflect.Indirect(providerClientField).FieldByName("Config").IsValid() { - continue // currently unknown how to do this check for v2 clients - } - - actualEndpoint := reflect.Indirect(reflect.Indirect(providerClientField).FieldByName("Config").FieldByName("Endpoint")).String() - expectedEndpoint := fmt.Sprintf("http://%s", serviceKey) - - if actualEndpoint != expectedEndpoint { - return fmt.Errorf("expected endpoint (%s) value (%s), got: %s", serviceKey, expectedEndpoint, actualEndpoint) - } - } - - return nil - } -} - func testAccCheckUnusualEndpoints(_ context.Context, p **schema.Provider, unusual unusualEndpoint) resource.TestCheckFunc { return func(s *terraform.State) error { if p == nil || *p == nil || (*p).Meta() == nil || (*p).Meta().(*conns.AWSClient) == nil { From 903012dc5ea859ec666ab7bd8d6d3c5bea9a57cf Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Fri, 29 Nov 2024 13:20:29 -0800 Subject: [PATCH 3/5] Skips `TestAccProvider_Region_*` tests due to bug in `aws-sdk-go-base` --- internal/provider/provider_acc_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/internal/provider/provider_acc_test.go b/internal/provider/provider_acc_test.go index 1026d0a746c..0d808e029eb 100644 --- a/internal/provider/provider_acc_test.go +++ b/internal/provider/provider_acc_test.go @@ -481,6 +481,9 @@ func TestAccProvider_IgnoreTagsKeyPrefixes_envVarMerged(t *testing.T) { } func TestAccProvider_Region_c2s(t *testing.T) { + // When using `AWS_PROFILE` for authentication, `skip_credentials_validation` is ignored + // https://github.com/hashicorp/aws-sdk-go-base/issues/453 + t.Skip() ctx := acctest.Context(t) var provider *schema.Provider @@ -504,6 +507,9 @@ func TestAccProvider_Region_c2s(t *testing.T) { } func TestAccProvider_Region_china(t *testing.T) { + // When using `AWS_PROFILE` for authentication, `skip_credentials_validation` is ignored + // https://github.com/hashicorp/aws-sdk-go-base/issues/453 + t.Skip() ctx := acctest.Context(t) var provider *schema.Provider @@ -527,6 +533,9 @@ func TestAccProvider_Region_china(t *testing.T) { } func TestAccProvider_Region_commercial(t *testing.T) { + // When using `AWS_PROFILE` for authentication, `skip_credentials_validation` is ignored + // https://github.com/hashicorp/aws-sdk-go-base/issues/453 + t.Skip() ctx := acctest.Context(t) var provider *schema.Provider @@ -550,6 +559,9 @@ func TestAccProvider_Region_commercial(t *testing.T) { } func TestAccProvider_Region_govCloud(t *testing.T) { + // When using `AWS_PROFILE` for authentication, `skip_credentials_validation` is ignored + // https://github.com/hashicorp/aws-sdk-go-base/issues/453 + t.Skip() ctx := acctest.Context(t) var provider *schema.Provider @@ -573,6 +585,9 @@ func TestAccProvider_Region_govCloud(t *testing.T) { } func TestAccProvider_Region_sc2s(t *testing.T) { + // When using `AWS_PROFILE` for authentication, `skip_credentials_validation` is ignored + // https://github.com/hashicorp/aws-sdk-go-base/issues/453 + t.Skip() ctx := acctest.Context(t) var provider *schema.Provider @@ -596,6 +611,9 @@ func TestAccProvider_Region_sc2s(t *testing.T) { } func TestAccProvider_Region_stsRegion(t *testing.T) { + // When using `AWS_PROFILE` for authentication, `skip_credentials_validation` is ignored + // https://github.com/hashicorp/aws-sdk-go-base/issues/453 + t.Skip() ctx := acctest.Context(t) var provider *schema.Provider From 9ca46457b26258aa91def76762bb27b2101ff266 Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Fri, 29 Nov 2024 13:20:53 -0800 Subject: [PATCH 4/5] Adds `shellcheck` linter instruction --- .teamcity/scripts/service_tests/acceptance_tests.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.teamcity/scripts/service_tests/acceptance_tests.sh b/.teamcity/scripts/service_tests/acceptance_tests.sh index e8a14f220b1..07fabf7e88c 100644 --- a/.teamcity/scripts/service_tests/acceptance_tests.sh +++ b/.teamcity/scripts/service_tests/acceptance_tests.sh @@ -4,6 +4,7 @@ set -euo pipefail TEST_LIST=$(./test-binary -test.list="%TEST_PATTERN%" 2>/dev/null) +# shellcheck disable=2157 # This isn't a constant string, it's a TeamCity variable substitution if [[ -n "%TEST_EXCLUDE_PATTERN%" ]]; then TEST_LIST=$(echo "${TEST_LIST}" | grep -vE "%TEST_EXCLUDE_PATTERN%") fi From c6daa7c449b75d0b85ffb99a9ac68117ca6bcad6 Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Mon, 2 Dec 2024 10:41:14 -0800 Subject: [PATCH 5/5] Removes unused function --- internal/provider/provider_acc_test.go | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/internal/provider/provider_acc_test.go b/internal/provider/provider_acc_test.go index 0d808e029eb..31fbf4d51b7 100644 --- a/internal/provider/provider_acc_test.go +++ b/internal/provider/provider_acc_test.go @@ -1059,21 +1059,6 @@ data "aws_service" "provider_test" { } ` -func testAccProviderConfig_endpoints(endpoints string) string { - //lintignore:AT004 - return acctest.ConfigCompose(testAccProviderConfig_base, fmt.Sprintf(` -provider "aws" { - skip_credentials_validation = true - skip_metadata_api_check = true - skip_requesting_account_id = true - - endpoints { - %[1]s - } -} -`, endpoints)) -} - func testAccProviderConfig_customS3Endpoint(endpoint, rName string) string { //lintignore:AT004 return acctest.ConfigCompose(testAccProviderConfig_base, fmt.Sprintf(`