test(autoscaling): scope mixed-policy override assertion to Overrides block (#1609)

updateMixedInstancesPolicyOverridesAndDistribution asserted that the
DescribeAutoScalingGroups response contained no <InstanceType>t4g.medium</InstanceType>
anywhere after switching the override to r7g.large. The background
AutoScalingReconciler may have already launched an instance with the
original t4g.medium override, which legitimately keeps its instance type
after a policy update (matching AWS). That instance appears under
<Instances>, making the whole-response assertion flaky.

Scope the negative check to the <Overrides> block so it verifies the
policy was updated without being tripped by a previously launched
instance.
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-06-27 00:53:42 -05:00
1 parent 1dc48eca39
commit aeb11d77c3
1 file changed
+10 -3
@@ -745,7 +745,7 @@ class AutoScalingIntegrationTest {
.statusCode(200)
.body(containsString("UpdateAutoScalingGroupResponse"));
given()
String describeBody = given()
.formParam("Action", "DescribeAutoScalingGroups")
.formParam("AutoScalingGroupNames.member.1", "my-mixed-asg")
.header("Authorization", AUTH)
@@ -755,10 +755,17 @@ class AutoScalingIntegrationTest {
.statusCode(200)
.body(containsString("<Version>5</Version>"))
.body(containsString("<InstanceType>r7g.large</InstanceType>"))
.body(not(containsString("<InstanceType>t4g.medium</InstanceType>")))
.body(containsString("<OnDemandBaseCapacity>2</OnDemandBaseCapacity>"))
.body(containsString("<OnDemandPercentageAboveBaseCapacity>50</OnDemandPercentageAboveBaseCapacity>"))
.body(containsString("<SpotAllocationStrategy>price-capacity-optimized</SpotAllocationStrategy>"));
.body(containsString("<SpotAllocationStrategy>price-capacity-optimized</SpotAllocationStrategy>"))
.extract().asString();
// Scope the negative check to the policy overrides: a previously launched
// instance keeps its original instance type after a policy update (matching
// AWS), so t4g.medium may still appear under <Instances>.
String overrides = describeBody.substring(
describeBody.indexOf("<Overrides>"), describeBody.indexOf("</Overrides>"));
assertThat(overrides, not(containsString("<InstanceType>t4g.medium</InstanceType>")));
}
@Test