Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider: Add -count 1 to testacc Makefile target to prevent issues with Go test caching #10245

Merged
merged 1 commit into from
Sep 25, 2019

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Sep 25, 2019

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Release note for CHANGELOG:

NONE

Go 1.10+ will automatically cache successful test results if it detects no local changes: https://golang.org/doc/go1.10#test

When running acceptance testing to attempt to find eventual consistency issues by repeatedly running the same tests, its possible this Go test caching will inadvertently make it hard to detect inconsistent remote results. The testing output does not make it obvious for individual tests (at least in Go 1.13.0) that the results are actually cached except for the final line which mentions (cached):

$ time TF_ACC=1 go test ./aws -v -timeout 120m -parallel 20 -run='TestAccAWSWafWebAcl_Rules'
=== RUN   TestAccAWSWafWebAcl_Rules
=== PAUSE TestAccAWSWafWebAcl_Rules
=== CONT  TestAccAWSWafWebAcl_Rules
--- PASS: TestAccAWSWafWebAcl_Rules (35.42s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws    (cached)
TF_ACC=1 go test ./aws -v     10.87s user 3.64s system 267% cpu 5.419 total

Output from acceptance testing:

$ make testacc TEST=./aws TESTARGS=-run='TestAccAWSProvider_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSProvider_ -timeout 120m
=== RUN   TestAccAWSProvider_Endpoints
=== PAUSE TestAccAWSProvider_Endpoints
=== RUN   TestAccAWSProvider_Endpoints_Deprecated
=== PAUSE TestAccAWSProvider_Endpoints_Deprecated
=== RUN   TestAccAWSProvider_Region_AwsChina
=== PAUSE TestAccAWSProvider_Region_AwsChina
=== RUN   TestAccAWSProvider_Region_AwsCommercial
=== PAUSE TestAccAWSProvider_Region_AwsCommercial
=== RUN   TestAccAWSProvider_Region_AwsGovCloudUs
=== PAUSE TestAccAWSProvider_Region_AwsGovCloudUs
=== CONT  TestAccAWSProvider_Endpoints
=== CONT  TestAccAWSProvider_Region_AwsChina
=== CONT  TestAccAWSProvider_Endpoints_Deprecated
=== CONT  TestAccAWSProvider_Region_AwsCommercial
=== CONT  TestAccAWSProvider_Region_AwsGovCloudUs
--- PASS: TestAccAWSProvider_Region_AwsCommercial (2.77s)
--- PASS: TestAccAWSProvider_Region_AwsChina (2.78s)
--- PASS: TestAccAWSProvider_Region_AwsGovCloudUs (2.91s)
--- PASS: TestAccAWSProvider_Endpoints_Deprecated (2.98s)
--- PASS: TestAccAWSProvider_Endpoints (3.01s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	4.065s

…ith Go test caching

Go 1.10+ will automatically cache successful test results if it detects no local changes: https://golang.org/doc/go1.10#test

When running acceptance testing to attempt to find eventual consistency issues by repeatedly running the same tests, its possible this Go test caching will inadvertently make it hard to detect inconsistent remote results. The testing output does not make it obvious for individual tests (at least in Go 1.13.0) that the results are actually cached except for the final line which mentions `(cached)`:

```console
$ time TF_LOG_PATH=/tmp/${AWS_PROFILE}.txt TF_LOG=debug TF_ACC=1 go test ./aws -v -timeout 120m -parallel 20 -run='TestAccAWSWafWebAcl_Rules'
=== RUN   TestAccAWSWafWebAcl_Rules
=== PAUSE TestAccAWSWafWebAcl_Rules
=== CONT  TestAccAWSWafWebAcl_Rules
--- PASS: TestAccAWSWafWebAcl_Rules (35.42s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws    (cached)
TF_LOG_PATH=/tmp/${AWS_PROFILE}.txt TF_LOG=debug TF_ACC=1 go test ./aws -v     10.87s user 3.64s system 267% cpu 5.419 total
```

Output from acceptance testing:

```console
$ make testacc TEST=./aws TESTARGS=-run='TestAccAWSProvider_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSProvider_ -timeout 120m
=== RUN   TestAccAWSProvider_Endpoints
=== PAUSE TestAccAWSProvider_Endpoints
=== RUN   TestAccAWSProvider_Endpoints_Deprecated
=== PAUSE TestAccAWSProvider_Endpoints_Deprecated
=== RUN   TestAccAWSProvider_Region_AwsChina
=== PAUSE TestAccAWSProvider_Region_AwsChina
=== RUN   TestAccAWSProvider_Region_AwsCommercial
=== PAUSE TestAccAWSProvider_Region_AwsCommercial
=== RUN   TestAccAWSProvider_Region_AwsGovCloudUs
=== PAUSE TestAccAWSProvider_Region_AwsGovCloudUs
=== CONT  TestAccAWSProvider_Endpoints
=== CONT  TestAccAWSProvider_Region_AwsChina
=== CONT  TestAccAWSProvider_Endpoints_Deprecated
=== CONT  TestAccAWSProvider_Region_AwsCommercial
=== CONT  TestAccAWSProvider_Region_AwsGovCloudUs
--- PASS: TestAccAWSProvider_Region_AwsCommercial (2.77s)
--- PASS: TestAccAWSProvider_Region_AwsChina (2.78s)
--- PASS: TestAccAWSProvider_Region_AwsGovCloudUs (2.91s)
--- PASS: TestAccAWSProvider_Endpoints_Deprecated (2.98s)
--- PASS: TestAccAWSProvider_Endpoints (3.01s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	4.065s
```
@bflad bflad added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. technical-debt Addresses areas of the codebase that need refactoring or redesign. provider Pertains to the provider itself, rather than any interaction with AWS. labels Sep 25, 2019
@bflad bflad requested a review from a team September 25, 2019 18:48
@ghost ghost added the size/XS Managed by automation to categorize the size of a PR. label Sep 25, 2019
Copy link
Contributor

@aeschright aeschright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bflad bflad added this to the v2.30.0 milestone Sep 25, 2019
@bflad bflad merged commit 42f7b0e into master Sep 25, 2019
@bflad bflad deleted the td-testacc-test-caching branch September 25, 2019 20:03
@ghost
Copy link

ghost commented Sep 26, 2019

This has been released in version 2.30.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Nov 1, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
provider Pertains to the provider itself, rather than any interaction with AWS. size/XS Managed by automation to categorize the size of a PR. technical-debt Addresses areas of the codebase that need refactoring or redesign. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants