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

VCR testing phase 1 #25587

Merged
merged 106 commits into from
Jan 13, 2023
Merged

VCR testing phase 1 #25587

merged 106 commits into from
Jan 13, 2023

Conversation

ewbankkit
Copy link
Contributor

@ewbankkit ewbankkit commented Jun 27, 2022

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" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Introduces facilities to enable VCR testing via go-vcr.
VCR provides facilities to transparently record and replay HTTP requests and responses, enabling fast, deterministic and accurate testing of HTTP API interactions.

This PR adds functionality to the acctest package to

  • Replace the provider's HTTP Transport with go-vcr's for AWS SDK for Go v1 API clients
  • Provide "deterministic randomness" so that recording and replaying HTTP interactions use the same seed

Recording

% VCR_MODE=RECORDING VCR_PATH=$PWD make testacc TESTARGS='-run=TestAccRDSInstance_basic' PKG=rds
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/rds/... -v -count 1 -parallel 20  -run=TestAccRDSInstance_basic -timeout 180m
=== RUN   TestAccRDSInstance_basic
2022/06/26 16:53:23 [DEBUG] initializing VCR
=== PAUSE TestAccRDSInstance_basic
=== CONT  TestAccRDSInstance_basic
--- PASS: TestAccRDSInstance_basic (589.23s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/rds	591.896s

Replaying

% VCR_MODE=REPLAYING VCR_PATH=$PWD make testacc TESTARGS='-run=TestAccRDSInstance_basic' PKG=rds
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/rds/... -v -count 1 -parallel 20  -run=TestAccRDSInstance_basic -timeout 180m
=== RUN   TestAccRDSInstance_basic
2022/06/26 17:56:15 [DEBUG] initializing VCR
=== PAUSE TestAccRDSInstance_basic
=== CONT  TestAccRDSInstance_basic
--- PASS: TestAccRDSInstance_basic (54.08s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/rds	58.161s

Enabling VCR Testing

VCR testing is configured through the use of two environment variables, both of which must be set in order to enable the facility:

  • VCR_MODE - there are two valid values:
    • RECORDING - indicates that VCR is recording HTTP interactions and will persist successful HTTP request/response pairs to a cassette file
    • REPLAYING - indicates that VCR is replaying, from the cassette file matching HTTP requests
  • VCR_PATH - indicates the file system location for cassette files

Cassettes are the YAML files (one per acceptance test) generated by VCR that contain HTTP requests and responses.

References

Leverages the great work done for VCR testing in the Terraform GCP Provider.

TODO

  • Maybe use context.Context to signal that VCR replay is enabled for tfresource?

Relates: #25602.
Relates: #18419.

@github-actions github-actions bot added service/rds Issues and PRs that pertain to the rds service. service/vpc Issues and PRs that pertain to the vpc service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/XL Managed by automation to categorize the size of a PR. and removed tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/rds Issues and PRs that pertain to the rds service. service/vpc Issues and PRs that pertain to the vpc service. labels Jun 27, 2022
@ewbankkit ewbankkit added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. provider Pertains to the provider itself, rather than any interaction with AWS. labels Jun 27, 2022
@github-actions github-actions bot added service/rds Issues and PRs that pertain to the rds service. and removed provider Pertains to the provider itself, rather than any interaction with AWS. labels Jun 27, 2022
@ewbankkit ewbankkit changed the title [WIP] VCR testing phase 1 VCR testing phase 1 Jun 27, 2022
@github-actions github-actions bot added the service/logs Issues and PRs that pertain to the logs service. label Jun 30, 2022
@github-actions github-actions bot added generators Relates to code generators. provider Pertains to the provider itself, rather than any interaction with AWS. labels Jan 12, 2023
@github-actions github-actions bot added service/scheduler Issues and PRs that pertain to the scheduler service. sweeper Pertains to changes to or issues with the sweeper. labels Jan 13, 2023
@ewbankkit
Copy link
Contributor Author

ewbankkit commented Jan 13, 2023

% make testacc TESTARGS='-run=TestAccLogsGroup_' PKG=logs ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/logs/... -v -count 1 -parallel 3  -run=TestAccLogsGroup_ -timeout 180m
=== RUN   TestAccLogsGroup_basic
=== PAUSE TestAccLogsGroup_basic
=== RUN   TestAccLogsGroup_nameGenerate
=== PAUSE TestAccLogsGroup_nameGenerate
=== RUN   TestAccLogsGroup_namePrefix
=== PAUSE TestAccLogsGroup_namePrefix
=== RUN   TestAccLogsGroup_disappears
=== PAUSE TestAccLogsGroup_disappears
=== RUN   TestAccLogsGroup_tags
=== PAUSE TestAccLogsGroup_tags
=== RUN   TestAccLogsGroup_kmsKey
=== PAUSE TestAccLogsGroup_kmsKey
=== RUN   TestAccLogsGroup_retentionPolicy
=== PAUSE TestAccLogsGroup_retentionPolicy
=== RUN   TestAccLogsGroup_multiple
=== PAUSE TestAccLogsGroup_multiple
=== RUN   TestAccLogsGroup_skipDestroy
=== PAUSE TestAccLogsGroup_skipDestroy
=== CONT  TestAccLogsGroup_basic
=== CONT  TestAccLogsGroup_kmsKey
=== CONT  TestAccLogsGroup_multiple
--- PASS: TestAccLogsGroup_multiple (15.15s)
=== CONT  TestAccLogsGroup_skipDestroy
--- PASS: TestAccLogsGroup_basic (17.35s)
=== CONT  TestAccLogsGroup_tags
--- PASS: TestAccLogsGroup_skipDestroy (13.25s)
=== CONT  TestAccLogsGroup_retentionPolicy
--- PASS: TestAccLogsGroup_kmsKey (49.12s)
=== CONT  TestAccLogsGroup_namePrefix
--- PASS: TestAccLogsGroup_retentionPolicy (29.04s)
=== CONT  TestAccLogsGroup_nameGenerate
--- PASS: TestAccLogsGroup_tags (40.59s)
=== CONT  TestAccLogsGroup_disappears
--- PASS: TestAccLogsGroup_namePrefix (16.17s)
--- PASS: TestAccLogsGroup_disappears (11.82s)
--- PASS: TestAccLogsGroup_nameGenerate (16.19s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/logs	78.578s
% make testacc TESTARGS='-run=TestAccSchedulerSchedule_' PKG=scheduler ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/scheduler/... -v -count 1 -parallel 3  -run=TestAccSchedulerSchedule_ -timeout 180m
=== RUN   TestAccSchedulerSchedule_basic
=== PAUSE TestAccSchedulerSchedule_basic
=== RUN   TestAccSchedulerSchedule_disappears
=== PAUSE TestAccSchedulerSchedule_disappears
=== RUN   TestAccSchedulerSchedule_description
=== PAUSE TestAccSchedulerSchedule_description
=== RUN   TestAccSchedulerSchedule_endDate
=== PAUSE TestAccSchedulerSchedule_endDate
=== RUN   TestAccSchedulerSchedule_flexibleTimeWindow
=== PAUSE TestAccSchedulerSchedule_flexibleTimeWindow
=== RUN   TestAccSchedulerSchedule_groupName
=== PAUSE TestAccSchedulerSchedule_groupName
=== RUN   TestAccSchedulerSchedule_kmsKeyARN
=== PAUSE TestAccSchedulerSchedule_kmsKeyARN
=== RUN   TestAccSchedulerSchedule_nameGenerated
=== PAUSE TestAccSchedulerSchedule_nameGenerated
=== RUN   TestAccSchedulerSchedule_namePrefix
=== PAUSE TestAccSchedulerSchedule_namePrefix
=== RUN   TestAccSchedulerSchedule_scheduleExpression
=== PAUSE TestAccSchedulerSchedule_scheduleExpression
=== RUN   TestAccSchedulerSchedule_scheduleExpressionTimezone
=== PAUSE TestAccSchedulerSchedule_scheduleExpressionTimezone
=== RUN   TestAccSchedulerSchedule_startDate
=== PAUSE TestAccSchedulerSchedule_startDate
=== RUN   TestAccSchedulerSchedule_state
=== PAUSE TestAccSchedulerSchedule_state
=== RUN   TestAccSchedulerSchedule_targetARN
=== PAUSE TestAccSchedulerSchedule_targetARN
=== RUN   TestAccSchedulerSchedule_targetDeadLetterConfig
=== PAUSE TestAccSchedulerSchedule_targetDeadLetterConfig
=== RUN   TestAccSchedulerSchedule_targetECSParameters
=== PAUSE TestAccSchedulerSchedule_targetECSParameters
=== RUN   TestAccSchedulerSchedule_targetEventBridgeParameters
=== PAUSE TestAccSchedulerSchedule_targetEventBridgeParameters
=== RUN   TestAccSchedulerSchedule_targetInput
=== PAUSE TestAccSchedulerSchedule_targetInput
=== RUN   TestAccSchedulerSchedule_targetKinesisParameters
=== PAUSE TestAccSchedulerSchedule_targetKinesisParameters
=== RUN   TestAccSchedulerSchedule_targetRetryPolicy
=== PAUSE TestAccSchedulerSchedule_targetRetryPolicy
=== RUN   TestAccSchedulerSchedule_targetRoleARN
=== PAUSE TestAccSchedulerSchedule_targetRoleARN
=== RUN   TestAccSchedulerSchedule_targetSageMakerPipelineParameters
=== PAUSE TestAccSchedulerSchedule_targetSageMakerPipelineParameters
=== RUN   TestAccSchedulerSchedule_targetSQSParameters
=== PAUSE TestAccSchedulerSchedule_targetSQSParameters
=== CONT  TestAccSchedulerSchedule_basic
=== CONT  TestAccSchedulerSchedule_targetSageMakerPipelineParameters
=== CONT  TestAccSchedulerSchedule_targetSQSParameters
--- PASS: TestAccSchedulerSchedule_basic (51.31s)
=== CONT  TestAccSchedulerSchedule_kmsKeyARN
--- PASS: TestAccSchedulerSchedule_targetSQSParameters (89.50s)
=== CONT  TestAccSchedulerSchedule_scheduleExpressionTimezone
--- PASS: TestAccSchedulerSchedule_targetSageMakerPipelineParameters (111.84s)
=== CONT  TestAccSchedulerSchedule_scheduleExpression
--- PASS: TestAccSchedulerSchedule_kmsKeyARN (77.91s)
=== CONT  TestAccSchedulerSchedule_namePrefix
--- PASS: TestAccSchedulerSchedule_scheduleExpressionTimezone (75.99s)
=== CONT  TestAccSchedulerSchedule_nameGenerated
--- PASS: TestAccSchedulerSchedule_scheduleExpression (61.49s)
=== CONT  TestAccSchedulerSchedule_targetEventBridgeParameters
--- PASS: TestAccSchedulerSchedule_namePrefix (46.15s)
=== CONT  TestAccSchedulerSchedule_targetRoleARN
--- PASS: TestAccSchedulerSchedule_nameGenerated (45.84s)
=== CONT  TestAccSchedulerSchedule_targetRetryPolicy
--- PASS: TestAccSchedulerSchedule_targetRoleARN (60.88s)
=== CONT  TestAccSchedulerSchedule_targetKinesisParameters
--- PASS: TestAccSchedulerSchedule_targetEventBridgeParameters (86.13s)
=== CONT  TestAccSchedulerSchedule_targetInput
--- PASS: TestAccSchedulerSchedule_targetRetryPolicy (78.96s)
=== CONT  TestAccSchedulerSchedule_targetDeadLetterConfig
--- PASS: TestAccSchedulerSchedule_targetInput (68.23s)
=== CONT  TestAccSchedulerSchedule_targetECSParameters
--- PASS: TestAccSchedulerSchedule_targetKinesisParameters (111.82s)
=== CONT  TestAccSchedulerSchedule_startDate
--- PASS: TestAccSchedulerSchedule_targetDeadLetterConfig (134.82s)
=== CONT  TestAccSchedulerSchedule_targetARN
--- PASS: TestAccSchedulerSchedule_startDate (145.01s)
=== CONT  TestAccSchedulerSchedule_state
--- PASS: TestAccSchedulerSchedule_targetARN (107.97s)
=== CONT  TestAccSchedulerSchedule_description
--- PASS: TestAccSchedulerSchedule_targetECSParameters (228.17s)
=== CONT  TestAccSchedulerSchedule_endDate
--- PASS: TestAccSchedulerSchedule_state (136.08s)
=== CONT  TestAccSchedulerSchedule_groupName
--- PASS: TestAccSchedulerSchedule_description (139.36s)
=== CONT  TestAccSchedulerSchedule_flexibleTimeWindow
--- PASS: TestAccSchedulerSchedule_endDate (139.92s)
=== CONT  TestAccSchedulerSchedule_disappears
--- PASS: TestAccSchedulerSchedule_groupName (80.40s)
--- PASS: TestAccSchedulerSchedule_disappears (55.86s)
--- PASS: TestAccSchedulerSchedule_flexibleTimeWindow (109.30s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/scheduler	787.155s

@github-actions
Copy link

This functionality has been released in v4.51.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. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
client-connections Pertains to the AWS Client and service connections. generators Relates to code generators. provider Pertains to the provider itself, rather than any interaction with AWS. service/logs Issues and PRs that pertain to the logs service. service/scheduler Issues and PRs that pertain to the scheduler service. size/XL Managed by automation to categorize the size of a PR. sweeper Pertains to changes to or issues with the sweeper. 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.

1 participant