test(cloudformation): delete the alarm stack after the integration test (#9642)

CloudFormationCloudWatchAlarmIntegrationTest left its stack and metric alarm in the shared emulator, where later tests could find them. The stack name is now a field, the alarm is named after it, and an @AfterEach deletes the stack through CfnStackWaits.deleteStack and waits for the deletion, even when an assertion fails.

Co-authored-by: Andre Kurait <akurait@amazon.com>
Signed-off-by: Andre Kurait <akurait@amazon.com>
Signed-off-by: Jackson Price <jxnprice@amazon.com>
This commit is contained in:
Jackson PriceandAndre Kurait authored and GitHub committed 2026-11-28 08:19:53 -04:00
1 parent 2effefbbf0
commit 70cf13bc4c
1 file changed
+9 -3
@@ -2,6 +2,7 @@ package io.floci.aws.services.cloudformation;
import io.floci.aws.testing.CfnStackWaits;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
@@ -20,11 +21,16 @@ class CloudFormationCloudWatchAlarmIntegrationTest {
private static final String CW_AUTH =
"AWS4-HMAC-SHA256 Credential=test/20260205/us-east-1/monitoring/aws4_request";
private final String stackName = "cfn-cw-alarm-stack-" + Long.toString(System.nanoTime(), 36);
@AfterEach
void deleteStack() {
CfnStackWaits.deleteStack(stackName, CFN_AUTH);
}
@Test
void createStackProvisionsAlarmVisibleToCloudWatch() {
String suffix = Long.toString(System.nanoTime(), 36);
String alarmName = "cfn-alarm-" + suffix;
String stackName = "cfn-cw-alarm-stack-" + suffix;
String alarmName = stackName + "-alarm";
String template = """
{