Skip to content

Commit

Permalink
r/aws_iam_role_policy_attachments_exclusive(test): fix test configura…
Browse files Browse the repository at this point in the history
…tion (#39729)

During a refactor of the initial implementation, the `Config` field was updated during the first test step but not the second. This introduced a race condition between detachment and deletion of the out of band policy, resulting in intermittent failures deleting the policy. The impacted test now appropriately uses the same configuration throughout all test steps.

```console
% make testacc PKG=iam TESTS=TestAccIAMRolePolicyAttachmentsExclusive_
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.2 test ./internal/service/iam/... -v -count 1 -parallel 20 -run='TestAccIAMRolePolicyAttachmentsExclusive_'  -timeout 360m
2024/10/15 13:56:16 Initializing Terraform AWS Provider...

--- PASS: TestAccIAMRolePolicyAttachmentsExclusive_empty (15.49s)
--- PASS: TestAccIAMRolePolicyAttachmentsExclusive_disappears_Role (17.15s)
--- PASS: TestAccIAMRolePolicyAttachmentsExclusive_disappears_Policy (17.45s)
--- PASS: TestAccIAMRolePolicyAttachmentsExclusive_basic (17.85s)
--- PASS: TestAccIAMRolePolicyAttachmentsExclusive_outOfBandAddition (25.47s)
--- PASS: TestAccIAMRolePolicyAttachmentsExclusive_outOfBandRemoval (25.58s)
--- PASS: TestAccIAMRolePolicyAttachmentsExclusive_multiple (25.99s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/iam        31.059s
```
  • Loading branch information
jar-b authored Oct 15, 2024
1 parent 0e4ee68 commit ca7bd21
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func TestAccIAMRolePolicyAttachmentsExclusive_outOfBandAddition(t *testing.T) {
ExpectNonEmptyPlan: true,
},
{
Config: testAccRolePolicyAttachmentsExclusiveConfig_basic(rName),
Config: testAccRolePolicyAttachmentsExclusiveConfig_outOfBandAddition(rName, oobPolicyName),
Check: resource.ComposeTestCheckFunc(
testAccCheckRoleExists(ctx, roleResourceName, &role),
testAccCheckRolePolicyAttachmentsExclusiveExists(ctx, resourceName),
Expand Down

0 comments on commit ca7bd21

Please sign in to comment.