mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
test(stepfunctions): hold the runtime-failing Map iteration until the one it cuts is waiting (#4794)
The two States.Runtime cases in AslExecutorParallelCutTest failed their item at the Route Choice, which never reaches the sleeper, so nothing made it wait for the other iteration to start. When it won the race the Map failed with nothing to cut, and the tolerance case found no MapIterationAborted or WaitStateAborted before MapStateFailed. The failing item now goes through Pause, which the sleeper holds until the other iteration is in its Wait, and then meets a Choice nothing matches. The plain States.Runtime case also asserts the other iteration's Wait never exits, so it no longer passes with nothing having been cut. Closes #4785 Co-authored-by: mitsukado-shinagawa <mitsukado-shinagawa@users.noreply.github.com>
This commit is contained in:
1 parent
ea06896984
commit
812e9f8269
1 file changed
+15
-5
+15
-5
@@ -105,6 +105,13 @@ class AslExecutorParallelCutTest {
|
||||
"Done":{"Type":"Pass","End":true},
|
||||
"Nest":{"Type":"Task","Resource":"arn:aws:states:::states:startExecution.sync:2",
|
||||
"Parameters":{"StateMachineArn":"%s"},"End":true}}}}""".formatted(CHILD_SM_ARN);
|
||||
/**
|
||||
* The same Map with the "fail" item's Fail swapped for a Choice nothing matches, so that item
|
||||
* ends in States.Runtime, and only after its Pause, where the sleeper holds it.
|
||||
*/
|
||||
private static final String MAP_WITH_A_RUNTIME_FAILING_ITERATION = MAP_WITH_A_FAILING_ITERATION.replace(
|
||||
"\"Boom\":{\"Type\":\"Fail\",\"Error\":\"Boom\",\"Cause\":\"sibling failed\"}",
|
||||
"\"Boom\":{\"Type\":\"Choice\",\"Choices\":[{\"Variable\":\"$.kind\",\"StringEquals\":\"never\",\"Next\":\"Done\"}]}");
|
||||
private static final String SLOW_RESULT_BRANCH = """
|
||||
{"StartAt":"Slow","States":{"Slow":{"Type":"Wait","Seconds":1,"Next":"Out"},
|
||||
"Out":{"Type":"Pass","Result":"slow","End":true}}}""";
|
||||
@@ -283,9 +290,9 @@ class AslExecutorParallelCutTest {
|
||||
*/
|
||||
@Test
|
||||
void aRuntimeFailureThatExceedsTheToleranceRecordsTheOnesItCutButNotItself() {
|
||||
String map = MAP_WITH_A_FAILING_ITERATION.replace("\"Type\":\"Map\",", "\"Type\":\"Map\",\"ToleratedFailureCount\":0,")
|
||||
.replace("\"Default\":\"Nest\",", "");
|
||||
Execution execution = run(map, sleeper(1), 0, "[{\"kind\":\"wait\"},{\"kind\":\"nomatch\"}]");
|
||||
String map = MAP_WITH_A_RUNTIME_FAILING_ITERATION.replace("\"Type\":\"Map\",",
|
||||
"\"Type\":\"Map\",\"ToleratedFailureCount\":0,");
|
||||
Execution execution = run(map, sleeper(1), 0, "[{\"kind\":\"wait\"},{\"kind\":\"fail\"}]");
|
||||
|
||||
assertEquals("FAILED", execution.getStatus());
|
||||
assertEquals("States.ExceedToleratedFailureThreshold", execution.getError());
|
||||
@@ -301,13 +308,16 @@ class AslExecutorParallelCutTest {
|
||||
*/
|
||||
@Test
|
||||
void aRuntimeFailureThatEndsTheMapRecordsNothingForTheOnesItCut() {
|
||||
String map = MAP_WITH_A_FAILING_ITERATION.replace("\"Default\":\"Nest\",", "");
|
||||
Execution execution = run(map, sleeper(1), 0, "[{\"kind\":\"wait\"},{\"kind\":\"nomatch\"}]");
|
||||
Execution execution = run(MAP_WITH_A_RUNTIME_FAILING_ITERATION, sleeper(1), 0,
|
||||
"[{\"kind\":\"wait\"},{\"kind\":\"fail\"}]");
|
||||
|
||||
assertEquals("FAILED", execution.getStatus());
|
||||
assertEquals("States.Runtime", execution.getError());
|
||||
assertTrue(types().stream().noneMatch(type -> type.contains("Aborted") || type.endsWith("Failed")
|
||||
&& !type.equals("ExecutionFailed")), types().toString());
|
||||
// The other iteration was cut inside Long: only the failing one's Pause ever exits.
|
||||
assertEquals(List.of("Pause"), eventsOfType("WaitStateExited").stream()
|
||||
.map(event -> String.valueOf(event.getDetails().get("name"))).toList(), types().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user