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

Sweepers: Initialize conn.AWSClient.ServicePackages as AWS API clients are now lazy-loaded #32119

Merged
merged 8 commits into from
Jun 21, 2023

Conversation

ewbankkit
Copy link
Contributor

@ewbankkit ewbankkit commented Jun 20, 2023

Description

As AWS API clients are now lazy-loaded, using functions defined in each service package to create the clients, we need to initialize the list of service packages before creating the conn.AWSClient structures for test sweepers.

Before
% make sweep SWEEPARGS=-sweep-run=aws_accessanalyzer_analyzer
# make sweep SWEEPARGS=-sweep-run=aws_example_thing
# set SWEEPARGS=-sweep-allow-failures to continue after first failure
WARNING: This will destroy infrastructure. Use only in development accounts.
go test ./internal/sweep -v -tags=sweep -sweep=us-west-2,us-east-1,us-east-2 -sweep-run=aws_accessanalyzer_analyzer -timeout 60m
2023/06/20 16:32:43 [DEBUG] Running Sweepers for region (us-west-2):
2023/06/20 16:32:43 [DEBUG] Running Sweeper (aws_accessanalyzer_analyzer) in region (us-west-2)
panic: unknown service package: accessanalyzer

goroutine 1 [running]:
github.com/hashicorp/terraform-provider-aws/internal/errs.Must[...](0xf0d06f0?, {0xefd15e0?, 0xc000756870?})
	/Users/ewbankkit/altsrc.2/github.com/terraform-providers/terraform-provider-aws/internal/errs/must.go:10 +0x45
github.com/hashicorp/terraform-provider-aws/internal/conns.(*AWSClient).AccessAnalyzerClient(0xf0d06f0?, {0xf0d06f0?, 0xc00020e008?})
	/Users/ewbankkit/altsrc.2/github.com/terraform-providers/terraform-provider-aws/internal/conns/awsclient_gen.go:360 +0x4f
github.com/hashicorp/terraform-provider-aws/internal/service/accessanalyzer.sweepAnalyzers({0x7ff7bfeff1b3, 0x9})
	/Users/ewbankkit/altsrc.2/github.com/terraform-providers/terraform-provider-aws/internal/service/accessanalyzer/sweep.go:30 +0xf0
github.com/hashicorp/terraform-plugin-testing/helper/resource.runSweeperWithRegion({0x7ff7bfeff1b3, 0x9}, 0xc00064b680, 0x1895ca68?, 0xd0?, 0xa0?)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-testing@v1.3.0/helper/resource/testing.go:272 +0x15b
github.com/hashicorp/terraform-plugin-testing/helper/resource.runSweepers({0xc000af0d20, 0x3, 0xdded6ca?}, 0x1?, 0x0)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-testing@v1.3.0/helper/resource/testing.go:150 +0x428
github.com/hashicorp/terraform-plugin-testing/helper/resource.TestMain({0xeff4c80, 0xc000ad05a0})
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-testing@v1.3.0/helper/resource/testing.go:128 +0xff
github.com/hashicorp/terraform-provider-aws/internal/sweep_test.TestMain(...)
	/Users/ewbankkit/altsrc.2/github.com/terraform-providers/terraform-provider-aws/internal/sweep/sweep_test.go:155
main.main()
	_testmain.go:49 +0x205
FAIL	github.com/hashicorp/terraform-provider-aws/internal/sweep	5.842s
FAIL
make: *** [sweep] Error 1
After
% make sweep SWEEPARGS=-sweep-run=aws_accessanalyzer_analyzer
# make sweep SWEEPARGS=-sweep-run=aws_example_thing
# set SWEEPARGS=-sweep-allow-failures to continue after first failure
WARNING: This will destroy infrastructure. Use only in development accounts.
go test ./internal/sweep -v -tags=sweep -sweep=us-west-2,us-east-1,us-east-2 -sweep-run=aws_accessanalyzer_analyzer -timeout 60m
2023/06/20 16:55:30 [DEBUG] Running Sweepers for region (us-west-2):
2023/06/20 16:55:30 [DEBUG] Running Sweeper (aws_accessanalyzer_analyzer) in region (us-west-2)
2023/06/20 16:55:31 [DEBUG] Completed Sweeper (aws_accessanalyzer_analyzer) in region (us-west-2) in 925.364309ms
2023/06/20 16:55:31 Completed Sweepers for region (us-west-2) in 925.608966ms
2023/06/20 16:55:31 Sweeper Tests for region (us-west-2) ran successfully:
	- aws_accessanalyzer_analyzer
2023/06/20 16:55:31 [DEBUG] Running Sweepers for region (us-east-1):
2023/06/20 16:55:31 [DEBUG] Running Sweeper (aws_accessanalyzer_analyzer) in region (us-east-1)
2023/06/20 16:55:31 [DEBUG] Completed Sweeper (aws_accessanalyzer_analyzer) in region (us-east-1) in 265.921304ms
2023/06/20 16:55:31 Completed Sweepers for region (us-east-1) in 265.980847ms
2023/06/20 16:55:31 Sweeper Tests for region (us-east-1) ran successfully:
	- aws_accessanalyzer_analyzer
2023/06/20 16:55:31 [DEBUG] Running Sweepers for region (us-east-2):
2023/06/20 16:55:31 [DEBUG] Running Sweeper (aws_accessanalyzer_analyzer) in region (us-east-2)
2023/06/20 16:55:32 [DEBUG] Completed Sweeper (aws_accessanalyzer_analyzer) in region (us-east-2) in 402.806927ms
2023/06/20 16:55:32 Completed Sweepers for region (us-east-2) in 402.866443ms
2023/06/20 16:55:32 Sweeper Tests for region (us-east-2) ran successfully:
	- aws_accessanalyzer_analyzer
ok  	github.com/hashicorp/terraform-provider-aws/internal/sweep	6.863s

Relations

Relates #31927.

@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/XL Managed by automation to categorize the size of a PR. generators Relates to code generators. repository Repository modifications; GitHub Actions, developer docs, issue templates, codeowners, changelog. sweeper Pertains to changes to or issues with the sweeper. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jun 20, 2023
@gdavison gdavison self-assigned this Jun 21, 2023
Copy link
Contributor

@gdavison gdavison left a comment

Choose a reason for hiding this comment

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

Just one comment, otherwise looks good 🚀

GNUmakefile Show resolved Hide resolved
# Conflicts:
#	internal/generate/sweepimp/file.tmpl
#	internal/sweep/sweep.go
#	internal/sweep/sweep_test.go
@ewbankkit ewbankkit merged commit 31443bf into main Jun 21, 2023
35 checks passed
@ewbankkit ewbankkit deleted the s-lazy-load-aws-api-clients branch June 21, 2023 12:20
@github-actions github-actions bot added this to the v5.5.0 milestone Jun 21, 2023
@github-actions
Copy link

This functionality has been released in v5.5.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 Jul 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
generators Relates to code generators. repository Repository modifications; GitHub Actions, developer docs, issue templates, codeowners, changelog. 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.

2 participants