-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
tests/provider: Introduce shared disappears TestCheckFunc, refactor Backup testing to implement and verify #12864
Conversation
…ackup testing to implement and verify A common problem in Terraform Providers is the need to verify that a Terraform Resource will successfully remove itself from the Terraform state when externally deleted. In an effort to test this functionality, the Terraform AWS Provider has implemented testing, commonly named `_disappears` in each resource's acceptance testing, where each test includes a `TestCheckFunc` that manually reimplements the deletion functionality of the resource. This change proposes the introduction of a shared `TestCheckFunc` that can prevent the necessity of manually reimplementing the resource deletion code in a `TestCheckFunc` for each resource. If acceptable, a GitHub issue will be created outlining a refactoring and documentation proposal for the provider codebase. It is worth noting that in the future, the Terraform Plugin SDK's acceptance testing framework could introduce native functionality for this type of common testing, but this shared `TestCheckFunc` is an effort to reduce a current development pain point. Output from acceptance testing: ``` --- PASS: TestAccAwsBackupVault_disappears (13.75s) --- PASS: TestAccAwsBackupPlan_disappears (18.15s) --- PASS: TestAccAwsBackupSelection_disappears (24.02s) ```
aws/provider_test.go
Outdated
} | ||
|
||
if resourceState.Primary.ID == "" { | ||
return fmt.Errorf("resource ID missing:: %s", resourceName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra :
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 😄
…error message Reference: #12864 (review)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
--- PASS: TestProvider_impl (0.02s)
--- PASS: TestProvider (0.85s)
--- PASS: TestAccAWSProvider_Region_AwsChina (10.24s)
--- PASS: TestAccAWSProvider_Region_AwsCommercial (11.48s)
--- PASS: TestAccAWSProvider_Region_AwsGovCloudUs (11.29s)
--- PASS: TestAccAWSProvider_IgnoreTags_Keys_One (12.59s)
--- PASS: TestAccAWSProvider_IgnoreTags_EmptyConfigurationBlock (12.77s)
--- PASS: TestAccAWSProvider_IgnoreTags_KeyPrefixes_None (13.07s)
--- PASS: TestAccAWSProvider_IgnoreTags_KeyPrefixes_One (13.34s)
--- PASS: TestAccAWSProvider_IgnoreTags_Keys_None (13.46s)
--- PASS: TestAccAWSProvider_IgnoreTags_Keys_Multiple (14.05s)
--- PASS: TestAccAWSProvider_IgnoreTags_KeyPrefixes_Multiple (13.93s)
--- PASS: TestAccAWSProvider_Endpoints_Deprecated (15.50s)
--- PASS: TestAccAWSProvider_Endpoints (15.77s)
--- PASS: TestAccAwsBackupPlan_basic (17.67s)
--- PASS: TestAccAwsBackupPlan_Rule_CopyAction_Multiple (17.98s)
--- PASS: TestAccAwsBackupPlan_disappears (11.93s)
--- PASS: TestAccAwsBackupVault_disappears (9.28s)
--- PASS: TestAccAwsBackupPlan_Rule_CopyAction_CrossRegion (23.49s)
--- PASS: TestAccAwsBackupVault_basic (12.03s)
--- PASS: TestAccAwsBackupSelection_basic (15.07s)
--- PASS: TestAccAwsBackupSelection_withTags (14.30s)
--- PASS: TestAccAwsBackupSelection_disappears (15.83s)
--- PASS: TestAccAwsBackupPlan_withRules (28.99s)
--- PASS: TestAccAwsBackupPlan_withTags (29.42s)
--- PASS: TestAccAwsBackupPlan_withRecoveryPointTags (30.27s)
--- PASS: TestAccAwsBackupPlan_Rule_CopyAction_SameRegion (30.89s)
--- PASS: TestAccAwsBackupSelection_updateTag (19.15s)
--- PASS: TestAccAwsBackupPlan_withLifecycle (35.36s)
--- PASS: TestAccAwsBackupSelection_withResources (22.94s)
--- PASS: TestAccAwsBackupVault_withTags (21.83s)
--- PASS: TestAccAwsBackupVault_withKmsKey (30.63s)
This has been released in version 2.60.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! |
…ackup testing to implement and verify (hashicorp#12864) * tests/provider: Introduce shared disappears TestCheckFunc, refactor Backup testing to implement and verify A common problem in Terraform Providers is the need to verify that a Terraform Resource will successfully remove itself from the Terraform state when externally deleted. In an effort to test this functionality, the Terraform AWS Provider has implemented testing, commonly named `_disappears` in each resource's acceptance testing, where each test includes a `TestCheckFunc` that manually reimplements the deletion functionality of the resource. This change proposes the introduction of a shared `TestCheckFunc` that can prevent the necessity of manually reimplementing the resource deletion code in a `TestCheckFunc` for each resource. If acceptable, a GitHub issue will be created outlining a refactoring and documentation proposal for the provider codebase. It is worth noting that in the future, the Terraform Plugin SDK's acceptance testing framework could introduce native functionality for this type of common testing, but this shared `TestCheckFunc` is an effort to reduce a current development pain point. Output from acceptance testing: ``` --- PASS: TestAccAwsBackupVault_disappears (13.75s) --- PASS: TestAccAwsBackupPlan_disappears (18.15s) --- PASS: TestAccAwsBackupSelection_disappears (24.02s) ``` * tests/provider: Remove extra colon in testAccCheckResourceDisappears error message Reference: hashicorp#12864 (review)
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! |
Community Note
Release note for CHANGELOG:
A common problem in Terraform Providers is the need to verify that a Terraform Resource will successfully remove itself from the Terraform state when externally deleted. In an effort to test this functionality, the Terraform AWS Provider has implemented testing, commonly named
_disappears
in each resource's acceptance testing, where each test includes aTestCheckFunc
that manually reimplements the deletion functionality of the resource.This change proposes the introduction of a shared
TestCheckFunc
that can prevent the necessity of manually reimplementing the resource deletion code in aTestCheckFunc
for each resource. If acceptable, a GitHub issue will be created outlining a refactoring and documentation proposal for the provider codebase.It is worth noting that in the future, the Terraform Plugin SDK's acceptance testing framework could introduce native functionality for this type of common testing, but this shared
TestCheckFunc
is an effort to reduce a current development pain point.Output from acceptance testing: