From 2bbd9b3f2606af79fb3bab974085956669ace68b Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Mon, 18 Nov 2024 16:16:21 -0500 Subject: [PATCH] d/aws_elbv2_listener_rule(test): fix flaky test configuration (#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 ``` --- internal/service/elbv2/listener_rule_data_source_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/service/elbv2/listener_rule_data_source_test.go b/internal/service/elbv2/listener_rule_data_source_test.go index 1ff650d9ef7..a928c4b8d65 100644 --- a/internal/service/elbv2/listener_rule_data_source_test.go +++ b/internal/service/elbv2/listener_rule_data_source_test.go @@ -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" @@ -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 {