mirror of
https://github.com/floci-io/floci.git
synced 2026-11-28 16:11:48 -05:00
test(stepfunctions): use the shared execution waiter in four compatibility tests (#7580)
StepFunctionsActivityTest, StepFunctionsDescribeMapRunTest, StepFunctionsExecutionHistoryTest and StepFunctionsNestedSmTest each had their own pollUntilDone loop. They now call TestFixtures.awaitExecutionTerminal with the same time budgets as before (60 s, 15 s, 60 s and 30 s). Every caller asserts the status right after, so an execution still RUNNING at the deadline fails the test as before. Co-authored-by: Syed Ali Hasan Shah <257496457+syedali032-creator@users.noreply.github.com>
This commit is contained in:
1 parent
a19b296f06
commit
b235792722
4 files changed
+26
-58
No files matched your search
+5
-15
@@ -4,6 +4,7 @@ import org.junit.jupiter.api.*;
|
||||
import software.amazon.awssdk.services.sfn.SfnClient;
|
||||
import software.amazon.awssdk.services.sfn.model.*;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -144,7 +145,8 @@ class StepFunctionsActivityTest {
|
||||
|
||||
worker.get(90, TimeUnit.SECONDS);
|
||||
|
||||
DescribeExecutionResponse result = pollUntilDone(execArn);
|
||||
DescribeExecutionResponse result =
|
||||
TestFixtures.awaitExecutionTerminal(sfn, execArn, Duration.ofSeconds(60));
|
||||
assertThat(result.status()).isEqualTo(ExecutionStatus.SUCCEEDED);
|
||||
assertThat(result.output()).contains("\"result\":\"done\"");
|
||||
} finally {
|
||||
@@ -208,7 +210,8 @@ class StepFunctionsActivityTest {
|
||||
|
||||
worker.get(90, TimeUnit.SECONDS);
|
||||
|
||||
DescribeExecutionResponse result = pollUntilDone(execArn);
|
||||
DescribeExecutionResponse result =
|
||||
TestFixtures.awaitExecutionTerminal(sfn, execArn, Duration.ofSeconds(60));
|
||||
assertThat(result.status()).isEqualTo(ExecutionStatus.SUCCEEDED);
|
||||
assertThat(result.output()).contains("\"processed\":true");
|
||||
} finally {
|
||||
@@ -216,17 +219,4 @@ class StepFunctionsActivityTest {
|
||||
try { sfn.deleteActivity(b -> b.activityArn(arn)); } catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
// ──────────────────────────── helper ────────────────────────────
|
||||
|
||||
private DescribeExecutionResponse pollUntilDone(String execArn) throws InterruptedException {
|
||||
for (int i = 0; i < 120; i++) {
|
||||
DescribeExecutionResponse resp = sfn.describeExecution(b -> b.executionArn(execArn));
|
||||
if (resp.status() != ExecutionStatus.RUNNING) {
|
||||
return resp;
|
||||
}
|
||||
Thread.sleep(500);
|
||||
}
|
||||
throw new AssertionError("Execution did not complete within 60s: " + execArn);
|
||||
}
|
||||
}
|
||||
+4
-12
@@ -22,6 +22,8 @@ import software.amazon.awssdk.services.sfn.model.MapRunItemCounts;
|
||||
import software.amazon.awssdk.services.sfn.model.MapRunStatus;
|
||||
import software.amazon.awssdk.services.sfn.model.ResourceNotFoundException;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
@@ -94,7 +96,8 @@ class StepFunctionsDescribeMapRunTest {
|
||||
.stateMachineArn(stateMachineArn)
|
||||
.input("{}")).executionArn();
|
||||
|
||||
DescribeExecutionResponse execution = pollUntilDone(executionArn);
|
||||
DescribeExecutionResponse execution =
|
||||
TestFixtures.awaitExecutionTerminal(sfn, executionArn, Duration.ofSeconds(15));
|
||||
assertThat(execution.status())
|
||||
.as("cause: %s", execution.cause())
|
||||
.isEqualTo(ExecutionStatus.SUCCEEDED);
|
||||
@@ -185,15 +188,4 @@ class StepFunctionsDescribeMapRunTest {
|
||||
assertThat(counts.failuresNotRedrivable()).isEqualTo(0);
|
||||
assertThat(counts.pendingRedrive()).isEqualTo(0);
|
||||
}
|
||||
|
||||
private static DescribeExecutionResponse pollUntilDone(String execArn) throws InterruptedException {
|
||||
for (int i = 0; i < 150; i++) {
|
||||
DescribeExecutionResponse resp = sfn.describeExecution(b -> b.executionArn(execArn));
|
||||
if (resp.status() != ExecutionStatus.RUNNING) {
|
||||
return resp;
|
||||
}
|
||||
Thread.sleep(100);
|
||||
}
|
||||
throw new AssertionError("Execution did not complete within timeout: " + execArn);
|
||||
}
|
||||
}
|
||||
+9
-15
@@ -8,6 +8,7 @@ import software.amazon.awssdk.services.sfn.model.*;
|
||||
import software.amazon.awssdk.services.sqs.SqsClient;
|
||||
import software.amazon.awssdk.services.sqs.model.DeleteQueueRequest;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
@@ -80,7 +81,8 @@ class StepFunctionsExecutionHistoryTest {
|
||||
.stateMachineArn(smArn)
|
||||
.input("{}")).executionArn();
|
||||
|
||||
DescribeExecutionResponse execution = pollUntilDone(execArn);
|
||||
DescribeExecutionResponse execution =
|
||||
TestFixtures.awaitExecutionTerminal(sfn, execArn, Duration.ofSeconds(60));
|
||||
assertThat(execution.status()).isEqualTo(ExecutionStatus.SUCCEEDED);
|
||||
|
||||
GetExecutionHistoryResponse history = sfn.getExecutionHistory(b -> b
|
||||
@@ -171,7 +173,8 @@ class StepFunctionsExecutionHistoryTest {
|
||||
.stateMachineArn(smArn)
|
||||
.input("{\"items\": [1, 2]}")).executionArn();
|
||||
|
||||
DescribeExecutionResponse execution = pollUntilDone(execArn);
|
||||
DescribeExecutionResponse execution =
|
||||
TestFixtures.awaitExecutionTerminal(sfn, execArn, Duration.ofSeconds(60));
|
||||
assertThat(execution.status()).isEqualTo(ExecutionStatus.SUCCEEDED);
|
||||
|
||||
List<HistoryEvent> events = sfn.getExecutionHistory(b -> b
|
||||
@@ -249,7 +252,8 @@ class StepFunctionsExecutionHistoryTest {
|
||||
.stateMachineArn(smArn)
|
||||
.input("{\"x\":\"a\"}")).executionArn();
|
||||
|
||||
DescribeExecutionResponse execution = pollUntilDone(execArn);
|
||||
DescribeExecutionResponse execution =
|
||||
TestFixtures.awaitExecutionTerminal(sfn, execArn, Duration.ofSeconds(60));
|
||||
assertThat(execution.status()).isEqualTo(ExecutionStatus.FAILED);
|
||||
assertThat(execution.error()).isEqualTo("States.Runtime");
|
||||
assertThat(execution.cause()).isEqualTo(
|
||||
@@ -289,7 +293,8 @@ class StepFunctionsExecutionHistoryTest {
|
||||
|
||||
try {
|
||||
String execArn = sfn.startExecution(b -> b.stateMachineArn(smArn).input("{}")).executionArn();
|
||||
assertThat(pollUntilDone(execArn).status()).isEqualTo(ExecutionStatus.SUCCEEDED);
|
||||
assertThat(TestFixtures.awaitExecutionTerminal(sfn, execArn, Duration.ofSeconds(60)).status())
|
||||
.isEqualTo(ExecutionStatus.SUCCEEDED);
|
||||
|
||||
GetExecutionHistoryResponse firstPage = sfn.getExecutionHistory(b -> b.executionArn(execArn));
|
||||
assertThat(firstPage.events()).hasSize(100);
|
||||
@@ -322,15 +327,4 @@ class StepFunctionsExecutionHistoryTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private DescribeExecutionResponse pollUntilDone(String execArn) throws InterruptedException {
|
||||
for (int i = 0; i < 120; i++) {
|
||||
DescribeExecutionResponse resp = sfn.describeExecution(b -> b.executionArn(execArn));
|
||||
if (resp.status() != ExecutionStatus.RUNNING) {
|
||||
return resp;
|
||||
}
|
||||
Thread.sleep(500);
|
||||
}
|
||||
throw new AssertionError("Execution did not complete within 60s: " + execArn);
|
||||
}
|
||||
}
|
||||
+8
-16
@@ -4,6 +4,8 @@ import org.junit.jupiter.api.*;
|
||||
import software.amazon.awssdk.services.sfn.SfnClient;
|
||||
import software.amazon.awssdk.services.sfn.model.*;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
/**
|
||||
@@ -90,7 +92,8 @@ class StepFunctionsNestedSmTest {
|
||||
.stateMachineArn(parentSmArn)
|
||||
.input("{}")).executionArn();
|
||||
|
||||
DescribeExecutionResponse result = pollUntilDone(execArn);
|
||||
DescribeExecutionResponse result =
|
||||
TestFixtures.awaitExecutionTerminal(sfn, execArn, Duration.ofSeconds(30));
|
||||
|
||||
assertThat(result.status()).isEqualTo(ExecutionStatus.SUCCEEDED);
|
||||
// Output must be the PascalCase envelope, with the child's output as a JSON value
|
||||
@@ -136,7 +139,8 @@ class StepFunctionsNestedSmTest {
|
||||
.stateMachineArn(parentSmArn)
|
||||
.input("{}")).executionArn();
|
||||
|
||||
DescribeExecutionResponse result = pollUntilDone(execArn);
|
||||
DescribeExecutionResponse result =
|
||||
TestFixtures.awaitExecutionTerminal(sfn, execArn, Duration.ofSeconds(30));
|
||||
|
||||
assertThat(result.status()).isEqualTo(ExecutionStatus.SUCCEEDED);
|
||||
// Output must be the PascalCase envelope, with the child's output as a JSON string
|
||||
@@ -182,7 +186,8 @@ class StepFunctionsNestedSmTest {
|
||||
.stateMachineArn(parentSmArn)
|
||||
.input("{}")).executionArn();
|
||||
|
||||
DescribeExecutionResponse result = pollUntilDone(execArn);
|
||||
DescribeExecutionResponse result =
|
||||
TestFixtures.awaitExecutionTerminal(sfn, execArn, Duration.ofSeconds(30));
|
||||
|
||||
assertThat(result.status()).isEqualTo(ExecutionStatus.SUCCEEDED);
|
||||
// Output must be { ExecutionArn, StartDate } with no child output
|
||||
@@ -194,17 +199,4 @@ class StepFunctionsNestedSmTest {
|
||||
try { sfn.deleteStateMachine(b -> b.stateMachineArn(parentSmArn)); } catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
// ──────────────────────────── helper ────────────────────────────
|
||||
|
||||
private DescribeExecutionResponse pollUntilDone(String execArn) throws InterruptedException {
|
||||
for (int i = 0; i < 60; i++) {
|
||||
DescribeExecutionResponse resp = sfn.describeExecution(b -> b.executionArn(execArn));
|
||||
if (resp.status() != ExecutionStatus.RUNNING) {
|
||||
return resp;
|
||||
}
|
||||
Thread.sleep(500);
|
||||
}
|
||||
throw new AssertionError("Execution did not complete within 30s: " + execArn);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user