Skip to content

Commit

Permalink
d/aws_elbv2_listener_rule(test): fix flaky test configuration (hashic…
Browse files Browse the repository at this point in the history
…orp#40142)

This change prevents intermittent panics caused by variable lengths of the random integer appended to the generated resource name. This approach now mirrors how the corresponding resoure acceptance test handles truncating the generated resource name.

```console
% make testacc PKG=elbv2 TESTS=TestAccELBV2ListenerRuleDataSource_actionForwardWeightedStickiness
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.2 test ./internal/service/elbv2/... -v -count 1 -parallel 20 -run='TestAccELBV2ListenerRuleDataSource_actionForwardWeightedStickiness'  -timeout 360m
2024/11/15 09:31:54 Initializing Terraform AWS Provider...

--- PASS: TestAccELBV2ListenerRuleDataSource_actionForwardWeightedStickiness (237.37s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/elbv2      243.811s
```
  • Loading branch information
jar-b authored Nov 18, 2024
1 parent 8206f58 commit 2bbd9b3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/service/elbv2/listener_rule_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ func TestAccELBV2ListenerRuleDataSource_actionForwardWeightedStickiness(t *testi

var listenerRule awstypes.Rule
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
rName = rName[:min(len(rName), 30)]
dataSourceName := "data.aws_lb_listener_rule.test"
resourceName := "aws_lb_listener_rule.test"

Expand Down Expand Up @@ -1106,7 +1107,7 @@ resource "aws_security_group" "test" {
cidr_blocks = ["0.0.0.0/0"]
}
}
`, rName[:30]))
`, rName))
}

func testAccListenerRuleDataSourceConfig_actionRedirect(rName string) string {
Expand Down

0 comments on commit 2bbd9b3

Please sign in to comment.