Skip to content

Commit

Permalink
internal/acctest: ignore missing endpoints in pre-check
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
jar-b committed Apr 5, 2024
1 parent d1ce462 commit 6d9dc00
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
5 changes: 5 additions & 0 deletions internal/acctest/acctest.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"errors"
"fmt"
"log"
"net"
"os"
"reflect"
"regexp"
Expand Down Expand Up @@ -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
}

Expand Down
10 changes: 0 additions & 10 deletions internal/service/devopsguru/devopsguru_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ package devopsguru_test

import (
"context"
"errors"
"net"
"strings"
"testing"

"github.com/aws/aws-sdk-go-v2/service/devopsguru"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 6d9dc00

Please sign in to comment.