Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix(cloudformation): poll for CREATE_COMPLETE in SAM changeset test (#1199)

devansh-jain-1842168cee17b7
diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/SamTransformIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/SamTransformIntegrationTest.java
index 08aef74772..6c04721526 100644
--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/SamTransformIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/SamTransformIntegrationTest.java
@@ -521,7 +521,7 @@ class SamTransformIntegrationTest {
}
@Test
- void samFunction_viaChangeSet_createsLambda() {
+ void samFunction_viaChangeSet_createsLambda() throws Exception {
String stackName = "sam-changeset-stack";
stacksToDelete.add(stackName);
@@ -562,15 +562,23 @@ class SamTransformIntegrationTest {
.then()
.statusCode(200);
- given()
- .contentType("application/x-www-form-urlencoded")
- .formParam("Action", "DescribeStacks")
- .formParam("StackName", stackName)
- .when()
- .post("/")
- .then()
- .statusCode(200)
- .body(containsString("<StackStatus>CREATE_COMPLETE</StackStatus>"));
+ String describeBody = null;
+ for (int attempt = 0; attempt < 50; attempt++) {
+ describeBody = given()
+ .contentType("application/x-www-form-urlencoded")
+ .formParam("Action", "DescribeStacks")
+ .formParam("StackName", stackName)
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200)
+ .extract().asString();
+ if (describeBody.contains("<StackStatus>CREATE_COMPLETE</StackStatus>")) {
+ break;
+ }
+ Thread.sleep(100);
+ }
+ assertThat(describeBody, containsString("<StackStatus>CREATE_COMPLETE</StackStatus>"));
given()
.when()