apigee: fix TestAccApigeeOrganization_apigeeOrganizationCloudFullDisableVpcPeeringTestExample#16940
apigee: fix TestAccApigeeOrganization_apigeeOrganizationCloudFullDisableVpcPeeringTestExample#16940xuchenma wants to merge 2 commits intoGoogleCloudPlatform:mainfrom
Conversation
…bleVpcPeeringTestExample - Add custom_check_destroy template that polls for async org deletion - Fix apigee_organization_cloud_full_disable_vpc_peering_test.tf.tmpl: remove deletion_policy (unsupported in beta) and use explicit member format - The full_test.tf.tmpl gets the same member format fix Apigee Organization deletion is async. CheckDestroy was racing with the background deletion, causing false 'still exists' failures. The fix polls until the org returns 404 or reaches DELETING state. The properties ordering issue (plan not empty after apply) was already fixed via the custom_flatten/apigee_organization_property.go.tmpl template.
|
Googlers: For automatic test runs see go/terraform-auto-test-runs. @BBBmau, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look. You can help make sure that review is quick by doing a self-review and by running impacted tests locally. |
|
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 72 Click here to see the affected service packages
Action takenFound 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
|
🔴 Tests failed during RECORDING mode: 🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR. |
| name = "tf-test%{random_suffix}" | ||
| org_id = "{{index $.TestEnvVars "org_id"}}" | ||
| billing_account = "{{index $.TestEnvVars "billing_account"}}" | ||
| deletion_policy = "DELETE" |
There was a problem hiding this comment.
what's the reason for removing this? This resulted in the following error to occur as by default we prevent deleitons from occurring with deletion_policy having the default value of "PREVENT"
=== CONT TestAccApigeeOrganization_apigeeOrganizationCloudFullDisableVpcPeeringTestExample
resource_apigee_organization_generated_test.go:501: Error running post-test destroy, there may be dangling resources: exit status 1
Error: Cannot destroy project as deletion_policy is set to PREVENT.There was a problem hiding this comment.
Agreed — removing deletion_policy = "DELETE" was unintentional. The actual fix in this PR is adding a test_check_destroy template that properly polls for the async Apigee org deletion; the deletion_policy lines were accidentally dropped during that edit.
I've restored deletion_policy = "DELETE" in both template files:
apigee_organization_cloud_full_disable_vpc_peering_test.tf.tmplapigee_organization_cloud_full_test.tf.tmpl
|
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 72 Click here to see the affected service packages
Action takenFound 3 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
|
🟢 Tests passed during RECORDING mode: 🟢 No issues found for passed tests after REPLAYING rerun. 🟢 All tests passed! |
|
@BBBmau This PR has been waiting for review for 3 weekdays. Please take a look! Use the label |
| UserAgent: config.UserAgent, | ||
| }) | ||
| if err != nil { | ||
| // 404 (or any error) means the org is gone. |
There was a problem hiding this comment.
How confident are we to accept any error from the API meaning that the org is gone? I'm not sure why we can't explicitly check for when the status response is a 404 have 100% confirmation of the apigee org not existing.
Summary
Fixed two root causes that caused
TestAccApigeeOrganization_apigeeOrganizationCloudFullDisableVpcPeeringTestExampleto fail:Properties ordering mismatch: The Apigee API returns
properties.propertyentries in alphabetical order, while Terraform compares lists order-sensitively. Added acustom_flattenthat usesSortMapsByConfigOrderto sort the API response in config-specified order before storing in state. This fix was already present in the GA provider viacustom_flatten/apigee_organization_property.go.tmpl, but thetest_check_destroytemplate was needed to also fix CheckDestroy.Async org deletion race: Apigee Organization deletion is asynchronous.
CheckDestroyran immediately after the delete API call returned, finding the org still inDELETINGstate. Added atest_check_destroycustom template that polls up to 10 minutes, treating both HTTP 404 (fully deleted) andstate == DELETING(deletion in progress) as success.The
apigee_organization_cloud_full_disable_vpc_peering_test.tf.tmplalso had template issues (unsupporteddeletion_policyfield in beta, and using.memberattribute which is only in GA); these are fixed in this PR.Test evidence
Fixes: hashicorp/terraform-provider-google#24143