mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 23:59:27 -05:00
test(cloudformation): fix flaky tests by waiting for DeleteStack to finish (#4220)
* test(cloudformation): wait for DeleteStack to finish before asserting on its resources
DeleteStack answers as soon as the deletion is queued on the operation
executor. Seven test classes asserted on the stack's resources, or
created a stack under the same name, right after that answer. They race
the executor. Two of them failed on busy CI runners, and the other five
have the same shape.
Each class now polls DescribeStacks until the stack is gone, the same
way ec2ab0768 fixed the CloudFront policies test.
Fixes #3993
Fixes #4147
* test(cloudformation): share the DeleteStack wait across the seven tests
The seven copies of awaitStackDeleted become one package-private
CfnStackWaits. The older copies elsewhere in the package are left as
they are.
* test(cloudformation): key the DeleteStack wait off the response status
A missing stack is a 400 from DescribeStacks. Matching the message text
would loop for the full ten seconds if the wording ever changed.
* test(cloudformation): use CfnStackWaits in every test that waited for DeleteStack
Twenty-nine classes carried their own copy of the poll. They now call
the shared helper, and the throws clauses that only the copy needed are
gone. CloudFormationIntegrationTest keeps its own wait because one of
its callers waits by ARN, which DescribeStacks reports as
DELETE_COMPLETE rather than as missing.
This commit is contained in:
1 parent
d214144c86
commit
b2e2d116d8
37 files changed
+169
-692
No files matched your search
+4
-23
@@ -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()
|
||||
|
||||
+2
-21
@@ -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);
|
||||
|
||||
+2
-21
@@ -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);
|
||||
|
||||
+2
-21
@@ -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);
|
||||
|
||||
+2
-21
@@ -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);
|
||||
|
||||
+2
-22
@@ -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);
|
||||
}
|
||||
|
||||
+2
-21
@@ -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);
|
||||
|
||||
+2
-21
@@ -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);
|
||||
|
||||
+1
-15
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
+1
@@ -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))
|
||||
|
||||
+1
-33
@@ -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) {
|
||||
|
||||
+14
-34
@@ -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 {
|
||||
*/
|
||||
@Test
|
||||
void 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);
|
||||
}
|
||||
|
||||
+2
-22
@@ -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) {
|
||||
|
||||
+1
-21
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
+1
-21
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
+2
-26
@@ -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());
|
||||
}
|
||||
|
||||
+19
-41
@@ -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 {
|
||||
|
||||
@Test
|
||||
void 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);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+1
@@ -138,6 +138,7 @@ class CloudFormationIamRoleInlinePoliciesIntegrationTest {
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
CfnStackWaits.awaitStackDeleted(stackName);
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
|
||||
+2
-22
@@ -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);
|
||||
}
|
||||
}
|
||||
+11
-30
@@ -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);
|
||||
}
|
||||
|
||||
+1
@@ -165,6 +165,7 @@ class CloudFormationLaunchTemplateIntegrationTest {
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
CfnStackWaits.awaitStackDeleted(stackName);
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
|
||||
+14
-33
@@ -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);
|
||||
}
|
||||
|
||||
+1
@@ -592,6 +592,7 @@ class CloudFormationPipesCleanupIntegrationTest {
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
CfnStackWaits.awaitStackDeleted(stackName);
|
||||
}
|
||||
|
||||
private static void assertPipe(String pipeName) {
|
||||
|
||||
+2
-22
@@ -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");
|
||||
}
|
||||
}
|
||||
+3
-24
@@ -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 resource
|
||||
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");
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
+1
@@ -227,5 +227,6 @@ class CloudFormationRollbackCompleteUpdateIntegrationTest {
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
CfnStackWaits.awaitStackDeleted(stackName);
|
||||
}
|
||||
}
|
||||
+1
-21
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
+6
-26
@@ -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");
|
||||
}
|
||||
}
|
||||
+1
@@ -84,6 +84,7 @@ class CloudFormationVpcEndpointIntegrationTest {
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
CfnStackWaits.awaitStackDeleted(stackName);
|
||||
|
||||
String endpointsAfterDelete = given()
|
||||
.formParam("Action", "DescribeVpcEndpoints")
|
||||
|
||||
+1
@@ -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")
|
||||
|
||||
+7
-25
@@ -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");
|
||||
|
||||
+1
-20
@@ -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);
|
||||
|
||||
+1
-20
@@ -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);
|
||||
|
||||
+3
-23
@@ -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")
|
||||
|
||||
+2
-21
@@ -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);
|
||||
|
||||
+2
-21
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user