From 42168cee17b7df7e82013e95c4c95d76a59809ec Mon Sep 17 00:00:00 2001 From: devansh-jain-18 Date: Sun, 7 Jun 2026 10:47:16 +0530 Subject: [PATCH] fix(cloudformation): poll for CREATE_COMPLETE in SAM changeset test (#1199) SamTransformIntegrationTest.samFunction_viaChangeSet_createsLambda asserted CREATE_COMPLETE immediately after ExecuteChangeSet, which provisions the stack asynchronously. On slower/variable runners the assertion raced the async work and intermittently observed CREATE_IN_PROGRESS, failing unrelated PRs' CI. Poll DescribeStacks until the stack reaches CREATE_COMPLETE (bounded to ~5s) before asserting. Test-only change; the async ExecuteChangeSet behavior is correct AWS semantics and is left untouched. --- .../SamTransformIntegrationTest.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) 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("CREATE_COMPLETE")); + 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("CREATE_COMPLETE")) { + break; + } + Thread.sleep(100); + } + assertThat(describeBody, containsString("CREATE_COMPLETE")); given() .when()