test(ec2): stop describeDefaultSecurityGroup flaking on shared store (#1477)

Filter DescribeSecurityGroups by group-name + vpc-id instead of assuming the
default group is item[0] of an unfiltered list, and tear down the stack the CFN
deleteStack test recreates. Both prevent flaky failures caused by other tests
leaving security groups behind in the shared in-memory EC2 store.
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-06-20 13:03:13 -05:00
1 parent bb5a37d19e
commit 0bb6c6e76a
2 files changed
+17

No files matched your search

@@ -5284,6 +5284,15 @@ class CloudFormationIntegrationTest {
.formParam("TemplateBody", template)
.when().post("/")
.then().statusCode(200);
// Tear the recreated stack back down so the security group is not left behind in the
// shared in-memory EC2 store, where it would pollute other tests' DescribeSecurityGroups.
given()
.formParam("Action", "DeleteStack")
.formParam("Version", "2010-05-15")
.formParam("StackName", stackName)
.when().post("/")
.then().statusCode(200);
}
@Test
@@ -92,8 +92,16 @@ class Ec2IntegrationTest {
@Test
@Order(3)
void describeDefaultSecurityGroup() {
// Filter to the default VPC's default group rather than assuming it is item[0] of an
// unfiltered list: DescribeSecurityGroups returns groups in the store's iteration order,
// so any other group in this region (e.g. one left behind by another test class sharing
// the in-memory EC2 store) could otherwise land at item[0] and flake this assertion.
given()
.formParam("Action", "DescribeSecurityGroups")
.formParam("Filter.1.Name", "group-name")
.formParam("Filter.1.Value.1", "default")
.formParam("Filter.2.Name", "vpc-id")
.formParam("Filter.2.Value.1", "vpc-default")
.header("Authorization", AUTH_HEADER)
.when()
.post("/")