feat(sfn): support Retry policies in Task, Parallel, and Map states (#2455)

* feat(sfn): honor Retry policies in the ASL executor

Task, Parallel, and Map states previously ignored their Retry field, so
any failure went straight to Catch or failed the execution. They now
retry per the ASL spec. ErrorEquals matching reuses the Catch matcher,
including the States.ALL and States.TaskFailed wildcards, and
States.Runtime is never retried. AWS defaults apply when fields are
omitted (MaxAttempts 3, IntervalSeconds 1, BackoffRate 2.0).
MaxDelaySeconds is honored. Each retrier keeps its own attempt counter
and an exhausted retrier falls through to Catch. The context object
field $$.State.RetryCount increments per attempt.

Attempt counts, defaults, backoff timing, retry before catch order,
and per attempt RetryCount resolution were verified against real AWS
Step Functions in us-east-1 using execution histories.

Two deviations are documented. The delay between attempts is capped at
30 seconds, matching the cap Floci applies to Wait states.
JitterStrategy is accepted but ignored.

Refs #2283

* test(sfn): add end-to-end Retry integration tests

Covers the JSON 1.0 wire protocol path. The fail-then-succeed case
works without mocks by resolving the DynamoDB table name from
$$.State.RetryCount, so attempt 0 targets a missing table and the
retry targets one that exists. This also exercises per attempt
Parameters re-resolution, which real AWS does the same way. The other
cases cover retrier exhaustion falling through to Catch and an
unmatched error failing without retry.

* fix(sfn): unwrap branch failures so Parallel Retry and Catch apply

* fix(sfn): isolate the context object per Parallel branch and per branch state

* fix(sfn): fail a missing Lambda function as Lambda.ResourceNotFoundException

* test(sfn): cover Retry and Catch for Parallel and Map states

* feat(sfn): support JitterStrategy FULL in Retry backoff

* fix(sfn): keep branch Error causes wrapped so executions still terminate
This commit is contained in:
TATSUNO “Taz” Yasuhiro authored and GitHub committed 2026-08-23 17:13:30 -04:00
1 parent 127e51e71b
commit 56e74d64c6
4 files changed
+783 -6

No files matched your search

@@ -0,0 +1,432 @@
package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbService;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.lambda.model.InvocationType;
import io.github.hectorvent.floci.services.lambda.model.InvokeResult;
import io.github.hectorvent.floci.services.lambda.model.LambdaFunction;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.sqs.SqsJsonHandler;
import io.github.hectorvent.floci.services.stepfunctions.model.Execution;
import io.github.hectorvent.floci.services.stepfunctions.model.HistoryEvent;
import io.github.hectorvent.floci.services.stepfunctions.model.StateMachine;
import io.quarkus.test.junit.QuarkusTest;
import io.vertx.mutiny.core.Vertx;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* Retry policy semantics of the ASL executor. Attempt counts, defaults, and backoff
* behavior were verified against real AWS Step Functions in us-east-1.
*/
@QuarkusTest
class AslExecutorRetryTest {
private static final String REGION = "us-east-2";
private static final String ACCOUNT = "000000000000";
private static final String FLAKY_FUNCTION_NAME = "flaky-lambda";
private static final String FLAKY_FUNCTION_ARN =
"arn:aws:lambda:%s:%s:function:%s".formatted(REGION, ACCOUNT, FLAKY_FUNCTION_NAME);
private final ObjectMapper objectMapper = new ObjectMapper();
private LambdaExecutorService lambdaExecutor;
private LambdaFunctionStore functionStore;
private LambdaFunction flakyFunction;
private AslExecutor executor;
@Inject
Vertx vertx;
@BeforeEach
void setUp() {
lambdaExecutor = mock(LambdaExecutorService.class);
functionStore = mock(LambdaFunctionStore.class);
flakyFunction = new LambdaFunction();
flakyFunction.setFunctionName(FLAKY_FUNCTION_NAME);
flakyFunction.setFunctionArn(FLAKY_FUNCTION_ARN);
when(functionStore.get(REGION, FLAKY_FUNCTION_NAME)).thenReturn(Optional.of(flakyFunction));
executor = new AslExecutor(
lambdaExecutor,
functionStore,
mock(DynamoDbService.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class),
mock(io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler.class),
mock(io.github.hectorvent.floci.services.ec2.Ec2Service.class),
mock(S3Service.class),
mock(io.github.hectorvent.floci.services.ecs.EcsService.class),
mock(io.github.hectorvent.floci.services.ecs.EcsJsonHandler.class),
objectMapper,
new JsonataEvaluator(objectMapper),
mock(Instance.class), mock(EmulatorConfig.class), vertx);
}
@Test
void retriesUntilTheTaskSucceeds() throws Exception {
when(lambdaExecutor.invoke(eq(flakyFunction), any(byte[].class), eq(InvocationType.RequestResponse)))
.thenReturn(new InvokeResult(200, "Handled",
"{\"errorType\":\"Boom\"}".getBytes(StandardCharsets.UTF_8), null, "req-1"))
.thenReturn(new InvokeResult(200, null,
"{\"ok\":true}".getBytes(StandardCharsets.UTF_8), null, "req-2"));
var execution = run("""
{
"StartAt": "Flaky",
"States": {
"Flaky": {
"Type": "Task",
"Resource": "%s",
"End": true,
"Retry": [{
"ErrorEquals": ["Lambda.AWSLambdaException"],
"IntervalSeconds": 1,
"BackoffRate": 1.0,
"MaxAttempts": 2
}]
}
}
}
""".formatted(FLAKY_FUNCTION_ARN));
assertEquals("SUCCEEDED", execution.getStatus());
assertTrue(objectMapper.readTree(execution.getOutput()).path("ok").asBoolean());
verify(lambdaExecutor, times(2))
.invoke(eq(flakyFunction), any(byte[].class), eq(InvocationType.RequestResponse));
}
@Test
void exhaustedRetriesFailWithOriginalError() {
when(lambdaExecutor.invoke(eq(flakyFunction), any(byte[].class), eq(InvocationType.RequestResponse)))
.thenReturn(new InvokeResult(200, "Handled",
"{\"errorType\":\"Boom\"}".getBytes(StandardCharsets.UTF_8), null, "req-1"));
var execution = run("""
{
"StartAt": "Flaky",
"States": {
"Flaky": {
"Type": "Task",
"Resource": "%s",
"End": true,
"Retry": [{
"ErrorEquals": ["Lambda.AWSLambdaException"],
"IntervalSeconds": 1,
"BackoffRate": 1.0,
"MaxAttempts": 1
}]
}
}
}
""".formatted(FLAKY_FUNCTION_ARN));
assertEquals("FAILED", execution.getStatus());
assertEquals("Lambda.AWSLambdaException", execution.getError());
verify(lambdaExecutor, times(2))
.invoke(eq(flakyFunction), any(byte[].class), eq(InvocationType.RequestResponse));
}
@Test
void unmatchedErrorIsNotRetried() {
when(lambdaExecutor.invoke(eq(flakyFunction), any(byte[].class), eq(InvocationType.RequestResponse)))
.thenReturn(new InvokeResult(200, "Handled",
"{\"errorType\":\"Boom\"}".getBytes(StandardCharsets.UTF_8), null, "req-1"));
var execution = run("""
{
"StartAt": "Flaky",
"States": {
"Flaky": {
"Type": "Task",
"Resource": "%s",
"End": true,
"Retry": [{
"ErrorEquals": ["SomeOther.Error"],
"IntervalSeconds": 1,
"MaxAttempts": 3
}]
}
}
}
""".formatted(FLAKY_FUNCTION_ARN));
assertEquals("FAILED", execution.getStatus());
assertEquals("Lambda.AWSLambdaException", execution.getError());
verify(lambdaExecutor, times(1))
.invoke(eq(flakyFunction), any(byte[].class), eq(InvocationType.RequestResponse));
}
@Test
void exhaustedRetrierFallsThroughToCatch() throws Exception {
when(lambdaExecutor.invoke(eq(flakyFunction), any(byte[].class), eq(InvocationType.RequestResponse)))
.thenReturn(new InvokeResult(200, "Handled",
"{\"errorType\":\"Boom\"}".getBytes(StandardCharsets.UTF_8), null, "req-1"));
var execution = run("""
{
"StartAt": "Flaky",
"States": {
"Flaky": {
"Type": "Task",
"Resource": "%s",
"End": true,
"Retry": [{
"ErrorEquals": ["States.ALL"],
"IntervalSeconds": 1,
"BackoffRate": 1.0,
"MaxAttempts": 1
}],
"Catch": [{
"ErrorEquals": ["States.ALL"],
"Next": "HandleError"
}]
},
"HandleError": {
"Type": "Pass",
"End": true
}
}
}
""".formatted(FLAKY_FUNCTION_ARN));
assertEquals("SUCCEEDED", execution.getStatus());
assertEquals("Lambda.AWSLambdaException",
objectMapper.readTree(execution.getOutput()).path("Error").asText());
verify(lambdaExecutor, times(2))
.invoke(eq(flakyFunction), any(byte[].class), eq(InvocationType.RequestResponse));
}
@Test
void parallelStateRetriesFailingBranch() throws Exception {
failOnceThenSucceed();
var execution = run("""
{
"StartAt": "Par",
"States": {
"Par": {
"Type": "Parallel",
"Branches": [{
"StartAt": "Inner",
"States": {"Inner": {"Type": "Task", "Resource": "%s", "End": true}}
}],
"Retry": [{
"ErrorEquals": ["Lambda.AWSLambdaException"],
"IntervalSeconds": 1,
"BackoffRate": 1.0,
"MaxAttempts": 1
}],
"End": true
}
}
}
""".formatted(FLAKY_FUNCTION_ARN));
assertEquals("SUCCEEDED", execution.getStatus());
assertTrue(objectMapper.readTree(execution.getOutput()).path(0).path("ok").asBoolean());
verify(lambdaExecutor, times(2))
.invoke(eq(flakyFunction), any(byte[].class), eq(InvocationType.RequestResponse));
}
@Test
void parallelBranchFailureReachesCatch() throws Exception {
when(lambdaExecutor.invoke(eq(flakyFunction), any(byte[].class), eq(InvocationType.RequestResponse)))
.thenReturn(new InvokeResult(200, "Handled",
"{\"errorType\":\"Boom\"}".getBytes(StandardCharsets.UTF_8), null, "req-1"));
var execution = run("""
{
"StartAt": "Par",
"States": {
"Par": {
"Type": "Parallel",
"Branches": [{
"StartAt": "Inner",
"States": {"Inner": {"Type": "Task", "Resource": "%s", "End": true}}
}],
"Catch": [{
"ErrorEquals": ["States.ALL"],
"Next": "HandleError"
}],
"End": true
},
"HandleError": {"Type": "Pass", "End": true}
}
}
""".formatted(FLAKY_FUNCTION_ARN));
assertEquals("SUCCEEDED", execution.getStatus());
assertEquals("Lambda.AWSLambdaException",
objectMapper.readTree(execution.getOutput()).path("Error").asText());
verify(lambdaExecutor, times(1))
.invoke(eq(flakyFunction), any(byte[].class), eq(InvocationType.RequestResponse));
}
@Test
void taskInsideParallelBranchRetriesIndependently() throws Exception {
failOnceThenSucceed();
var execution = run("""
{
"StartAt": "Par",
"States": {
"Par": {
"Type": "Parallel",
"Branches": [{
"StartAt": "Inner",
"States": {
"Inner": {
"Type": "Task",
"Resource": "%s",
"End": true,
"Retry": [{
"ErrorEquals": ["Lambda.AWSLambdaException"],
"IntervalSeconds": 1,
"BackoffRate": 1.0,
"MaxAttempts": 1
}]
}
}
}],
"End": true
}
}
}
""".formatted(FLAKY_FUNCTION_ARN));
assertEquals("SUCCEEDED", execution.getStatus());
assertTrue(objectMapper.readTree(execution.getOutput()).path(0).path("ok").asBoolean());
verify(lambdaExecutor, times(2))
.invoke(eq(flakyFunction), any(byte[].class), eq(InvocationType.RequestResponse));
}
@Test
void mapStateRetriesFailingIteration() throws Exception {
failOnceThenSucceed();
var execution = run("""
{
"StartAt": "Loop",
"States": {
"Loop": {
"Type": "Map",
"ItemsPath": "$.items",
"ItemProcessor": {
"ProcessorConfig": {"Mode": "INLINE"},
"StartAt": "Inner",
"States": {"Inner": {"Type": "Task", "Resource": "%s", "End": true}}
},
"Retry": [{
"ErrorEquals": ["Lambda.AWSLambdaException"],
"IntervalSeconds": 1,
"BackoffRate": 1.0,
"MaxAttempts": 1
}],
"End": true
}
}
}
""".formatted(FLAKY_FUNCTION_ARN), "{\"items\": [1]}");
assertEquals("SUCCEEDED", execution.getStatus());
assertTrue(objectMapper.readTree(execution.getOutput()).path(0).path("ok").asBoolean());
verify(lambdaExecutor, times(2))
.invoke(eq(flakyFunction), any(byte[].class), eq(InvocationType.RequestResponse));
}
@Test
void branchErrorStillFailsTheExecution() {
when(lambdaExecutor.invoke(eq(flakyFunction), any(byte[].class), eq(InvocationType.RequestResponse)))
.thenThrow(new AssertionError("boom"));
var execution = run("""
{
"StartAt": "Par",
"States": {
"Par": {
"Type": "Parallel",
"Branches": [{
"StartAt": "Inner",
"States": {"Inner": {"Type": "Task", "Resource": "%s", "End": true}}
}],
"End": true
}
}
}
""".formatted(FLAKY_FUNCTION_ARN));
assertEquals("FAILED", execution.getStatus());
assertEquals("States.Runtime", execution.getError());
}
@Test
void retryDelayFollowsBackoffAndCaps() throws Exception {
assertEquals(10.0, delay("{\"IntervalSeconds\": 10, \"BackoffRate\": 2.0}", 1, 0.5));
assertEquals(20.0, delay("{\"IntervalSeconds\": 10, \"BackoffRate\": 2.0}", 2, 0.5));
assertEquals(15.0, delay("{\"IntervalSeconds\": 10, \"BackoffRate\": 2.0, \"MaxDelaySeconds\": 15}", 2, 0.5));
assertEquals(30.0, delay("{\"IntervalSeconds\": 20, \"BackoffRate\": 2.0}", 2, 0.5));
}
@Test
void fullJitterScalesTheDelayByTheRandomFactor() throws Exception {
var retrier = "{\"IntervalSeconds\": 10, \"BackoffRate\": 1.0, \"JitterStrategy\": \"FULL\"}";
assertEquals(0.0, delay(retrier, 1, 0.0));
assertEquals(5.0, delay(retrier, 1, 0.5));
assertEquals(10.0, delay("{\"IntervalSeconds\": 10, \"BackoffRate\": 1.0, \"JitterStrategy\": \"NONE\"}", 1, 0.5));
}
private double delay(String retrierJson, int attemptsUsed, double random) throws Exception {
return AslExecutor.retryDelaySeconds(objectMapper.readTree(retrierJson), attemptsUsed, random);
}
private void failOnceThenSucceed() {
when(lambdaExecutor.invoke(eq(flakyFunction), any(byte[].class), eq(InvocationType.RequestResponse)))
.thenReturn(new InvokeResult(200, "Handled",
"{\"errorType\":\"Boom\"}".getBytes(StandardCharsets.UTF_8), null, "req-1"))
.thenReturn(new InvokeResult(200, null,
"{\"ok\":true}".getBytes(StandardCharsets.UTF_8), null, "req-2"));
}
private Execution run(String definition) {
return run(definition, "{}");
}
private Execution run(String definition, String input) {
var stateMachine = new StateMachine();
stateMachine.setName("retry-test");
stateMachine.setStateMachineArn("arn:aws:states:%s:%s:stateMachine:retry-test".formatted(REGION, ACCOUNT));
stateMachine.setRoleArn("arn:aws:iam::%s:role/test-role".formatted(ACCOUNT));
stateMachine.setDefinition(definition);
var execution = new Execution();
execution.setName("retry-test-execution");
execution.setExecutionArn(
"arn:aws:states:%s:%s:execution:retry-test:retry-test-execution".formatted(REGION, ACCOUNT));
execution.setStateMachineArn(stateMachine.getStateMachineArn());
execution.setInput(input);
var history = new ArrayList<HistoryEvent>();
executor.executeSync(stateMachine, execution, history, (updated, events) -> {
});
return execution;
}
}
@@ -0,0 +1,234 @@
package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.response.Response;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import static io.restassured.RestAssured.given;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
/**
* End-to-end Retry policy tests through the JSON 1.0 wire protocol.
*
* The fail-then-succeed case works without mocks by resolving the DynamoDB table name
* from {@code $$.State.RetryCount}. Attempt 0 targets a table that does not exist and
* fails. The retry re-resolves Parameters, targets the table that does exist, and
* succeeds. Real AWS re-resolves Parameters per attempt the same way (verified in
* us-east-1).
*/
@QuarkusTest
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class StepFunctionsRetryIntegrationTest {
private static final String SFN_CONTENT_TYPE = "application/x-amz-json-1.0";
private static final String DDB_CONTENT_TYPE = "application/x-amz-json-1.0";
private static final String ROLE_ARN = "arn:aws:iam::000000000000:role/test-role";
private static final String RETRY_TABLE = "sfn-retry-1";
private static final String MISSING_TABLE = "sfn-retry-none";
private static final ObjectMapper mapper = new ObjectMapper();
@BeforeAll
static void configureRestAssured() {
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
@Order(0)
void setup_createTargetTableForSecondAttempt() {
given()
.header("X-Amz-Target", "DynamoDB_20120810.CreateTable")
.contentType(DDB_CONTENT_TYPE)
.body("""
{
"TableName": "%s",
"KeySchema": [{"AttributeName": "pk", "KeyType": "HASH"}],
"AttributeDefinitions": [{"AttributeName": "pk", "AttributeType": "S"}],
"BillingMode": "PAY_PER_REQUEST"
}
""".formatted(RETRY_TABLE))
.when().post("/")
.then().statusCode(200);
}
@Test
@Order(1)
void taskIsRetriedAndSucceedsOnSecondAttempt() throws Exception {
var smArn = createStateMachine("sfn-retry-succeed-test", """
{
"StartAt": "Flaky",
"States": {
"Flaky": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:putItem",
"Parameters": {
"TableName.$": "States.Format('sfn-retry-{}', $$.State.RetryCount)",
"Item": {"pk": {"S": "attempt-win"}}
},
"Retry": [{
"ErrorEquals": ["DynamoDB.ResourceNotFoundException"],
"IntervalSeconds": 1,
"BackoffRate": 1.0,
"MaxAttempts": 2
}],
"End": true
}
}
}
""");
var execArn = startExecution(smArn, "{}");
var describe = waitForTerminalState(execArn);
assertEquals("SUCCEEDED", describe.jsonPath().getString("status"));
var getItem = given()
.header("X-Amz-Target", "DynamoDB_20120810.GetItem")
.contentType(DDB_CONTENT_TYPE)
.body("""
{"TableName": "%s", "Key": {"pk": {"S": "attempt-win"}}}
""".formatted(RETRY_TABLE))
.when().post("/");
getItem.then().statusCode(200);
assertEquals("attempt-win",
mapper.readTree(getItem.body().asString()).path("Item").path("pk").path("S").asText());
}
@Test
@Order(2)
void exhaustedRetriesFallThroughToCatch() throws Exception {
var smArn = createStateMachine("sfn-retry-catch-test", """
{
"StartAt": "Flaky",
"States": {
"Flaky": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:putItem",
"Parameters": {
"TableName": "%s",
"Item": {"pk": {"S": "never"}}
},
"Retry": [{
"ErrorEquals": ["DynamoDB.ResourceNotFoundException"],
"IntervalSeconds": 1,
"BackoffRate": 1.0,
"MaxAttempts": 1
}],
"Catch": [{
"ErrorEquals": ["States.ALL"],
"ResultPath": "$.err",
"Next": "Handled"
}],
"End": true
},
"Handled": {"Type": "Pass", "End": true}
}
}
""".formatted(MISSING_TABLE));
var execArn = startExecution(smArn, "{}");
var describe = waitForTerminalState(execArn);
assertEquals("SUCCEEDED", describe.jsonPath().getString("status"));
var output = mapper.readTree(describe.jsonPath().getString("output"));
assertEquals("DynamoDB.ResourceNotFoundException", output.path("err").path("Error").asText());
}
@Test
@Order(3)
void unmatchedErrorFailsWithoutRetry() {
var smArn = createStateMachine("sfn-retry-unmatched-test", """
{
"StartAt": "Flaky",
"States": {
"Flaky": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:putItem",
"Parameters": {
"TableName": "%s",
"Item": {"pk": {"S": "never"}}
},
"Retry": [{
"ErrorEquals": ["SomeOther.Error"],
"IntervalSeconds": 1,
"MaxAttempts": 3
}],
"End": true
}
}
}
""".formatted(MISSING_TABLE));
var execArn = startExecution(smArn, "{}");
var describe = waitForTerminalState(execArn);
assertEquals("FAILED", describe.jsonPath().getString("status"));
assertEquals("DynamoDB.ResourceNotFoundException", describe.jsonPath().getString("error"));
}
private static String createStateMachine(String name, String definition) {
var resp = given()
.header("X-Amz-Target", "AWSStepFunctions.CreateStateMachine")
.contentType(SFN_CONTENT_TYPE)
.body("""
{
"name": "%s",
"roleArn": "%s",
"definition": %s
}
""".formatted(name, ROLE_ARN, quote(definition)))
.when().post("/");
resp.then().statusCode(200);
return resp.jsonPath().getString("stateMachineArn");
}
private static String startExecution(String smArn, String input) {
var resp = given()
.header("X-Amz-Target", "AWSStepFunctions.StartExecution")
.contentType(SFN_CONTENT_TYPE)
.body("""
{"stateMachineArn": "%s", "input": %s}
""".formatted(smArn, quote(input)))
.when().post("/");
resp.then().statusCode(200);
return resp.jsonPath().getString("executionArn");
}
private static Response waitForTerminalState(String execArn) {
for (var i = 0; i < 100; i++) {
var resp = given()
.header("X-Amz-Target", "AWSStepFunctions.DescribeExecution")
.contentType(SFN_CONTENT_TYPE)
.body("""
{"executionArn": "%s"}
""".formatted(execArn))
.when().post("/");
var status = resp.jsonPath().getString("status");
if (!"RUNNING".equals(status)) {
return resp;
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
fail("Interrupted while waiting for execution " + execArn);
}
}
fail("Execution did not complete within timeout: " + execArn);
return null;
}
private static String quote(String raw) {
return "\"" + raw
.replace("\\", "\\\\")
.replace("\"", "\\\"")
.replace("\n", "\\n")
.replace("\r", "\\r")
.replace("\t", "\\t")
+ "\"";
}
}