From 6d9dc00939b17098de552237ff805417be119cc4 Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Fri, 5 Apr 2024 14:50:05 -0400 Subject: [PATCH] internal/acctest: ignore missing endpoints in pre-check Adds the logic used in internal/sweep/awsv2 to the internal/acctest pre-check skipping function. Successfully tested with DevOpsGuru in GovCloud: ```console % make testacc PKG=devopsguru TESTS=TestAccDevOpsGuru_serial ==> Checking that code complies with gofmt requirements... TF_ACC=1 go1.21.8 test ./internal/service/devopsguru/... -v -count 1 -parallel 20 -run='TestAccDevOpsGuru_serial' -timeout 360m --- PASS: TestAccDevOpsGuru_serial (0.12s) --- PASS: TestAccDevOpsGuru_serial/ResourceCollection (0.11s) --- SKIP: TestAccDevOpsGuru_serial/ResourceCollection/basic (0.11s) --- SKIP: TestAccDevOpsGuru_serial/ResourceCollection/cloudformation (0.00s) --- SKIP: TestAccDevOpsGuru_serial/ResourceCollection/disappears (0.00s) --- SKIP: TestAccDevOpsGuru_serial/ResourceCollection/tags (0.00s) --- SKIP: TestAccDevOpsGuru_serial/ResourceCollection/tagsAllResources (0.00s) --- PASS: TestAccDevOpsGuru_serial/ResourceCollectionDataSource (0.00s) --- SKIP: TestAccDevOpsGuru_serial/ResourceCollectionDataSource/basic (0.00s) --- PASS: TestAccDevOpsGuru_serial/ServiceIntegration (0.00s) --- SKIP: TestAccDevOpsGuru_serial/ServiceIntegration/basic (0.00s) --- SKIP: TestAccDevOpsGuru_serial/ServiceIntegration/kms (0.00s) --- PASS: TestAccDevOpsGuru_serial/EventSourcesConfig (0.00s) --- SKIP: TestAccDevOpsGuru_serial/EventSourcesConfig/basic (0.00s) --- SKIP: TestAccDevOpsGuru_serial/EventSourcesConfig/disappears (0.00s) --- PASS: TestAccDevOpsGuru_serial/NotificationChannel (0.00s) --- SKIP: TestAccDevOpsGuru_serial/NotificationChannel/basic (0.00s) --- SKIP: TestAccDevOpsGuru_serial/NotificationChannel/disappears (0.00s) --- SKIP: TestAccDevOpsGuru_serial/NotificationChannel/filters (0.00s) --- PASS: TestAccDevOpsGuru_serial/NotificationChannelDataSource (0.00s) --- SKIP: TestAccDevOpsGuru_serial/NotificationChannelDataSource/basic (0.00s) PASS ok github.com/hashicorp/terraform-provider-aws/internal/service/devopsguru 5.604s ``` --- internal/acctest/acctest.go | 5 +++++ internal/service/devopsguru/devopsguru_test.go | 10 ---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/internal/acctest/acctest.go b/internal/acctest/acctest.go index 5400dc4ace0..241ec80a435 100644 --- a/internal/acctest/acctest.go +++ b/internal/acctest/acctest.go @@ -9,6 +9,7 @@ import ( "errors" "fmt" "log" + "net" "os" "reflect" "regexp" @@ -1733,6 +1734,10 @@ func PreCheckSkipError(err error) bool { if tfawserr.ErrCodeEquals(err, "ForbiddenException") { return true } + // Ignore missing API endpoints + if errs.IsA[*net.DNSError](err) { + return true + } return false } diff --git a/internal/service/devopsguru/devopsguru_test.go b/internal/service/devopsguru/devopsguru_test.go index 0caf6ab696d..f806a1297d9 100644 --- a/internal/service/devopsguru/devopsguru_test.go +++ b/internal/service/devopsguru/devopsguru_test.go @@ -5,9 +5,6 @@ package devopsguru_test import ( "context" - "errors" - "net" - "strings" "testing" "github.com/aws/aws-sdk-go-v2/service/devopsguru" @@ -60,13 +57,6 @@ func testAccPreCheck(ctx context.Context, t *testing.T) { if acctest.PreCheckSkipError(err) { t.Skipf("skipping acceptance testing: %s", err) } - // In GovCloud partitions, API calls trigger an operation error - var netOpErr *net.OpError - if errors.As(err, &netOpErr) { - if strings.Contains(netOpErr.Error(), "no such host") { - t.Skipf("skipping acceptance testing: %s", err) - } - } if err != nil { t.Fatalf("unexpected PreCheck error: %s", err) }