Light, fluffy, and always free - The AWS Local Emulator alternative
test(cloudformation): fix flaky tests by waiting for DeleteStack to finish (#4220)
TATSUNO “Taz” Yasuhirob2e2d116d866
diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/AcmCfnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/AcmCfnIntegrationTest.javaindex e354a43a49..4ab9c34460 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/AcmCfnIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/AcmCfnIntegrationTest.java@@ -16,7 +16,6 @@ import static org.hamcrest.Matchers.equalTo;import static org.junit.jupiter.api.Assertions.assertEquals;import static org.junit.jupiter.api.Assertions.assertNotEquals;import static org.junit.jupiter.api.Assertions.assertTrue;-import static org.junit.jupiter.api.Assertions.fail;/*** Provisions an {@code AWS::CertificateManager::Certificate} through a CloudFormation stack and@@ -91,7 +90,7 @@ class AcmCfnIntegrationTest {}@Test- void certificateStackExposesAnArnThatDescribeCertificateFinds() throws InterruptedException {+ void certificateStackExposesAnArnThatDescribeCertificateFinds() {cloudFormation(STACK, "CreateStack", TEMPLATE, Map.of());String stacks = describeStacks(STACK, "CREATE_COMPLETE");@@ -108,7 +107,7 @@ class AcmCfnIntegrationTest {.body("Certificate.Options.CertificateTransparencyLoggingPreference", equalTo("ENABLED"));cloudFormation(STACK, "DeleteStack", null, Map.of());- awaitStackDeleted(STACK);+ CfnStackWaits.awaitStackDeleted(STACK);describeCertificate(arn).then().statusCode(404)@@ -116,7 +115,7 @@ class AcmCfnIntegrationTest {}@Test- void certificateOptionsFollowTheTemplateThroughCreateAndUpdate() throws InterruptedException {+ void certificateOptionsFollowTheTemplateThroughCreateAndUpdate() {cloudFormation(OPTIONS_STACK, "CreateStack", OPTIONS_TEMPLATE, options("ENABLED", "DISABLED"));String arn = outputValue(describeStacks(OPTIONS_STACK, "CREATE_COMPLETE"), "CertArn");describeCertificate(arn).then()@@ -146,7 +145,7 @@ class AcmCfnIntegrationTest {.body("Certificate.Options.CertificateTransparencyLoggingPreference", equalTo("ENABLED"));cloudFormation(OPTIONS_STACK, "DeleteStack", null, Map.of());- awaitStackDeleted(OPTIONS_STACK);+ CfnStackWaits.awaitStackDeleted(OPTIONS_STACK);describeCertificate(replacement).then().statusCode(404)@@ -188,24 +187,6 @@ class AcmCfnIntegrationTest {}/** DeleteStack runs asynchronously; a successful delete removes the stack entirely. */- private static void awaitStackDeleted(String stack) throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", stack)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + stack + " was not deleted within the timeout");- }private static Response describeCertificate(String arn) {return given()diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayApiKeyCfnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayApiKeyCfnIntegrationTest.javaindex 86322645de..6b87f13c6a 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayApiKeyCfnIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayApiKeyCfnIntegrationTest.java@@ -17,7 +17,6 @@ import static org.hamcrest.Matchers.not;import static org.hamcrest.Matchers.startsWith;import static org.junit.jupiter.api.Assertions.assertEquals;import static org.junit.jupiter.api.Assertions.assertNotEquals;-import static org.junit.jupiter.api.Assertions.fail;/*** Provisions {@code AWS::ApiGateway::ApiKey} resources through a CloudFormation stack: a named key@@ -75,7 +74,7 @@ class ApiGatewayApiKeyCfnIntegrationTest {}@Test- void createUpdateAndDeleteApiKeys() throws InterruptedException {+ void createUpdateAndDeleteApiKeys() {cloudFormation("CreateStack", parameters("first", "false", "v1"));String created = describeStacks("CREATE_COMPLETE");String namedId = outputValue(created, "NamedRef");@@ -118,7 +117,7 @@ class ApiGatewayApiKeyCfnIntegrationTest {.body("tags.stack", equalTo("v2"));cloudFormation("DeleteStack", Map.of());- awaitStackDeleted();+ CfnStackWaits.awaitStackDeleted(STACK);getApiKey(namedId).statusCode(404);getApiKey(unnamedId).statusCode(404);@@ -159,24 +158,6 @@ class ApiGatewayApiKeyCfnIntegrationTest {}/** DeleteStack runs asynchronously; a successful delete removes the stack entirely. */- private static void awaitStackDeleted() throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", STACK)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + STACK + " was not deleted within the timeout");- }private static String outputValue(String xml, String key) {return XmlParser.extractPairs(xml, "Outputs", "OutputKey", "OutputValue").get(key);diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayDomainCfnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayDomainCfnIntegrationTest.javaindex 1037b46dcd..946de23558 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayDomainCfnIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayDomainCfnIntegrationTest.java@@ -18,7 +18,6 @@ import static org.hamcrest.Matchers.equalTo;import static org.hamcrest.Matchers.nullValue;import static org.junit.jupiter.api.Assertions.assertEquals;import static org.junit.jupiter.api.Assertions.assertTrue;-import static org.junit.jupiter.api.Assertions.fail;/*** Provisions an {@code AWS::ApiGateway::DomainName} and an {@code AWS::ApiGateway::BasePathMapping}@@ -219,7 +218,7 @@ class ApiGatewayDomainCfnIntegrationTest {invokeThroughDomain(RENAMED_DOMAIN, "/v1/items");cloudFormation(STACK, "DeleteStack", null, Map.of());- awaitStackDeleted(STACK);+ CfnStackWaits.awaitStackDeleted(STACK);getDomain(RENAMED_DOMAIN).statusCode(404);getMapping(RENAMED_DOMAIN, "v1").statusCode(404);@@ -241,7 +240,7 @@ class ApiGatewayDomainCfnIntegrationTest {.body("stage", nullValue());cloudFormation(INLINE_API_STACK, "DeleteStack", null, Map.of());- awaitStackDeleted(INLINE_API_STACK);+ CfnStackWaits.awaitStackDeleted(INLINE_API_STACK);getDomain(INLINE_DOMAIN).statusCode(404);given().when().get("/restapis/" + apiId).then().statusCode(404);@@ -289,24 +288,6 @@ class ApiGatewayDomainCfnIntegrationTest {}/** DeleteStack runs asynchronously; a successful delete removes the stack entirely. */- private static void awaitStackDeleted(String stack) throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", stack)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + stack + " was not deleted within the timeout");- }private static String outputValue(String xml, String key) {return XmlParser.extractPairs(xml, "Outputs", "OutputKey", "OutputValue").get(key);diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayGatewayResponseCfnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayGatewayResponseCfnIntegrationTest.javaindex 1f67498e3c..90101987e2 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayGatewayResponseCfnIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayGatewayResponseCfnIntegrationTest.java@@ -16,7 +16,6 @@ import static org.hamcrest.Matchers.containsString;import static org.hamcrest.Matchers.equalTo;import static org.hamcrest.Matchers.nullValue;import static org.junit.jupiter.api.Assertions.assertEquals;-import static org.junit.jupiter.api.Assertions.fail;/*** Provisions an {@code AWS::ApiGateway::GatewayResponse} against a REST API created outside the@@ -70,7 +69,7 @@ class ApiGatewayGatewayResponseCfnIntegrationTest {}@Test- void createUpdateAndDeleteAGatewayResponse() throws InterruptedException {+ void createUpdateAndDeleteAGatewayResponse() {String apiId = createMockApi(STACK);String deploymentId = createDeployment(apiId);createStage(apiId, "dev", deploymentId);@@ -110,7 +109,7 @@ class ApiGatewayGatewayResponseCfnIntegrationTest {.header("Access-Control-Allow-Origin", equalTo("https://other.example"));cloudFormation("DeleteStack", Map.of());- awaitStackDeleted();+ CfnStackWaits.awaitStackDeleted(STACK);// The stack owned the customisation, not the API: the type is back to its default.getGatewayResponse(apiId).statusCode(200).body("defaultResponse", equalTo(true));@@ -157,24 +156,6 @@ class ApiGatewayGatewayResponseCfnIntegrationTest {}/** DeleteStack runs asynchronously; a successful delete removes the stack entirely. */- private static void awaitStackDeleted() throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", STACK)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + STACK + " was not deleted within the timeout");- }private static String outputValue(String xml, String key) {return XmlParser.extractPairs(xml, "Outputs", "OutputKey", "OutputValue").get(key);diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayUsagePlanCfnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayUsagePlanCfnIntegrationTest.javaindex d7c5ad6632..5eb00f65e9 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayUsagePlanCfnIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayUsagePlanCfnIntegrationTest.java@@ -19,7 +19,6 @@ import static io.restassured.RestAssured.given;import static org.hamcrest.Matchers.containsString;import static org.hamcrest.Matchers.equalTo;import static org.junit.jupiter.api.Assertions.assertEquals;-import static org.junit.jupiter.api.Assertions.fail;/*** Provisions an {@code AWS::ApiGateway::UsagePlan} over a deployed REST API stage and an@@ -86,7 +85,7 @@ class ApiGatewayUsagePlanCfnIntegrationTest {}@Test- void createUpdateAndDeleteAUsagePlanWithAKey() throws InterruptedException {+ void createUpdateAndDeleteAUsagePlanWithAKey() {String apiId = createMockApi(STACK);String deploymentId = createDeployment(apiId);createStage(apiId, "dev", deploymentId);@@ -128,7 +127,7 @@ class ApiGatewayUsagePlanCfnIntegrationTest {getUsagePlanKey(planId, keyId).statusCode(200);cloudFormation("DeleteStack", Map.of());- awaitStackDeleted();+ CfnStackWaits.awaitStackDeleted(STACK);// The stack owned the plan and the association, not the key.getUsagePlan(planId).statusCode(404);@@ -176,24 +175,6 @@ class ApiGatewayUsagePlanCfnIntegrationTest {}/** DeleteStack runs asynchronously; a successful delete removes the stack entirely. */- private static void awaitStackDeleted() throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", STACK)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + STACK + " was not deleted within the timeout");- }private static String outputValue(String xml, String key) {return XmlParser.extractPairs(xml, "Outputs", "OutputKey", "OutputValue").get(key);diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/AppSyncCfnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/AppSyncCfnIntegrationTest.javaindex 2d49f1fa32..31f8cc7ead 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/AppSyncCfnIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/AppSyncCfnIntegrationTest.java@@ -18,7 +18,6 @@ import static org.hamcrest.Matchers.notNullValue;import static org.junit.jupiter.api.Assertions.assertEquals;import static org.junit.jupiter.api.Assertions.assertNotEquals;import static org.junit.jupiter.api.Assertions.assertTrue;-import static org.junit.jupiter.api.Assertions.fail;/*** Deploys the AppSync shape a Serverless Framework {@code appSync:} block compiles to: an API with@@ -150,7 +149,7 @@ class AppSyncCfnIntegrationTest {""";@Test- void createUpdateAndDeleteAnAppSyncApi() throws InterruptedException {+ void createUpdateAndDeleteAnAppSyncApi() {cloudFormation("CreateStack", Map.of("FieldLogLevel", "ERROR"));String created = describeStacks("CREATE_COMPLETE");@@ -229,7 +228,7 @@ class AppSyncCfnIntegrationTest {.body("resolver.pipelineConfig.functions[0]", equalTo(functionId));cloudFormation("DeleteStack", Map.of());- awaitStackDeleted();+ CfnStackWaits.awaitStackDeleted(STACK);appSync("/v1/apis/" + apiId).statusCode(404);}@@ -263,25 +262,6 @@ class AppSyncCfnIntegrationTest {.extract().asString();}- private static void awaitStackDeleted() throws InterruptedException {- for (int i = 0; i < 200; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", STACK)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + STACK + " was not deleted within the timeout");- }-private static String outputValue(String xml, String key) {return XmlParser.extractPairs(xml, "Outputs", "OutputKey", "OutputValue").get(key);}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/AutoScalingScalingPolicyCfnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/AutoScalingScalingPolicyCfnIntegrationTest.javaindex bc406a4b5b..15d4f060b4 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/AutoScalingScalingPolicyCfnIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/AutoScalingScalingPolicyCfnIntegrationTest.java@@ -17,7 +17,6 @@ import static org.hamcrest.Matchers.containsString;import static org.hamcrest.Matchers.not;import static org.junit.jupiter.api.Assertions.assertEquals;import static org.junit.jupiter.api.Assertions.assertTrue;-import static org.junit.jupiter.api.Assertions.fail;/*** Provisions two {@code AWS::AutoScaling::ScalingPolicy} resources on a group the same stack@@ -98,7 +97,7 @@ class AutoScalingScalingPolicyCfnIntegrationTest {AutoScalingService autoScalingService;@Test- void createUpdateAndDeleteScalingPolicies() throws InterruptedException {+ void createUpdateAndDeleteScalingPolicies() {cloudFormation("CreateStack", Map.of("TargetValue", "50", "Cooldown", "60"));String created = describeStacks("CREATE_COMPLETE");String trackingArn = outputValue(created, "TrackingRef");@@ -138,7 +137,7 @@ class AutoScalingScalingPolicyCfnIntegrationTest {assertEquals(2, autoScalingService.describePolicies(REGION, ASG, null).size());cloudFormation("DeleteStack", Map.of());- awaitStackDeleted();+ CfnStackWaits.awaitStackDeleted(STACK);assertEquals(List.of(), autoScalingService.describePolicies(REGION, null, List.of(trackingName, simpleName)));}@@ -177,24 +176,6 @@ class AutoScalingScalingPolicyCfnIntegrationTest {}/** DeleteStack runs asynchronously; a successful delete removes the stack entirely. */- private static void awaitStackDeleted() throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", STACK)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + STACK + " was not deleted within the timeout");- }private static String outputValue(String xml, String key) {return XmlParser.extractPairs(xml, "Outputs", "OutputKey", "OutputValue").get(key);diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/BackupVaultCfnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/BackupVaultCfnIntegrationTest.javaindex f99c228278..42dd4e2589 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/BackupVaultCfnIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/BackupVaultCfnIntegrationTest.java@@ -14,7 +14,6 @@ import static org.hamcrest.Matchers.equalTo;import static org.hamcrest.Matchers.nullValue;import static org.hamcrest.Matchers.startsWith;import static org.junit.jupiter.api.Assertions.assertEquals;-import static org.junit.jupiter.api.Assertions.fail;/*** Provisions two {@code AWS::Backup::BackupVault} resources through a CloudFormation stack, one@@ -58,7 +57,7 @@ class BackupVaultCfnIntegrationTest {""".formatted(NAMED, KMS);@Test- void createUpdateAndDeleteBackupVaults() throws InterruptedException {+ void createUpdateAndDeleteBackupVaults() {cloudFormation("CreateStack", Map.of("TagValue", "v1"));String created = describeStacks("CREATE_COMPLETE");String namedArn = outputValue(created, "NamedArn");@@ -92,7 +91,7 @@ class BackupVaultCfnIntegrationTest {.body("Tags.team", equalTo("core"));cloudFormation("DeleteStack", Map.of());- awaitStackDeleted();+ CfnStackWaits.awaitStackDeleted(STACK);describeVault(NAMED).statusCode(404);describeVault(unnamed).statusCode(404);@@ -128,24 +127,6 @@ class BackupVaultCfnIntegrationTest {}/** DeleteStack runs asynchronously; a successful delete removes the stack entirely. */- private static void awaitStackDeleted() throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", STACK)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + STACK + " was not deleted within the timeout");- }private static String outputValue(String xml, String key) {return XmlParser.extractPairs(xml, "Outputs", "OutputKey", "OutputValue").get(key);diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CfnCustomDomainEnsureHostIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CfnCustomDomainEnsureHostIntegrationTest.javaindex fd259b39e6..1fd33840f4 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CfnCustomDomainEnsureHostIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CfnCustomDomainEnsureHostIntegrationTest.java@@ -106,7 +106,7 @@ class CfnCustomDomainEnsureHostIntegrationTest {verifyNoMoreInteractions(certificateManager);cloudFormation("DeleteStack", Map.of());- awaitStackDeleted();+ CfnStackWaits.awaitStackDeleted(STACK);verifyNoMoreInteractions(certificateManager);}@@ -153,18 +153,4 @@ class CfnCustomDomainEnsureHostIntegrationTest {}fail("stack did not reach " + expected + " within the timeout: " + body);}-- private static void awaitStackDeleted() throws InterruptedException {- for (int i = 0; i < 200; i++) {- String body = describeStack();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + STACK + " was not deleted within the timeout");- }}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CfnStackWaits.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CfnStackWaits.javanew file mode 100644index 0000000000..71e49e77f7--- /dev/null+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CfnStackWaits.java@@ -0,0 +1,48 @@+package io.github.hectorvent.floci.services.cloudformation;++import io.restassured.response.Response;++import static io.restassured.RestAssured.given;+import static org.hamcrest.MatcherAssert.assertThat;+import static org.hamcrest.Matchers.containsString;+import static org.hamcrest.Matchers.not;+import static org.junit.jupiter.api.Assertions.fail;++/**+ * DeleteStack answers before the stack is gone. The deletion runs on an executor, so a test+ * that looks at the stack's resources right after the answer races it.+ */+final class CfnStackWaits {++ private CfnStackWaits() {+ }++ /**+ * Waits until DescribeStacks answers 400, which is how a missing stack is reported. Fails on+ * DELETE_FAILED or after ten seconds.+ */+ static void awaitStackDeleted(String stackName) {+ long deadline = System.currentTimeMillis() + 10_000;+ String body = "";+ while (System.currentTimeMillis() < deadline) {+ Response response = given()+ .contentType("application/x-www-form-urlencoded")+ .formParam("Action", "DescribeStacks")+ .formParam("StackName", stackName)+ .when()+ .post("/");+ body = response.asString();+ assertThat(body, not(containsString("<StackStatus>DELETE_FAILED</StackStatus>")));+ if (response.statusCode() == 400) {+ return;+ }+ try {+ Thread.sleep(50);+ } catch (InterruptedException e) {+ Thread.currentThread().interrupt();+ throw new AssertionError("Interrupted while waiting for stack " + stackName + " to be deleted", e);+ }+ }+ fail("Stack " + stackName + " was not deleted within ten seconds: " + body);+ }+}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationBatchIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationBatchIntegrationTest.javaindex 65259f3418..9a02d006e7 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationBatchIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationBatchIntegrationTest.java@@ -282,6 +282,7 @@ class CloudFormationBatchIntegrationTest {.post("/").then().statusCode(200);+ CfnStackWaits.awaitStackDeleted(stackName);// Both entities are gone. Under the legacy switch these describes still returned them.givenBatchJson("{\"jobQueues\":[\"%s\"]}".formatted(queueName))diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationCloudFrontPoliciesIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationCloudFrontPoliciesIntegrationTest.javaindex 645511b8e4..df60347e6d 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationCloudFrontPoliciesIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationCloudFrontPoliciesIntegrationTest.java@@ -266,39 +266,7 @@ class CloudFormationCloudFrontPoliciesIntegrationTest {.post("/").then().statusCode(200);- awaitStackDeleted(stackName);- }-- /**- * github.com/floci-io/floci/issues/3365: DeleteStack answers before the stack is actually- * gone - deletion runs on an executor (CloudFormationService.deleteStack) - so a DescribeStacks- * call made immediately after DeleteStack's 200 races that executor and intermittently still- * finds the stack. Polls until DescribeStacks reports the stack unknown, matching the- * awaitStackDeleted helper CloudFormationIntegrationTest already uses for the same race.- */- private static void awaitStackDeleted(String stackName) {- long deadline = System.currentTimeMillis() + 10_000;- while (System.currentTimeMillis() < deadline) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", stackName)- .when()- .post("/")- .then()- .extract().body().asString();- if (body.contains("Stack with id " + stackName + " does not exist")) {- return;- }- try {- Thread.sleep(200);- } catch (InterruptedException e) {- Thread.currentThread().interrupt();- throw new AssertionError("Interrupted while waiting for stack " + stackName + " to be deleted", e);- }- }- fail("Stack " + stackName + " did not become unknown to DescribeStacks within timeout");+ CfnStackWaits.awaitStackDeleted(stackName);}private static String describeStacks(String stackName) {diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationCloudWatchDashboardIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationCloudWatchDashboardIntegrationTest.javaindex c269a0f0b1..26dbff74d9 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationCloudWatchDashboardIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationCloudWatchDashboardIntegrationTest.java@@ -20,7 +20,6 @@ import static org.hamcrest.Matchers.equalTo;import static org.hamcrest.Matchers.not;import static org.junit.jupiter.api.Assertions.assertEquals;import static org.junit.jupiter.api.Assertions.assertTrue;-import static org.junit.jupiter.api.Assertions.fail;import static org.mockito.ArgumentMatchers.anyMap;import static org.mockito.ArgumentMatchers.anyString;@@ -110,7 +109,7 @@ class CloudFormationCloudWatchDashboardIntegrationTest {}@Test- void dashboardFollowsTheTemplateThroughCreateUpdateReplacementAndDelete() throws InterruptedException {+ void dashboardFollowsTheTemplateThroughCreateUpdateReplacementAndDelete() {String suffix = Long.toString(System.nanoTime(), 36);String stack = "cfn-dashboard-" + suffix;String name = "ops-" + suffix;@@ -150,14 +149,14 @@ class CloudFormationCloudWatchDashboardIntegrationTest {assertEvent(describeEvents(stack), "DELETE_COMPLETE", name);cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);getDashboard(renamed).then().statusCode(404).body("ErrorResponse.Error.Code", equalTo("ResourceNotFound"));}@Test- void anUnnamedDashboardKeepsItsGeneratedNameAcrossUpdates() throws InterruptedException {+ void anUnnamedDashboardKeepsItsGeneratedNameAcrossUpdates() {String suffix = Long.toString(System.nanoTime(), 36);String stack = "cfn-dashboard-unnamed-" + suffix;@@ -176,12 +175,12 @@ class CloudFormationCloudWatchDashboardIntegrationTest {.body("GetDashboardResponse.GetDashboardResult.DashboardBody", containsString("\"Throughput\""));cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);getDashboard(generated).then().statusCode(404);}@Test- void aFailedUpdateRollsTheReplacementBack() throws InterruptedException {+ void aFailedUpdateRollsTheReplacementBack() {String suffix = Long.toString(System.nanoTime(), 36);String stack = "cfn-dashboard-rb-" + suffix;String name = "ops-rb-" + suffix;@@ -200,12 +199,12 @@ class CloudFormationCloudWatchDashboardIntegrationTest {.body("ErrorResponse.Error.Code", equalTo("ResourceNotFound"));cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);}/** An in-place body and tag change is put back from the snapshot the update took. */@Test- void aFailedUpdateRestoresTheBodyAndTagsAnInPlaceUpdateChanged() throws InterruptedException {+ void aFailedUpdateRestoresTheBodyAndTagsAnInPlaceUpdateChanged() {String suffix = Long.toString(System.nanoTime(), 36);String stack = "cfn-dashboard-ip-" + suffix;String name = "ops-ip-" + suffix;@@ -225,7 +224,7 @@ class CloudFormationCloudWatchDashboardIntegrationTest {assertTags(arn, Map.of("team", "platform", "env", "dev"), Map.of());cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);}/**@@ -236,7 +235,7 @@ class CloudFormationCloudWatchDashboardIntegrationTest {*/@Testvoid anUpdateThatFailedOnItsTagsPutsTheDashboardBackAndTheStackRollsBackCleanly()- throws InterruptedException {+ {String suffix = Long.toString(System.nanoTime(), 36);String stack = "cfn-dashboard-tagfail-" + suffix;String name = "ops-tagfail-" + suffix;@@ -270,7 +269,7 @@ class CloudFormationCloudWatchDashboardIntegrationTest {}cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);}/**@@ -280,7 +279,7 @@ class CloudFormationCloudWatchDashboardIntegrationTest {* dashboard is intact.*/@Test- void aFailedRestoreLeavesTheStackInUpdateRollbackFailedNamingTheDashboard() throws InterruptedException {+ void aFailedRestoreLeavesTheStackInUpdateRollbackFailedNamingTheDashboard() {String suffix = Long.toString(System.nanoTime(), 36);String stack = "cfn-dashboard-restorefail-" + suffix;String name = "ops-restorefail-" + suffix;@@ -306,7 +305,7 @@ class CloudFormationCloudWatchDashboardIntegrationTest {}cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);// A resource left UPDATE_FAILED by a failed rollback is not one DeleteStack removes, so the// dashboard outlives the stack and this test removes it itself.dashboardsService.deleteDashboards(List.of(name), "us-east-1");@@ -314,7 +313,7 @@ class CloudFormationCloudWatchDashboardIntegrationTest {/** Dropping an explicit name is a replacement on AWS: the dashboard comes back under a generated name. */@Test- void droppingTheExplicitNameReplacesTheDashboard() throws InterruptedException {+ void droppingTheExplicitNameReplacesTheDashboard() {String suffix = Long.toString(System.nanoTime(), 36);String stack = "cfn-dashboard-drop-" + suffix;String name = "ops-drop-" + suffix;@@ -331,7 +330,7 @@ class CloudFormationCloudWatchDashboardIntegrationTest {.body("ErrorResponse.Error.Code", equalTo("ResourceNotFound"));cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);}private static Response getDashboard(String name) {@@ -408,25 +407,6 @@ class CloudFormationCloudWatchDashboardIntegrationTest {assertTrue(found, "no " + status + " event for " + physicalId + " in " + eventsXml);}- private static void awaitStackDeleted(String stack) throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", stack)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + stack + " was not deleted within the timeout");- }-private static String outputValue(String xml, String key) {return XmlParser.extractPairs(xml, "Outputs", "OutputKey", "OutputValue").get(key);}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationDeleteIdempotencyIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationDeleteIdempotencyIntegrationTest.javaindex 05d15fb1cf..43582efdd4 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationDeleteIdempotencyIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationDeleteIdempotencyIntegrationTest.java@@ -35,7 +35,7 @@ class CloudFormationDeleteIdempotencyIntegrationTest {}@Test- void deletingStackWhoseTableWasRemovedOutOfBandStillCompletes() throws InterruptedException {+ void deletingStackWhoseTableWasRemovedOutOfBandStillCompletes() {String suffix = Long.toString(System.nanoTime(), 36);String tableName = "idem-delete-table-" + suffix;String stackName = "idem-delete-stack-" + suffix;@@ -86,27 +86,7 @@ class CloudFormationDeleteIdempotencyIntegrationTest {// DeleteStack runs asynchronously: poll until the stack is gone (a successful delete removes it// entirely). A failed delete would instead leave it queryable as DELETE_FAILED — fail fast on that.- awaitStackDeleted(stackName);- }-- private void awaitStackDeleted(String stackName) throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", stackName)- .when().post("/").then().extract().asString();-- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed instead of treating the already-removed table as deleted: " + body);- }- Thread.sleep(50);- }- fail("stack " + stackName + " was not deleted within the timeout");+ CfnStackWaits.awaitStackDeleted(stackName);}private void assertStackStatus(String stackName, String status) {diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationDynamoDbGlobalTableIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationDynamoDbGlobalTableIntegrationTest.javaindex 599e22a90b..c2dade00c6 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationDynamoDbGlobalTableIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationDynamoDbGlobalTableIntegrationTest.java@@ -11,13 +11,11 @@ import java.time.Duration;import java.util.List;import static io.restassured.RestAssured.given;-import static org.awaitility.Awaitility.await;import static org.hamcrest.Matchers.containsString;import static org.hamcrest.Matchers.equalTo;import static org.junit.jupiter.api.Assertions.assertEquals;import static org.junit.jupiter.api.Assertions.assertFalse;import static org.junit.jupiter.api.Assertions.assertTrue;-import static org.junit.jupiter.api.Assertions.fail;/*** {@code AWS::DynamoDB::GlobalTable} through the per-service provisioner: {@code Ref} is the table@@ -103,7 +101,7 @@ class CloudFormationDynamoDbGlobalTableIntegrationTest {assertEquals(tableId, parameterValue("/gt-v2/" + suffix + "/table-id"));deleteStack(stackName);- awaitStackGone(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);given().contentType("application/x-amz-json-1.0")@@ -163,22 +161,4 @@ class CloudFormationDynamoDbGlobalTableIntegrationTest {.when().post("/").then().statusCode(200).extract().jsonPath().getString("Parameter.Value");}-- private void awaitStackGone(String stackName) {- await()- .atMost(STACK_DELETE_TIMEOUT)- .pollInterval(STACK_DELETE_POLL_INTERVAL)- .untilAsserted(() -> {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", stackName)- .when().post("/").then().extract().asString();- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- assertTrue(body.contains("does not exist"), "stack still exists: " + body);- });- }}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationDynamoDbReplicaIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationDynamoDbReplicaIntegrationTest.javaindex a9322c42a3..70c9757fc4 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationDynamoDbReplicaIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationDynamoDbReplicaIntegrationTest.java@@ -13,10 +13,8 @@ import static io.restassured.RestAssured.given;import static org.hamcrest.Matchers.containsString;import static org.hamcrest.Matchers.equalTo;import static org.hamcrest.Matchers.not;-import static org.awaitility.Awaitility.await;import static org.junit.jupiter.api.Assertions.assertFalse;import static org.junit.jupiter.api.Assertions.assertTrue;-import static org.junit.jupiter.api.Assertions.fail;/*** Verifies global-table v2 replica support: the DynamoDB API path (UpdateTable ReplicaUpdates +@@ -306,7 +304,7 @@ class CloudFormationDynamoDbReplicaIntegrationTest {// Deleting the stack must detach the replica from the surviving table (async delete).deleteStack(stackName);- awaitStackGone(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);// The table still exists, but its replica is gone.given()@@ -318,22 +316,4 @@ class CloudFormationDynamoDbReplicaIntegrationTest {.body(containsString("\"TableName\":\"" + tableName + "\"")).body(not(containsString(REPLICA_REGION)));}-- private void awaitStackGone(String stackName) {- await()- .atMost(STACK_DELETE_TIMEOUT)- .pollInterval(STACK_DELETE_POLL_INTERVAL)- .untilAsserted(() -> {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", stackName)- .when().post("/").then().extract().asString();- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- assertTrue(body.contains("does not exist"), "stack still exists: " + body);- });- }}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationEc2NetworkingIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationEc2NetworkingIntegrationTest.javaindex 96262fae6f..8978db44c6 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationEc2NetworkingIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationEc2NetworkingIntegrationTest.java@@ -14,7 +14,6 @@ import static org.hamcrest.Matchers.containsString;import static org.junit.jupiter.api.Assertions.assertEquals;import static org.junit.jupiter.api.Assertions.assertFalse;import static org.junit.jupiter.api.Assertions.assertTrue;-import static org.junit.jupiter.api.Assertions.fail;/*** A public/private networking stack the way CDK lays one out: internet gateway and attachment,@@ -82,7 +81,7 @@ class CloudFormationEc2NetworkingIntegrationTest {"the subnet's prior MapPublicIpOnLaunch must be back");cloudFormation(ROLLBACK_STACK, "DeleteStack", null);- awaitStackDeleted(ROLLBACK_STACK);+ CfnStackWaits.awaitStackDeleted(ROLLBACK_STACK);ec2("DeleteVpc", Map.of("VpcId", vpcId));}@@ -203,7 +202,7 @@ class CloudFormationEc2NetworkingIntegrationTest {out = replaced;cloudFormation("DeleteStack", null);- awaitStackDeleted();+ CfnStackWaits.awaitStackDeleted(STACK);for (String id : List.of(out.get("SubnetId"), out.get("PublicRtId"), out.get("PrivateRtId"),out.get("AssocId"), out.get("NatId"), out.get("EipAllocationId"), out.get("IgwId"))) {@@ -252,29 +251,6 @@ class CloudFormationEc2NetworkingIntegrationTest {.extract().asString();}- private static void awaitStackDeleted() throws InterruptedException {- awaitStackDeleted(STACK);- }-- private static void awaitStackDeleted(String stack) throws InterruptedException {- for (int i = 0; i < 200; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", stack)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + stack + " was not deleted within the timeout");- }-private static String ec2(String action) {return ec2(action, Map.of());}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationEventBusIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationEventBusIntegrationTest.javaindex ea05bfe6b5..839f451cca 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationEventBusIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationEventBusIntegrationTest.java@@ -250,7 +250,7 @@ class CloudFormationEventBusIntegrationTest {}@Test- void customEventBusIsRegisteredSoRuleReferencingItSucceeds() throws InterruptedException {+ void customEventBusIsRegisteredSoRuleReferencingItSucceeds() {String suffix = Long.toString(System.nanoTime(), 36);String busName = "domain-events-" + suffix;String stackName = "eventbus-stack-" + suffix;@@ -288,7 +288,7 @@ class CloudFormationEventBusIntegrationTest {// Deleting the stack must remove the bus (and its rule) from EventBridge, not leak it: the// rule lives on the custom bus, so its cleanup must target that bus or the bus delete fails.deleteStack(stackName);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);given().contentType("application/x-amz-json-1.1").header("Authorization", EVENTS_AUTH)@@ -302,7 +302,7 @@ class CloudFormationEventBusIntegrationTest {}@Test- void getAttRuleNameResolvesToTheRuleName() throws InterruptedException {+ void getAttRuleNameResolvesToTheRuleName() {String suffix = Long.toString(System.nanoTime(), 36);String ruleName = "cfn-rulename-" + suffix;String stackName = "rulename-stack-" + suffix;@@ -350,32 +350,10 @@ class CloudFormationEventBusIntegrationTest {assertEquals(outputs.get("UnnamedRef"), outputs.get("UnnamedRuleName"));} finally {deleteStack(stackName);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);}}- private void awaitStackDeleted(String stackName) throws InterruptedException {- String lastBody = null;- for (int i = 0; i < 100; i++) {- lastBody = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", stackName)- .when().post("/").then().extract().asString();- if (lastBody.contains("does not exist")- || lastBody.contains("<StackStatus>DELETE_COMPLETE</StackStatus>")) {- return;- }- if (lastBody.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- throw new AssertionError("Stack " + stackName + " deletion failed: " + lastBody);- }- Thread.sleep(50);- }- throw new AssertionError(- "Timed out waiting for stack " + stackName + " to be deleted. Last response: " + lastBody);- }-private void awaitStackStatus(String stackName, String expectedStatus) throws InterruptedException {String lastBody = null;for (int i = 0; i < 100; i++) {@@ -395,7 +373,7 @@ class CloudFormationEventBusIntegrationTest {}@Test- void eventBusWithExistingNameInAnotherStackFailsWithoutAdoption() throws InterruptedException {+ void eventBusWithExistingNameInAnotherStackFailsWithoutAdoption() {String suffix = Long.toString(System.nanoTime(), 36);String busName = "collision-bus-" + suffix;String stackA = "eventbus-collision-a-" + suffix;@@ -417,11 +395,11 @@ class CloudFormationEventBusIntegrationTest {}deleteStack(stackB);- awaitStackDeleted(stackB);+ CfnStackWaits.awaitStackDeleted(stackB);callEventBridge("AWSEvents.DescribeEventBus", "{\"Name\":\"" + busName + "\"}", 200);deleteStack(stackA);- awaitStackDeleted(stackA);+ CfnStackWaits.awaitStackDeleted(stackA);given().contentType("application/x-amz-json-1.1")@@ -437,7 +415,7 @@ class CloudFormationEventBusIntegrationTest {@Testvoid sameStackNoOpUpdateReusesOwnedBusAndMutableDescriptionIsRejected()- throws InterruptedException {+ {String suffix = Long.toString(System.nanoTime(), 36);String busName = "update-bus-" + suffix;String stackName = "eventbus-update-" + suffix;@@ -469,7 +447,7 @@ class CloudFormationEventBusIntegrationTest {}deleteStack(stackName);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);given().contentType("application/x-amz-json-1.1")@@ -484,7 +462,7 @@ class CloudFormationEventBusIntegrationTest {}@Test- void explicitBusNameChangeFailsWithoutReplacingOwnedBus() throws InterruptedException {+ void explicitBusNameChangeFailsWithoutReplacingOwnedBus() {String suffix = Long.toString(System.nanoTime(), 36);String originalName = "original-bus-" + suffix;String replacementName = "replacement-bus-" + suffix;@@ -508,7 +486,7 @@ class CloudFormationEventBusIntegrationTest {callEventBridge("AWSEvents.DescribeEventBus", "{\"Name\":\"" + originalName + "\"}", 200);deleteStack(stackName);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);callEventBridge("AWSEvents.DescribeEventBus", "{\"Name\":\"" + originalName + "\"}", 400);}@@ -591,7 +569,7 @@ class CloudFormationEventBusIntegrationTest {}@Test- void mutableEventBusTagUpdateRollsBackWithoutChangingTags() throws InterruptedException {+ void mutableEventBusTagUpdateRollsBackWithoutChangingTags() {String suffix = Long.toString(System.nanoTime(), 36);String busName = "tagged-bus-" + suffix;String stackName = "eventbus-tags-" + suffix;@@ -630,11 +608,11 @@ class CloudFormationEventBusIntegrationTest {}deleteStack(stackName);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);}@Test- void mutableEventBusPolicyUpdateRollsBackWithoutChangingPolicy() throws InterruptedException {+ void mutableEventBusPolicyUpdateRollsBackWithoutChangingPolicy() {String suffix = Long.toString(System.nanoTime(), 36);String busName = "policy-bus-" + suffix;String stackName = "eventbus-policy-" + suffix;@@ -666,7 +644,7 @@ class CloudFormationEventBusIntegrationTest {}deleteStack(stackName);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);}@Test@@ -766,7 +744,7 @@ class CloudFormationEventBusIntegrationTest {callEventBridge("AWSEvents.DeleteEventBus", "{\"Name\":\"" + busName + "\"}", 200);deleteStack(stackName);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);}@Test@@ -789,12 +767,12 @@ class CloudFormationEventBusIntegrationTest {callEventBridge("AWSEvents.DeleteRule","{\"Name\":\"" + ruleName + "\",\"EventBusName\":\"" + busName + "\"}", 200);deleteStack(stackName);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);callEventBridge("AWSEvents.DescribeEventBus", "{\"Name\":\"" + busName + "\"}", 400);}@Test- void deletingStackTreatsAlreadyAbsentBusAsSuccess() throws InterruptedException {+ void deletingStackTreatsAlreadyAbsentBusAsSuccess() {String suffix = Long.toString(System.nanoTime(), 36);String busName = "already-gone-bus-" + suffix;String stackName = "eventbus-already-gone-" + suffix;@@ -804,7 +782,7 @@ class CloudFormationEventBusIntegrationTest {callEventBridge("AWSEvents.DeleteEventBus", "{\"Name\":\"" + busName + "\"}", 200);deleteStack(stackName);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);}@Testdiff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationIamRoleInlinePoliciesIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationIamRoleInlinePoliciesIntegrationTest.javaindex 50dd32feac..21c5594b87 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationIamRoleInlinePoliciesIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationIamRoleInlinePoliciesIntegrationTest.java@@ -138,6 +138,7 @@ class CloudFormationIamRoleInlinePoliciesIntegrationTest {.post("/").then().statusCode(200);+ CfnStackWaits.awaitStackDeleted(stackName);given().contentType("application/x-www-form-urlencoded")diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLambdaAddressingIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLambdaAddressingIntegrationTest.javaindex abae70a23f..bbe9f20005 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLambdaAddressingIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLambdaAddressingIntegrationTest.java@@ -6,7 +6,6 @@ import org.junit.jupiter.api.Test;import static io.restassured.RestAssured.given;import static org.hamcrest.Matchers.containsString;import static org.junit.jupiter.api.Assertions.assertEquals;-import static org.junit.jupiter.api.Assertions.assertFalse;/*** End-to-end check that CloudFormation provisions the Lambda addressing@@ -111,7 +110,7 @@ class CloudFormationLambdaAddressingIntegrationTest {}@Test- void updateKeepsVersionAppliesRoutingAndDeleteCleansUp() throws InterruptedException {+ void updateKeepsVersionAppliesRoutingAndDeleteCleansUp() {String suffix = Long.toString(System.nanoTime(), 36);String stackName = "cfn-lambda-addr-upd-" + suffix;String fnName = "addr-upd-fn-" + suffix;@@ -256,25 +255,6 @@ class CloudFormationLambdaAddressingIntegrationTest {// A permission, version or alias whose delete fails leaves the stack in DELETE_FAILED// and it never drops out of DescribeStacks — so waiting for the stack to disappear// exercises all three delete paths.- awaitStackGone(stackName);- }-- private static void awaitStackGone(String stackName) throws InterruptedException {- for (int i = 0; i < 200; i++) {- var response = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", stackName)- .when().post("/").then().extract();- if (response.statusCode() != 200) {- return;- }- String body = response.asString();- assertFalse(body.contains("DELETE_FAILED"),- "stack delete failed instead of completing: " + body);- Thread.sleep(50);- }- throw new AssertionError("Timed out waiting for stack " + stackName + " to be deleted");+ CfnStackWaits.awaitStackDeleted(stackName);}}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLambdaEventInvokeConfigIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLambdaEventInvokeConfigIntegrationTest.javaindex cd723f2e25..7989521ea2 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLambdaEventInvokeConfigIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLambdaEventInvokeConfigIntegrationTest.java@@ -107,7 +107,7 @@ class CloudFormationLambdaEventInvokeConfigIntegrationTest {}@Test- void configurationFollowsTheTemplateThroughCreateUpdateReplacementAndDelete() throws InterruptedException {+ void configurationFollowsTheTemplateThroughCreateUpdateReplacementAndDelete() {String suffix = Long.toString(System.nanoTime(), 36);String functionStack = "cfn-event-invoke-fn-" + suffix;String stack = "cfn-event-invoke-" + suffix;@@ -148,18 +148,18 @@ class CloudFormationLambdaEventInvokeConfigIntegrationTest {assertEvent(describeEvents(stack), "DELETE_COMPLETE", fn + "|$LATEST");cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);getConfig(fn, version).then().statusCode(404).body("__type", equalTo("ResourceNotFoundException"));given().when().get("/2015-03-31/functions/" + fn).then().statusCode(200);cloudFormation(functionStack, "DeleteStack", null, Map.of());- awaitStackDeleted(functionStack);+ CfnStackWaits.awaitStackDeleted(functionStack);}@Test- void aFailedUpdateRollsTheReplacementBack() throws InterruptedException {+ void aFailedUpdateRollsTheReplacementBack() {String suffix = Long.toString(System.nanoTime(), 36);String functionStack = "cfn-event-invoke-rb-fn-" + suffix;String stack = "cfn-event-invoke-rb-" + suffix;@@ -182,14 +182,14 @@ class CloudFormationLambdaEventInvokeConfigIntegrationTest {.body("__type", equalTo("ResourceNotFoundException"));cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);cloudFormation(functionStack, "DeleteStack", null, Map.of());- awaitStackDeleted(functionStack);+ CfnStackWaits.awaitStackDeleted(functionStack);}/** An in-place settings change is put back from the snapshot the update took. */@Test- void aFailedUpdateRestoresTheSettingsAnInPlaceUpdateChanged() throws InterruptedException {+ void aFailedUpdateRestoresTheSettingsAnInPlaceUpdateChanged() {String suffix = Long.toString(System.nanoTime(), 36);String functionStack = "cfn-event-invoke-ip-fn-" + suffix;String stack = "cfn-event-invoke-ip-" + suffix;@@ -210,9 +210,9 @@ class CloudFormationLambdaEventInvokeConfigIntegrationTest {.body("DestinationConfig.OnFailure.Destination", equalTo(DLQ_ARN));cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);cloudFormation(functionStack, "DeleteStack", null, Map.of());- awaitStackDeleted(functionStack);+ CfnStackWaits.awaitStackDeleted(functionStack);}@Test@@ -231,9 +231,9 @@ class CloudFormationLambdaEventInvokeConfigIntegrationTest {getConfig(fn, "$LATEST").then().statusCode(404);cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);cloudFormation(functionStack, "DeleteStack", null, Map.of());- awaitStackDeleted(functionStack);+ CfnStackWaits.awaitStackDeleted(functionStack);}/** Creates the function stack and returns the number of the version it published. */@@ -312,25 +312,6 @@ class CloudFormationLambdaEventInvokeConfigIntegrationTest {return fail("stack " + stack + " did not reach " + expectedStatus + " within the timeout");}- private static void awaitStackDeleted(String stack) throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", stack)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + stack + " was not deleted within the timeout");- }-private static String outputValue(String xml, String key) {return XmlParser.extractPairs(xml, "Outputs", "OutputKey", "OutputValue").get(key);}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLaunchTemplateIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLaunchTemplateIntegrationTest.javaindex 515e475f3c..80e1efa3af 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLaunchTemplateIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLaunchTemplateIntegrationTest.java@@ -165,6 +165,7 @@ class CloudFormationLaunchTemplateIntegrationTest {.post("/").then().statusCode(200);+ CfnStackWaits.awaitStackDeleted(stackName);given().contentType("application/x-www-form-urlencoded")diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLogsMetricFilterIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLogsMetricFilterIntegrationTest.javaindex f45bb8891f..23558e7a0e 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLogsMetricFilterIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLogsMetricFilterIntegrationTest.java@@ -200,12 +200,12 @@ class CloudFormationLogsMetricFilterIntegrationTest {"Requested update requires the replacement of the existing resource; deleting existing resource, then creating a new one."));cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);describeFilters(group).then().statusCode(200).body("metricFilters", hasSize(0));cloudFormation(groupStack, "DeleteStack", null, Map.of());- awaitStackDeleted(groupStack);+ CfnStackWaits.awaitStackDeleted(groupStack);}@Test@@ -232,9 +232,9 @@ class CloudFormationLogsMetricFilterIntegrationTest {describeFilters(group).then().body("metricFilters[0].filterPattern", equalTo("{ $.latency > 10 }"));cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);cloudFormation(groupStack, "DeleteStack", null, Map.of());- awaitStackDeleted(groupStack);+ CfnStackWaits.awaitStackDeleted(groupStack);}@Test@@ -259,9 +259,9 @@ class CloudFormationLogsMetricFilterIntegrationTest {assertPublishedValue(group, "Stack/" + suffix, "ERROR", 1);cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);cloudFormation(groupStack, "DeleteStack", null, Map.of());- awaitStackDeleted(groupStack);+ CfnStackWaits.awaitStackDeleted(groupStack);}@Test@@ -290,9 +290,9 @@ class CloudFormationLogsMetricFilterIntegrationTest {"fatal:CREATE_IN_PROGRESS", "errors:CREATE_COMPLETE", "errors:UPDATE_COMPLETE"));cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);cloudFormation(groupStack, "DeleteStack", null, Map.of());- awaitStackDeleted(groupStack);+ CfnStackWaits.awaitStackDeleted(groupStack);}@Test@@ -325,9 +325,9 @@ class CloudFormationLogsMetricFilterIntegrationTest {assertTrue(template.contains("MetricValue"), template);assertTrue(template.contains(""2"") || template.contains("\"2\""), template);cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);cloudFormation(groupStack, "DeleteStack", null, Map.of());- awaitStackDeleted(groupStack);+ CfnStackWaits.awaitStackDeleted(groupStack);}@Test@@ -355,9 +355,9 @@ class CloudFormationLogsMetricFilterIntegrationTest {describeFilters(group).then().body("metricFilters[0].applyOnTransformedLogs", equalTo(false)).body("metricFilters[0].emitSystemFieldDimensions", hasSize(2));cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);cloudFormation(groupStack, "DeleteStack", null, Map.of());- awaitStackDeleted(groupStack);+ CfnStackWaits.awaitStackDeleted(groupStack);}@ParameterizedTest@@ -649,9 +649,9 @@ class CloudFormationLogsMetricFilterIntegrationTest {String events = awaitStackStatus(stack, "ROLLBACK_COMPLETE");assertTrue(events.contains("Invalid filter pattern"), "the status reason carries the parse error: " + events);cloudFormation(stack, "DeleteStack", null, Map.of());- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);cloudFormation(groupStack, "DeleteStack", null, Map.of());- awaitStackDeleted(groupStack);+ CfnStackWaits.awaitStackDeleted(groupStack);}private static void createGroupStack(String stack, String group) {@@ -733,25 +733,6 @@ class CloudFormationLogsMetricFilterIntegrationTest {return fail("stack " + stack + " did not reach " + expectedStatus + " within the timeout");}- private static void awaitStackDeleted(String stack) throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", stack)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + stack + " was not deleted within the timeout");- }-private static String outputValue(String xml, String key) {return XmlParser.extractPairs(xml, "Outputs", "OutputKey", "OutputValue").get(key);}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationPipesCleanupIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationPipesCleanupIntegrationTest.javaindex 9c98481b4e..a41877650a 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationPipesCleanupIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationPipesCleanupIntegrationTest.java@@ -592,6 +592,7 @@ class CloudFormationPipesCleanupIntegrationTest {.post("/").then().statusCode(200);+ CfnStackWaits.awaitStackDeleted(stackName);}private static void assertPipe(String pipeName) {diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationRdsDynamicReferenceIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationRdsDynamicReferenceIntegrationTest.javaindex 96dbf76b19..a43dcc3ccb 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationRdsDynamicReferenceIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationRdsDynamicReferenceIntegrationTest.java@@ -9,7 +9,6 @@ import org.junit.jupiter.api.Test;import static io.restassured.RestAssured.given;import static org.junit.jupiter.api.Assertions.assertTrue;-import static org.junit.jupiter.api.Assertions.fail;/*** RDS master credentials are the only properties where {@code {{resolve:ssm-secure:...}}} is@@ -62,7 +61,7 @@ class CloudFormationRdsDynamicReferenceIntegrationTest {} finally {if (stackCreated) {deleteStack(stackName);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);}deleteParameter(parameterName);}@@ -92,7 +91,7 @@ class CloudFormationRdsDynamicReferenceIntegrationTest {} finally {if (stackCreated) {deleteStack(stackName);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);}deleteParameter(parameterName);}@@ -169,23 +168,4 @@ class CloudFormationRdsDynamicReferenceIntegrationTest {.formParam("StackName", stackName).when().post("/").then().statusCode(200);}-- private static void awaitStackDeleted(String stackName) throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", stackName)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + stackName + " was not deleted within the timeout");- }}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationResourceConditionIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationResourceConditionIntegrationTest.javaindex 182034caae..d5c0c56f03 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationResourceConditionIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationResourceConditionIntegrationTest.java@@ -5,14 +5,10 @@ import io.quarkus.test.junit.QuarkusTest;import org.junit.jupiter.api.BeforeAll;import org.junit.jupiter.api.Test;-import java.time.Duration;-import static io.restassured.RestAssured.given;-import static org.awaitility.Awaitility.await;import static org.hamcrest.Matchers.containsString;import static org.hamcrest.Matchers.equalTo;import static org.hamcrest.Matchers.not;-import static org.junit.jupiter.api.Assertions.assertTrue;import static org.junit.jupiter.api.Assertions.fail;@QuarkusTest@@ -273,7 +269,7 @@ class CloudFormationResourceConditionIntegrationTest {} finally {given().header("Host", bucketName + ".localhost").delete("/object.txt");deleteStack(stackName);- awaitStackGone(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);}}@@ -918,7 +914,7 @@ class CloudFormationResourceConditionIntegrationTest {// and reclaim the backing bucket rather than orphaning it.given().header("Host", bucketName + ".localhost").delete("/object.txt").then().statusCode(204);deleteStack(stackName);- awaitStackGone(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);given().header("Host", bucketName + ".localhost").when().get("/").then().statusCode(404);} finally {given().header("Host", bucketName + ".localhost").delete("/object.txt");@@ -1053,7 +1049,7 @@ class CloudFormationResourceConditionIntegrationTest {// Clear the blocker, then DeleteStack retries the DELETE_FAILED resourcegiven().header("Host", bucketName + ".localhost").delete("/object.txt").then().statusCode(204);deleteStack(stackName);- awaitStackGone(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);given().header("Host", bucketName + ".localhost").when().get("/").then().statusCode(404);} finally {given().header("Host", bucketName + ".localhost").delete("/object.txt");@@ -1098,21 +1094,4 @@ class CloudFormationResourceConditionIntegrationTest {.then().statusCode(200);}-- private static void awaitStackGone(String stackName) {- await()- .atMost(Duration.ofSeconds(30))- .pollInterval(Duration.ofMillis(50))- .untilAsserted(() -> {- String body = given()- .contentType("application/x-www-form-urlencoded")- .formParam("Action", "DescribeStacks")- .formParam("StackName", stackName)- .when().post("/").then().extract().asString();- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- assertTrue(body.contains("does not exist"), "stack still exists: " + body);- });- }}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationRollbackCompleteUpdateIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationRollbackCompleteUpdateIntegrationTest.javaindex 5ec723fa95..e8e329fd0b 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationRollbackCompleteUpdateIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationRollbackCompleteUpdateIntegrationTest.java@@ -227,5 +227,6 @@ class CloudFormationRollbackCompleteUpdateIntegrationTest {.post("/").then().statusCode(200);+ CfnStackWaits.awaitStackDeleted(stackName);}}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationRoute53RecordSetIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationRoute53RecordSetIntegrationTest.javaindex 55706e6a19..2264c498a4 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationRoute53RecordSetIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationRoute53RecordSetIntegrationTest.java@@ -8,11 +8,9 @@ import org.junit.jupiter.api.Test;import java.time.Duration;import static io.restassured.RestAssured.given;-import static org.awaitility.Awaitility.await;import static org.hamcrest.Matchers.containsString;import static org.junit.jupiter.api.Assertions.assertEquals;import static org.junit.jupiter.api.Assertions.assertTrue;-import static org.junit.jupiter.api.Assertions.fail;/*** {@code AWS::Route53::RecordSet} through the per-service provisioner: {@code Ref} is the record@@ -84,7 +82,7 @@ class CloudFormationRoute53RecordSetIntegrationTest {assertTrue(records.contains("10.0.0.1"), "record value not written to zone: " + records);} finally {deleteStack(stackName);- awaitStackGone(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);}}@@ -134,22 +132,4 @@ class CloudFormationRoute53RecordSetIntegrationTest {.when().post("/").then().statusCode(200).extract().jsonPath().getString("Parameter.Value");}-- private void awaitStackGone(String stackName) {- await()- .atMost(STACK_DELETE_TIMEOUT)- .pollInterval(STACK_DELETE_POLL_INTERVAL)- .untilAsserted(() -> {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", stackName)- .when().post("/").then().extract().asString();- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- assertTrue(body.contains("does not exist"), "stack still exists: " + body);- });- }}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationSecretTargetAttachmentIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationSecretTargetAttachmentIntegrationTest.javaindex 8a8ff92de0..7a9ae7e8cf 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationSecretTargetAttachmentIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationSecretTargetAttachmentIntegrationTest.java@@ -14,7 +14,6 @@ import static io.restassured.RestAssured.given;import static org.junit.jupiter.api.Assertions.assertEquals;import static org.junit.jupiter.api.Assertions.assertFalse;import static org.junit.jupiter.api.Assertions.assertTrue;-import static org.junit.jupiter.api.Assertions.fail;/** End-to-end coverage for attaching and detaching an external secret from an RDS target. */@QuarkusTest@@ -93,7 +92,7 @@ class CloudFormationSecretTargetAttachmentIntegrationTest {assertEquals(databaseId, attached.path("dbInstanceIdentifier").asText());deleteStack(stackName);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);stackCreated = false;given()@@ -114,7 +113,7 @@ class CloudFormationSecretTargetAttachmentIntegrationTest {} finally {if (stackCreated) {deleteStack(stackName);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);}forceDeleteSecret(secretName);}@@ -163,7 +162,7 @@ class CloudFormationSecretTargetAttachmentIntegrationTest {putBinarySecret(secretName, "AQID");deleteStack(stackName);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);stackCreated = false;JsonNode value = getSecretValue(secretName);@@ -172,7 +171,7 @@ class CloudFormationSecretTargetAttachmentIntegrationTest {} finally {if (stackCreated) {deleteStack(stackName);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);}forceDeleteSecret(secretName);}@@ -242,7 +241,7 @@ class CloudFormationSecretTargetAttachmentIntegrationTest {} finally {if (stackCreated) {deleteStack(stackName);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);}forceDeleteSecret(secretName);}@@ -310,7 +309,7 @@ class CloudFormationSecretTargetAttachmentIntegrationTest {} finally {if (stackCreated) {deleteStack(stackName);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);}forceDeleteSecret(secretName);}@@ -394,23 +393,4 @@ class CloudFormationSecretTargetAttachmentIntegrationTest {.formParam("StackName", stackName).when().post("/").then().statusCode(200);}-- private static void awaitStackDeleted(String stackName) throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", stackName)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + stackName + " was not deleted within the timeout");- }}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationVpcEndpointIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationVpcEndpointIntegrationTest.javaindex 62f88fcae8..d2df24a6f1 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationVpcEndpointIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationVpcEndpointIntegrationTest.java@@ -84,6 +84,7 @@ class CloudFormationVpcEndpointIntegrationTest {.post("/").then().statusCode(200);+ CfnStackWaits.awaitStackDeleted(stackName);String endpointsAfterDelete = given().formParam("Action", "DescribeVpcEndpoints")diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CodePipelineCfnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CodePipelineCfnIntegrationTest.javaindex a8e82d808b..a7fc9ba45c 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CodePipelineCfnIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CodePipelineCfnIntegrationTest.java@@ -105,6 +105,7 @@ class CodePipelineCfnIntegrationTest {.formParam("Action", "DeleteStack").formParam("StackName", STACK).when().post("/").then().statusCode(200);+ CfnStackWaits.awaitStackDeleted(STACK);given().header("X-Amz-Target", "CodePipeline_20150709.GetPipeline")diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CognitoCfnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CognitoCfnIntegrationTest.javaindex 50c2475f96..a757c784fc 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CognitoCfnIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CognitoCfnIntegrationTest.java@@ -210,7 +210,7 @@ class CognitoCfnIntegrationTest {assertEquals(renewedCertificateArn, description.path("CustomDomainConfig").path("CertificateArn").asText());cloudFormation(CUSTOM_STACK, "DeleteStack", null);- awaitStackDeleted(CUSTOM_STACK);+ CfnStackWaits.awaitStackDeleted(CUSTOM_STACK);assertDomainIsGone(REPLACEMENT_DOMAIN);assertCertificateIsGone(renewedCertificateArn);@@ -234,7 +234,7 @@ class CognitoCfnIntegrationTest {assertFalse(description.has("CustomDomainConfig"));cloudFormation(PREFIX_STACK, "DeleteStack", null);- awaitStackDeleted(PREFIX_STACK);+ CfnStackWaits.awaitStackDeleted(PREFIX_STACK);assertDomainIsGone(PREFIX_DOMAIN);}@@ -282,7 +282,7 @@ class CognitoCfnIntegrationTest {assertClientInPool(livePool, "orphan-web", "orphan-web");cloudFormation(stack, "DeleteStack", null);- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);cognitoAction("DeleteUserPool", "{\"UserPoolId\": \"" + livePool + "\"}").then().statusCode(200);}@@ -316,11 +316,11 @@ class CognitoCfnIntegrationTest {describeStacks(OVERRIDE_STACK + "-2", "ROLLBACK_COMPLETE");assertClientInPool(poolId, "override-web", "override-web");cloudFormation(OVERRIDE_STACK + "-2", "DeleteStack", null);- awaitStackDeleted(OVERRIDE_STACK + "-2");+ CfnStackWaits.awaitStackDeleted(OVERRIDE_STACK + "-2");assertClientInPool(poolId, "override-web", "override-web");cloudFormation(OVERRIDE_STACK, "DeleteStack", null);- awaitStackDeleted(OVERRIDE_STACK);+ CfnStackWaits.awaitStackDeleted(OVERRIDE_STACK);assertClientIsGone(poolId, "override-web");cognitoAction("DeleteUserPool", "{\"UserPoolId\": \"" + poolId + "\"}").then().statusCode(200);}@@ -380,7 +380,7 @@ class CognitoCfnIntegrationTest {.body("UserPoolClient.ClientSecret", nullValue());cloudFormation(CLIENT_STACK, "DeleteStack", null);- awaitStackDeleted(CLIENT_STACK);+ CfnStackWaits.awaitStackDeleted(CLIENT_STACK);assertClientIsGone(poolB, withoutSecret);cognitoAction("DescribeUserPool", "{\"UserPoolId\": \"" + poolB + "\"}")@@ -433,7 +433,7 @@ class CognitoCfnIntegrationTest {.body("UserPool.DeletionProtection", equalTo("INACTIVE"));cloudFormation(stack, "DeleteStack", null);- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);cognitoAction("DescribeUserPool", "{\"UserPoolId\": \"" + poolId + "\"}").then().body("__type", equalTo("ResourceNotFoundException"));@@ -505,24 +505,6 @@ class CognitoCfnIntegrationTest {}/** DeleteStack runs asynchronously; a successful delete removes the stack entirely. */- private static void awaitStackDeleted(String stack) throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", stack)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + stack + " was not deleted within the timeout");- }private static JsonNode describeDomain(String domain) throws Exception {return cognitoJson("DescribeUserPoolDomain", "{\"Domain\": \"" + domain + "\"}").path("DomainDescription");diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/IotCfnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/IotCfnIntegrationTest.javaindex 169f0ebf42..6eebc31105 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/IotCfnIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/IotCfnIntegrationTest.java@@ -13,7 +13,6 @@ import static org.hamcrest.Matchers.contains;import static org.hamcrest.Matchers.containsString;import static org.hamcrest.Matchers.equalTo;import static org.junit.jupiter.api.Assertions.assertEquals;-import static org.junit.jupiter.api.Assertions.fail;/*** Provisions an {@code AWS::IoT::Thing}, an {@code AWS::IoT::Policy} and an@@ -208,7 +207,7 @@ class IotCfnIntegrationTest {.body("policyDocument", containsString("iot:UpdateThingShadow"));cloudFormation("DeleteStack", null);- awaitStackDeleted();+ CfnStackWaits.awaitStackDeleted(STACK);given().when().get("/things/" + THING).then().statusCode(404);given().when().get("/policies/" + POLICY).then().statusCode(404);@@ -261,24 +260,6 @@ class IotCfnIntegrationTest {}/** DeleteStack runs asynchronously; a successful delete removes the stack entirely. */- private static void awaitStackDeleted() throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", STACK)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + STACK + " was not deleted within the timeout");- }private static String outputValue(String xml, String key) {return XmlParser.extractPairs(xml, "Outputs", "OutputKey", "OutputValue").get(key);diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/IotDomainConfigurationCfnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/IotDomainConfigurationCfnIntegrationTest.javaindex 336a5eb933..930e0c01f8 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/IotDomainConfigurationCfnIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/IotDomainConfigurationCfnIntegrationTest.java@@ -13,7 +13,6 @@ import static org.hamcrest.Matchers.equalTo;import static org.hamcrest.Matchers.hasItem;import static org.junit.jupiter.api.Assertions.assertEquals;import static org.junit.jupiter.api.Assertions.assertTrue;-import static org.junit.jupiter.api.Assertions.fail;/*** Provisions an {@code AWS::IoT::DomainConfiguration} through a CloudFormation stack and asserts@@ -103,7 +102,7 @@ class IotDomainConfigurationCfnIntegrationTest {.body("domainConfigurationStatus", equalTo("DISABLED"));cloudFormation("DeleteStack", null);- awaitStackDeleted();+ CfnStackWaits.awaitStackDeleted(STACK);given().when()@@ -137,24 +136,6 @@ class IotDomainConfigurationCfnIntegrationTest {}/** DeleteStack runs asynchronously; a successful delete removes the stack entirely. */- private static void awaitStackDeleted() throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", STACK)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + STACK + " was not deleted within the timeout");- }private static String outputValue(String xml, String key) {return XmlParser.extractPairs(xml, "Outputs", "OutputKey", "OutputValue").get(key);diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/RedshiftClusterCfnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/RedshiftClusterCfnIntegrationTest.javaindex 79ea2ad0c5..6fabacf64c 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/RedshiftClusterCfnIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/RedshiftClusterCfnIntegrationTest.java@@ -28,7 +28,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;import static org.junit.jupiter.api.Assertions.assertFalse;import static org.junit.jupiter.api.Assertions.assertNotNull;import static org.junit.jupiter.api.Assertions.assertTrue;-import static org.junit.jupiter.api.Assertions.fail;/*** End-to-end integration test provisioning AWS::Redshift::Cluster,@@ -68,7 +67,7 @@ class RedshiftClusterCfnIntegrationTest {for (String stack : stacksToCleanup) {try {cloudFormation(stack, "DeleteStack", null);- awaitStackDeleted(stack);+ CfnStackWaits.awaitStackDeleted(stack);} catch (Exception e) {LOG.warnv("Failed to clean up stack {0}: {1}", stack, e.getMessage());}@@ -130,7 +129,7 @@ class RedshiftClusterCfnIntegrationTest {}cloudFormation(stackName, "DeleteStack", null);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);stacksToCleanup.remove(stackName);assertClusterNotFound(clusterId);@@ -190,7 +189,7 @@ class RedshiftClusterCfnIntegrationTest {assertSubnetGroupExists(sgName);cloudFormation(stackName, "DeleteStack", null);- awaitStackDeleted(stackName);+ CfnStackWaits.awaitStackDeleted(stackName);stacksToCleanup.remove(stackName);assertParameterGroupNotFound(pgName);@@ -232,25 +231,6 @@ class RedshiftClusterCfnIntegrationTest {.extract().asString();}- private static void awaitStackDeleted(String stack) throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", stack)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("Stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("Stack " + stack + " was not deleted within the timeout");- }-private static void assertClusterNotFound(String clusterId) {given().contentType("application/x-www-form-urlencoded")diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/SnsFifoThroughputScopeCfnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/SnsFifoThroughputScopeCfnIntegrationTest.javaindex 5664990eb6..2157ac69fc 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/SnsFifoThroughputScopeCfnIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/SnsFifoThroughputScopeCfnIntegrationTest.java@@ -10,7 +10,6 @@ import static io.restassured.RestAssured.given;import static org.junit.jupiter.api.Assertions.assertEquals;import static org.junit.jupiter.api.Assertions.assertFalse;import static org.junit.jupiter.api.Assertions.assertTrue;-import static org.junit.jupiter.api.Assertions.fail;/*** A FIFO topic fanning out to a FIFO queue, the shape a template takes to publish one event per@@ -69,7 +68,7 @@ class SnsFifoThroughputScopeCfnIntegrationTest {""";@Test- void aTemplateAskingForPerGroupDeduplicationGetsIt() throws InterruptedException {+ void aTemplateAskingForPerGroupDeduplicationGetsIt() {cloudFormation("CreateStack", "MessageGroup");String created = describeStacks("CREATE_COMPLETE");String topicArn = outputValue(created, "TopicArn");@@ -103,7 +102,7 @@ class SnsFifoThroughputScopeCfnIntegrationTest {"Topic scope must keep deduplicating across groups: " + topicWide);cloudFormation("DeleteStack", null);- awaitStackDeleted();+ CfnStackWaits.awaitStackDeleted(STACK);topicAttributes(topicArn).statusCode(404);}@@ -133,24 +132,6 @@ class SnsFifoThroughputScopeCfnIntegrationTest {}/** DeleteStack runs asynchronously; a successful delete removes the stack entirely. */- private static void awaitStackDeleted() throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", STACK)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + STACK + " was not deleted within the timeout");- }private static String outputValue(String xml, String key) {return XmlParser.extractPairs(xml, "Outputs", "OutputKey", "OutputValue").get(key);diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/SnsTopicPolicyCfnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/SnsTopicPolicyCfnIntegrationTest.javaindex b9fc250640..968e5368af 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/SnsTopicPolicyCfnIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/SnsTopicPolicyCfnIntegrationTest.java@@ -13,7 +13,6 @@ import static org.hamcrest.Matchers.containsString;import static org.hamcrest.Matchers.not;import static org.junit.jupiter.api.Assertions.assertEquals;import static org.junit.jupiter.api.Assertions.assertTrue;-import static org.junit.jupiter.api.Assertions.fail;/*** Provisions an {@code AWS::SNS::TopicPolicy} over two topics the same stack creates, with the@@ -63,7 +62,7 @@ class SnsTopicPolicyCfnIntegrationTest {""";@Test- void createUpdateAndDeleteATopicPolicy() throws InterruptedException {+ void createUpdateAndDeleteATopicPolicy() {cloudFormation("CreateStack", Map.of("Sid", "AllowPublishV1"));String created = describeStacks("CREATE_COMPLETE");String policyId = outputValue(created, "PolicyRef");@@ -95,7 +94,7 @@ class SnsTopicPolicyCfnIntegrationTest {topicAttributes(topicB).body(containsString("AllowPublishV2"));cloudFormation("DeleteStack", Map.of());- awaitStackDeleted();+ CfnStackWaits.awaitStackDeleted(STACK);topicAttributes(topicA).statusCode(404);topicAttributes(topicB).statusCode(404);@@ -131,24 +130,6 @@ class SnsTopicPolicyCfnIntegrationTest {}/** DeleteStack runs asynchronously; a successful delete removes the stack entirely. */- private static void awaitStackDeleted() throws InterruptedException {- for (int i = 0; i < 100; i++) {- String body = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", CFN_AUTH)- .formParam("Action", "DescribeStacks")- .formParam("StackName", STACK)- .when().post("/").then().extract().asString();- if (body.contains("does not exist")) {- return;- }- if (body.contains("<StackStatus>DELETE_FAILED</StackStatus>")) {- fail("stack delete failed: " + body);- }- Thread.sleep(50);- }- fail("stack " + STACK + " was not deleted within the timeout");- }private static String outputValue(String xml, String key) {return XmlParser.extractPairs(xml, "Outputs", "OutputKey", "OutputValue").get(key);