fix(stepfunctions): end an Express execution at its maximum execution time instead of letting it run on (#5864)

* fix(stepfunctions): end a synchronous execution at its maximum execution time instead of letting it run on

* test(stepfunctions): build AslExecutor in tests through a shared fixture

* fix(stepfunctions): keep the first outcome of a timed-out Express execution and limit asynchronous Express executions too

* fix(stepfunctions): time out an execution a late runtime error reaches, and measure its deadlines on an injectable clock

* test(stepfunctions): test the synchronous caller's timeout step directly instead of on the real clock
This commit is contained in:
Niels Kootstra authored and GitHub committed 2026-10-18 09:10:25 -04:00
1 parent 450321a001
commit 1ee87fc4e9
37 files changed
+804 -933

No files matched your search

@@ -2,22 +2,9 @@ package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsService;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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 jakarta.enterprise.inject.Instance;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -29,7 +16,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
/**
* Functionality + regression coverage for the last four JSONPath-mode intrinsic functions:
@@ -50,25 +36,10 @@ class AslExecutorArrayAndMathIntrinsicsTest {
@BeforeEach
@SuppressWarnings("unchecked")
void setUp() {
executor = new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.class),
mock(CloudFormationQueryHandler.class),
mock(Ec2Service.class),
mock(S3Service.class),
mock(EcsService.class),
mock(EcsJsonHandler.class),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
mapper,
new JsonataEvaluator(mapper),
mock(Instance.class),
mock(EmulatorConfig.class),
null, null);
executor = AslExecutorFixture.builder()
.objectMapper(mapper)
.customResourceLiveness(null)
.build();
}
private void assertIntrinsicFailure(JsonNode root, String expr) {
@@ -18,8 +18,11 @@ class AslExecutorArrayParamsTest {
private final ObjectMapper mapper = new ObjectMapper();
private AslExecutor newExecutor() {
return new AslExecutor(null, null, null, null, null, null, null, null, null,
null, null, null, null, null, mapper, null, null, null, null, null);
return AslExecutorFixture.builder()
.objectMapper(mapper)
.config(null)
.customResourceLiveness(null)
.build();
}
@Test
@@ -2,13 +2,6 @@ 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.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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.MockedResponseStep;
@@ -64,24 +57,12 @@ class AslExecutorBranchHistoryEventsTest {
when(sfnService.get()).thenReturn(mock(StepFunctionsService.class));
EmulatorConfig config = mock(EmulatorConfig.class, RETURNS_DEEP_STUBS);
when(config.services().stepfunctions().maxWaitSeconds()).thenReturn(30);
executor = new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.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),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
objectMapper,
new JsonataEvaluator(objectMapper),
sfnService, config, vertx,
mock(io.github.hectorvent.floci.core.common.CustomResourceLiveness.class));
executor = AslExecutorFixture.builder()
.objectMapper(objectMapper)
.sfnService(sfnService)
.config(config)
.vertx(vertx)
.build();
}
@Test
@@ -2,23 +2,16 @@ package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
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.sns.SnsJsonHandler;
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;
@@ -80,23 +73,13 @@ class AslExecutorCatchTest {
return new InvokeResult(200, null, output, null, "cleanup-request");
});
executor = new AslExecutor(
lambdaExecutor,
functionStore,
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.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),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
objectMapper,
new JsonataEvaluator(objectMapper),
mock(Instance.class), mock(EmulatorConfig.class), vertx, null);
executor = AslExecutorFixture.builder()
.lambdaExecutor(lambdaExecutor)
.functionStore(functionStore)
.objectMapper(objectMapper)
.vertx(vertx)
.customResourceLiveness(null)
.build();
}
@Test
@@ -1,22 +1,9 @@
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.cloudformation.CloudFormationQueryHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsService;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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 jakarta.enterprise.inject.Instance;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -24,7 +11,6 @@ import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
/**
* End-to-end Choice-state routing through the full {@code executeSync} loop, covering the
@@ -43,25 +29,10 @@ class AslExecutorChoiceRuntimeTest {
@BeforeEach
@SuppressWarnings("unchecked")
void setUp() {
executor = new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.class),
mock(CloudFormationQueryHandler.class),
mock(Ec2Service.class),
mock(S3Service.class),
mock(EcsService.class),
mock(EcsJsonHandler.class),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
mapper,
new JsonataEvaluator(mapper),
mock(Instance.class),
mock(EmulatorConfig.class),
null, null);
executor = AslExecutorFixture.builder()
.objectMapper(mapper)
.customResourceLiveness(null)
.build();
}
private static final String GTE_MACHINE = """
@@ -1,24 +1,17 @@
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.core.common.CustomResourceLiveness;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
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.sns.SnsJsonHandler;
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;
@@ -74,23 +67,13 @@ class AslExecutorCustomResourceLivenessTest {
when(lambdaExecutor.invoke(eq(function), any(byte[].class), eq(InvocationType.RequestResponse)))
.thenReturn(new InvokeResult(200, null, "{}".getBytes(), null, "poll-request"));
executor = new AslExecutor(
lambdaExecutor,
functionStore,
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.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),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
objectMapper,
new JsonataEvaluator(objectMapper),
mock(Instance.class), mock(EmulatorConfig.class), vertx, customResourceLiveness);
executor = AslExecutorFixture.builder()
.lambdaExecutor(lambdaExecutor)
.functionStore(functionStore)
.objectMapper(objectMapper)
.vertx(vertx)
.customResourceLiveness(customResourceLiveness)
.build();
}
@Test
@@ -3,18 +3,12 @@ package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsService;
import io.github.hectorvent.floci.services.ecs.container.HostVolumePolicy;
import io.github.hectorvent.floci.services.ecs.model.Container;
import io.github.hectorvent.floci.services.ecs.model.EcsTask;
import io.github.hectorvent.floci.services.ecs.model.NetworkConfiguration;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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;
@@ -23,7 +17,6 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import java.time.Clock;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -86,29 +79,15 @@ class AslExecutorEcsRunTaskModeTest {
Instance<StepFunctionsService> instance = mock(Instance.class);
when(instance.get()).thenReturn(sfnService);
return new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.class),
mock(io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler.class),
mock(io.github.hectorvent.floci.services.ec2.Ec2Service.class),
mock(io.github.hectorvent.floci.services.s3.S3Service.class),
ecsService,
ecsJsonHandler,
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
objectMapper,
new JsonataEvaluator(objectMapper),
instance,
mock(EmulatorConfig.class),
null,
null,
Clock.systemUTC(),
sleeper,
30);
return AslExecutorFixture.builder()
.ecsService(ecsService)
.ecsJsonHandler(ecsJsonHandler)
.objectMapper(objectMapper)
.sfnService(instance)
.customResourceLiveness(null)
.sleeper(sleeper)
.maxWaitSeconds(30)
.build();
}
@Test
@@ -2,20 +2,11 @@ package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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;
@@ -29,7 +20,6 @@ import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
/**
* Guards that an {@link Error} escaping a state ends the execution instead of leaving it RUNNING
@@ -72,24 +62,11 @@ class AslExecutorErrorTerminationTest {
@BeforeEach
void setUp() {
executor = new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.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),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
objectMapper,
new CrashingJsonataEvaluator(objectMapper),
mock(Instance.class), mock(EmulatorConfig.class), vertx,
mock(io.github.hectorvent.floci.core.common.CustomResourceLiveness.class));
executor = AslExecutorFixture.builder()
.objectMapper(objectMapper)
.jsonataEvaluator(new CrashingJsonataEvaluator(objectMapper))
.vertx(vertx)
.build();
}
private static final String PASS_WITH_JSONATA_OUTPUT = """
@@ -1,19 +1,11 @@
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.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
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;
@@ -50,24 +42,11 @@ class AslExecutorFailStateErrorCauseTest {
@BeforeEach
void setUp() {
executor = new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class),
mock(io.github.hectorvent.floci.services.sns.SnsJsonHandler.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),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
objectMapper,
new JsonataEvaluator(objectMapper),
mock(Instance.class), mock(EmulatorConfig.class), vertx, null);
executor = AslExecutorFixture.builder()
.objectMapper(objectMapper)
.vertx(vertx)
.customResourceLiveness(null)
.build();
}
/** The exact reproduction from issue #3255: both ErrorPath and CausePath resolve from input. */
@@ -0,0 +1,251 @@
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.core.common.CustomResourceLiveness;
import io.github.hectorvent.floci.core.common.ServiceRegistry;
import io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsService;
import io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.lambda.LambdaTargetResolver;
import io.github.hectorvent.floci.services.rdsdata.RdsDataService;
import io.github.hectorvent.floci.services.redshiftdata.RedshiftDataJsonHandler;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.scheduler.SchedulerController;
import io.github.hectorvent.floci.services.scheduler.SchedulerService;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
import io.github.hectorvent.floci.services.sqs.SqsJsonHandler;
import io.vertx.mutiny.core.Vertx;
import jakarta.enterprise.inject.Instance;
import java.time.Clock;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import java.util.function.LongSupplier;
import static org.mockito.Mockito.mock;
/**
* Builds {@link AslExecutor} for tests, naming only the collaborators a test uses.
*
* <p>Every other collaborator defaults to what the convenience constructors pass: a Mockito mock
* for each integration, the system clock, a real sleeper, {@code System.nanoTime()} for deadlines,
* no Wait cap override, AWS's 5-minute Express limit, and no RDS Data, Redshift Data, service
* registry or Lambda task authorizer. A Lambda target resolver is built over the function store
* unless a test supplies its own.
*/
final class AslExecutorFixture {
private AslExecutorFixture() {
}
static Builder builder() {
return new Builder();
}
static final class Builder {
private LambdaExecutorService lambdaExecutor = mock(LambdaExecutorService.class);
private LambdaFunctionStore functionStore = mock(LambdaFunctionStore.class);
private LambdaTargetResolver targetResolver;
private DynamoDbFacade dynamoDb = mock(DynamoDbFacade.class);
private DynamoDbJsonHandler dynamoDbJsonHandler = mock(DynamoDbJsonHandler.class);
private SqsJsonHandler sqsJsonHandler = mock(SqsJsonHandler.class);
private SnsJsonHandler snsJsonHandler = mock(SnsJsonHandler.class);
private CloudFormationQueryHandler cloudFormationHandler = mock(CloudFormationQueryHandler.class);
private Ec2Service ec2Service = mock(Ec2Service.class);
private S3Service s3Service = mock(S3Service.class);
private EcsService ecsService = mock(EcsService.class);
private EcsJsonHandler ecsJsonHandler = mock(EcsJsonHandler.class);
private EventBridgeHandler eventBridgeHandler = mock(EventBridgeHandler.class);
private SchedulerService schedulerService = mock(SchedulerService.class);
private SchedulerController schedulerController = mock(SchedulerController.class);
private RdsDataService rdsDataService;
private ObjectMapper objectMapper = new ObjectMapper();
private JsonataEvaluator jsonataEvaluator;
@SuppressWarnings("unchecked")
private Instance<StepFunctionsService> sfnService = mock(Instance.class);
private EmulatorConfig config = mock(EmulatorConfig.class);
private Vertx vertx;
private CustomResourceLiveness customResourceLiveness = mock(CustomResourceLiveness.class);
private Clock clock = Clock.systemUTC();
private AslExecutor.Sleeper sleeper = TimeUnit.NANOSECONDS::sleep;
private Integer maxWaitSeconds;
private RedshiftDataJsonHandler redshiftDataHandler;
private ServiceRegistry serviceRegistry;
private LambdaTaskAuthorizer lambdaTaskAuthorizer;
private Duration expressMaxExecutionTime;
private LongSupplier nanoTime;
private Builder() {
}
Builder lambdaExecutor(LambdaExecutorService lambdaExecutor) {
this.lambdaExecutor = lambdaExecutor;
return this;
}
Builder functionStore(LambdaFunctionStore functionStore) {
this.functionStore = functionStore;
return this;
}
Builder targetResolver(LambdaTargetResolver targetResolver) {
this.targetResolver = targetResolver;
return this;
}
Builder dynamoDb(DynamoDbFacade dynamoDb) {
this.dynamoDb = dynamoDb;
return this;
}
Builder dynamoDbJsonHandler(DynamoDbJsonHandler dynamoDbJsonHandler) {
this.dynamoDbJsonHandler = dynamoDbJsonHandler;
return this;
}
Builder sqsJsonHandler(SqsJsonHandler sqsJsonHandler) {
this.sqsJsonHandler = sqsJsonHandler;
return this;
}
Builder snsJsonHandler(SnsJsonHandler snsJsonHandler) {
this.snsJsonHandler = snsJsonHandler;
return this;
}
Builder cloudFormationHandler(CloudFormationQueryHandler cloudFormationHandler) {
this.cloudFormationHandler = cloudFormationHandler;
return this;
}
Builder ec2Service(Ec2Service ec2Service) {
this.ec2Service = ec2Service;
return this;
}
Builder s3Service(S3Service s3Service) {
this.s3Service = s3Service;
return this;
}
Builder ecsService(EcsService ecsService) {
this.ecsService = ecsService;
return this;
}
Builder ecsJsonHandler(EcsJsonHandler ecsJsonHandler) {
this.ecsJsonHandler = ecsJsonHandler;
return this;
}
Builder eventBridgeHandler(EventBridgeHandler eventBridgeHandler) {
this.eventBridgeHandler = eventBridgeHandler;
return this;
}
Builder schedulerService(SchedulerService schedulerService) {
this.schedulerService = schedulerService;
return this;
}
Builder schedulerController(SchedulerController schedulerController) {
this.schedulerController = schedulerController;
return this;
}
Builder rdsDataService(RdsDataService rdsDataService) {
this.rdsDataService = rdsDataService;
return this;
}
Builder objectMapper(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
return this;
}
Builder jsonataEvaluator(JsonataEvaluator jsonataEvaluator) {
this.jsonataEvaluator = jsonataEvaluator;
return this;
}
Builder sfnService(Instance<StepFunctionsService> sfnService) {
this.sfnService = sfnService;
return this;
}
Builder config(EmulatorConfig config) {
this.config = config;
return this;
}
Builder vertx(Vertx vertx) {
this.vertx = vertx;
return this;
}
Builder customResourceLiveness(CustomResourceLiveness customResourceLiveness) {
this.customResourceLiveness = customResourceLiveness;
return this;
}
Builder clock(Clock clock) {
this.clock = clock;
return this;
}
Builder sleeper(AslExecutor.Sleeper sleeper) {
this.sleeper = sleeper;
return this;
}
Builder maxWaitSeconds(Integer maxWaitSeconds) {
this.maxWaitSeconds = maxWaitSeconds;
return this;
}
Builder redshiftDataHandler(RedshiftDataJsonHandler redshiftDataHandler) {
this.redshiftDataHandler = redshiftDataHandler;
return this;
}
Builder serviceRegistry(ServiceRegistry serviceRegistry) {
this.serviceRegistry = serviceRegistry;
return this;
}
Builder lambdaTaskAuthorizer(LambdaTaskAuthorizer lambdaTaskAuthorizer) {
this.lambdaTaskAuthorizer = lambdaTaskAuthorizer;
return this;
}
Builder expressMaxExecutionTime(Duration expressMaxExecutionTime) {
this.expressMaxExecutionTime = expressMaxExecutionTime;
return this;
}
Builder nanoTime(LongSupplier nanoTime) {
this.nanoTime = nanoTime;
return this;
}
AslExecutor build() {
return new AslExecutor(lambdaExecutor,
targetResolver != null ? targetResolver : new LambdaTargetResolver(functionStore, null),
dynamoDb, dynamoDbJsonHandler, sqsJsonHandler, snsJsonHandler, cloudFormationHandler,
ec2Service, s3Service, ecsService, ecsJsonHandler, eventBridgeHandler,
schedulerService, schedulerController, rdsDataService, objectMapper,
jsonataEvaluator != null ? jsonataEvaluator : new JsonataEvaluator(objectMapper),
sfnService, config, vertx, customResourceLiveness, clock, sleeper, maxWaitSeconds,
redshiftDataHandler, serviceRegistry, lambdaTaskAuthorizer, expressMaxExecutionTime,
nanoTime);
}
}
}
@@ -1,14 +1,6 @@
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.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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;
@@ -187,23 +179,12 @@ class AslExecutorHistoryEventLimitTest {
void setUp() {
Instance<StepFunctionsService> sfnService = mock(Instance.class);
when(sfnService.get()).thenReturn(mock(StepFunctionsService.class));
executor = new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.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),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
objectMapper,
new JsonataEvaluator(objectMapper),
sfnService, mock(EmulatorConfig.class), vertx, null);
executor = AslExecutorFixture.builder()
.objectMapper(objectMapper)
.sfnService(sfnService)
.vertx(vertx)
.customResourceLiveness(null)
.build();
}
@Test
@@ -3,14 +3,6 @@ package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsService;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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;
@@ -25,7 +17,6 @@ import io.vertx.mutiny.core.http.HttpServer;
import io.vertx.mutiny.core.http.HttpServerRequest;
import io.vertx.mutiny.ext.web.Router;
import io.vertx.mutiny.ext.web.RoutingContext;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@@ -43,7 +34,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
@QuarkusTest
class AslExecutorHttpInvokeTest {
@@ -159,26 +149,12 @@ class AslExecutorHttpInvokeTest {
.listenAndAwait(0);
baseUrl = "http://127.0.0.1:" + server.actualPort();
executor = new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.class),
mock(io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler.class),
mock(io.github.hectorvent.floci.services.ec2.Ec2Service.class),
mock(io.github.hectorvent.floci.services.s3.S3Service.class),
mock(EcsService.class),
mock(EcsJsonHandler.class),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
objectMapper,
new JsonataEvaluator(objectMapper),
mock(Instance.class),
emulatorConfig,
vertx,
null);
executor = AslExecutorFixture.builder()
.objectMapper(objectMapper)
.config(emulatorConfig)
.vertx(vertx)
.customResourceLiveness(null)
.build();
}
private void recordRequest(final RoutingContext ctx, String body) {
@@ -22,8 +22,11 @@ class AslExecutorIntrinsicContextTest {
/** Only ObjectMapper is exercised by the path/intrinsic resolution methods under test. */
private AslExecutor newExecutor() {
return new AslExecutor(null, null, null, null, null, null, null, null, null,
null, null, null, null, null, mapper, null, null, null, null, null);
return AslExecutorFixture.builder()
.objectMapper(mapper)
.config(null)
.customResourceLiveness(null)
.build();
}
@Test
@@ -3,22 +3,9 @@ package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsService;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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 jakarta.enterprise.inject.Instance;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -29,7 +16,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
/**
* Functionality + regression coverage for the five JSONPath-mode intrinsic functions added
@@ -53,25 +39,10 @@ class AslExecutorIntrinsicFunctionsTest {
@BeforeEach
@SuppressWarnings("unchecked")
void setUp() {
executor = new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.class),
mock(CloudFormationQueryHandler.class),
mock(Ec2Service.class),
mock(S3Service.class),
mock(EcsService.class),
mock(EcsJsonHandler.class),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
mapper,
new JsonataEvaluator(mapper),
mock(Instance.class),
mock(EmulatorConfig.class),
null, null);
executor = AslExecutorFixture.builder()
.objectMapper(mapper)
.customResourceLiveness(null)
.build();
}
private void assertIntrinsicFailure(JsonNode root, String expr) {
@@ -2,21 +2,12 @@ package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
import io.github.hectorvent.floci.services.sqs.SqsJsonHandler;
import jakarta.enterprise.inject.Instance;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
/**
* A {@code $.} argument of a {@code States.*} intrinsic that matches nothing fails with
@@ -33,26 +24,10 @@ class AslExecutorIntrinsicMissingArgumentTest {
@BeforeEach
@SuppressWarnings("unchecked")
void setUp() {
executor = new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.class),
mock(io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler.class),
mock(io.github.hectorvent.floci.services.ec2.Ec2Service.class),
mock(io.github.hectorvent.floci.services.s3.S3Service.class),
mock(io.github.hectorvent.floci.services.ecs.EcsService.class),
mock(io.github.hectorvent.floci.services.ecs.EcsJsonHandler.class),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
mapper,
new JsonataEvaluator(mapper),
mock(Instance.class),
mock(EmulatorConfig.class),
null,
null);
executor = AslExecutorFixture.builder()
.objectMapper(mapper)
.customResourceLiveness(null)
.build();
}
@Test
@@ -2,26 +2,12 @@ package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsService;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
import io.github.hectorvent.floci.services.sqs.SqsJsonHandler;
import jakarta.enterprise.inject.Instance;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
/**
* Regression + functionality coverage for the {@code States.JsonMerge} intrinsic. AWS Step Functions
@@ -38,26 +24,10 @@ class AslExecutorJsonMergeTest {
@BeforeEach
@SuppressWarnings("unchecked")
void setUp() {
executor = new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.class),
mock(CloudFormationQueryHandler.class),
mock(Ec2Service.class),
mock(S3Service.class),
mock(EcsService.class),
mock(EcsJsonHandler.class),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
mapper,
new JsonataEvaluator(mapper),
mock(Instance.class),
mock(EmulatorConfig.class),
null,
null);
executor = AslExecutorFixture.builder()
.objectMapper(mapper)
.customResourceLiveness(null)
.build();
}
@Test
@@ -3,13 +3,6 @@ package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsService;
import io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler;
import io.github.hectorvent.floci.services.lambda.LambdaAliasStore;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
@@ -17,17 +10,11 @@ import io.github.hectorvent.floci.services.lambda.LambdaTargetResolver;
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.scheduler.SchedulerController;
import io.github.hectorvent.floci.services.scheduler.SchedulerService;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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;
@@ -96,24 +83,15 @@ class AslExecutorLambdaArnTargetTest {
}
private AslExecutor newExecutor(EmulatorConfig config, LambdaTaskAuthorizer authorizer) {
return new AslExecutor(
lambdaExecutor,
new LambdaTargetResolver(functionStore, mock(LambdaAliasStore.class)),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.class),
mock(CloudFormationQueryHandler.class),
mock(Ec2Service.class),
mock(S3Service.class),
mock(EcsService.class),
mock(EcsJsonHandler.class),
mock(EventBridgeHandler.class),
mock(SchedulerService.class),
mock(SchedulerController.class),
null,
objectMapper,
new JsonataEvaluator(objectMapper),
mock(Instance.class), config, vertx, null, null, null, authorizer);
return AslExecutorFixture.builder()
.lambdaExecutor(lambdaExecutor)
.targetResolver(new LambdaTargetResolver(functionStore, mock(LambdaAliasStore.class)))
.objectMapper(objectMapper)
.config(config)
.vertx(vertx)
.customResourceLiveness(null)
.lambdaTaskAuthorizer(authorizer)
.build();
}
private static LambdaFunction function(String account, String region) {
@@ -2,9 +2,6 @@ package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.lambda.LambdaAliasStore;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
@@ -13,15 +10,11 @@ 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.LambdaAlias;
import io.github.hectorvent.floci.services.lambda.model.LambdaFunction;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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;
@@ -83,24 +76,13 @@ class AslExecutorLambdaInvokeResultTest {
return new InvokeResult(200, null, output, null, "echo-request");
});
executor = new AslExecutor(
lambdaExecutor,
new LambdaTargetResolver(functionStore, aliasStore),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.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),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
null,
objectMapper,
new JsonataEvaluator(objectMapper),
mock(Instance.class), mock(EmulatorConfig.class), vertx, null);
executor = AslExecutorFixture.builder()
.lambdaExecutor(lambdaExecutor)
.targetResolver(new LambdaTargetResolver(functionStore, aliasStore))
.objectMapper(objectMapper)
.vertx(vertx)
.customResourceLiveness(null)
.build();
}
@Test
@@ -4,35 +4,21 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsService;
import io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler;
import io.github.hectorvent.floci.services.lambda.LambdaConcurrencyLimiter;
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.scheduler.SchedulerController;
import io.github.hectorvent.floci.services.scheduler.SchedulerService;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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 jakarta.enterprise.inject.Instance;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.ValueSource;
import java.nio.charset.StandardCharsets;
import java.time.Clock;
import java.util.ArrayList;
import java.util.Optional;
@@ -195,24 +181,15 @@ class AslExecutorLambdaThrottleTest {
}
private AslExecutor executor(AslExecutor.Sleeper sleeper) {
return new AslExecutor(
lambdaExecutor,
functionStore,
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.class),
mock(CloudFormationQueryHandler.class),
mock(Ec2Service.class),
mock(S3Service.class),
mock(EcsService.class),
mock(EcsJsonHandler.class),
mock(EventBridgeHandler.class),
mock(SchedulerService.class),
mock(SchedulerController.class),
objectMapper,
new JsonataEvaluator(objectMapper),
mock(Instance.class), config, null, null,
Clock.systemUTC(), sleeper, 30);
return AslExecutorFixture.builder()
.lambdaExecutor(lambdaExecutor)
.functionStore(functionStore)
.objectMapper(objectMapper)
.config(config)
.customResourceLiveness(null)
.sleeper(sleeper)
.maxWaitSeconds(30)
.build();
}
private Execution run(AslExecutor executor, String definition) {
@@ -3,13 +3,7 @@ package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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.MockedResponseStep;
@@ -17,7 +11,6 @@ import io.github.hectorvent.floci.services.stepfunctions.model.MockedTestCase;
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;
@@ -53,23 +46,13 @@ class AslExecutorMockedResponsesTest {
EmulatorConfig config = mock(EmulatorConfig.class, RETURNS_DEEP_STUBS);
when(config.services().stepfunctions().maxWaitSeconds()).thenReturn(30);
executor = new AslExecutor(
lambdaExecutor,
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.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),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
objectMapper,
new JsonataEvaluator(objectMapper),
mock(Instance.class), config, vertx, null);
executor = AslExecutorFixture.builder()
.lambdaExecutor(lambdaExecutor)
.objectMapper(objectMapper)
.config(config)
.vertx(vertx)
.customResourceLiveness(null)
.build();
}
@Test
@@ -2,20 +2,11 @@ package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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;
@@ -25,7 +16,6 @@ import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
/**
* Pins the query language a state inside a Map's {@code ItemProcessor} runs under.
@@ -57,23 +47,11 @@ class AslExecutorNestedQueryLanguageTest {
@BeforeEach
void setUp() {
executor = new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.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),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
objectMapper,
new JsonataEvaluator(objectMapper),
mock(Instance.class), mock(EmulatorConfig.class), vertx, null);
executor = AslExecutorFixture.builder()
.objectMapper(objectMapper)
.vertx(vertx)
.customResourceLiveness(null)
.build();
}
/**
@@ -3,17 +3,6 @@ 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.core.common.AwsException;
import io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsService;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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;
@@ -75,25 +64,12 @@ class AslExecutorNestedStartExecutionTest {
EmulatorConfig config = mock(EmulatorConfig.class, RETURNS_DEEP_STUBS);
when(config.services().stepfunctions().maxWaitSeconds()).thenReturn(30);
executor = new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.class),
mock(CloudFormationQueryHandler.class),
mock(Ec2Service.class),
mock(S3Service.class),
mock(EcsService.class),
mock(EcsJsonHandler.class),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
mapper,
new JsonataEvaluator(mapper),
sfnInstance,
config,
null, null);
executor = AslExecutorFixture.builder()
.objectMapper(mapper)
.sfnService(sfnInstance)
.config(config)
.customResourceLiveness(null)
.build();
}
private Execution runParent(String parentDefinition, String input) {
@@ -1,21 +1,6 @@
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.cloudformation.CloudFormationQueryHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsService;
import io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.scheduler.SchedulerController;
import io.github.hectorvent.floci.services.scheduler.SchedulerService;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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;
@@ -26,7 +11,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.time.Clock;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
@@ -231,29 +215,12 @@ class AslExecutorNestedSyncFailureTest {
private AslExecutor newExecutor() {
Instance<StepFunctionsService> instance = mock(Instance.class);
when(instance.get()).thenReturn(sfnService);
return new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.class),
mock(CloudFormationQueryHandler.class),
mock(Ec2Service.class),
mock(S3Service.class),
mock(EcsService.class),
mock(EcsJsonHandler.class),
mock(EventBridgeHandler.class),
mock(SchedulerService.class),
mock(SchedulerController.class),
objectMapper,
new JsonataEvaluator(objectMapper),
instance,
mock(EmulatorConfig.class),
null,
null,
Clock.systemUTC(),
nanos -> { },
null);
return AslExecutorFixture.builder()
.objectMapper(objectMapper)
.sfnService(instance)
.customResourceLiveness(null)
.sleeper(nanos -> { })
.build();
}
private Execution run(String mode, String catcher) {
@@ -2,21 +2,6 @@ package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsService;
import io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.scheduler.SchedulerController;
import io.github.hectorvent.floci.services.scheduler.SchedulerService;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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;
@@ -24,7 +9,6 @@ import jakarta.enterprise.inject.Instance;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.time.Clock;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -176,29 +160,12 @@ class AslExecutorNestedSyncTimeoutTest {
private AslExecutor newExecutor(AslExecutor.Sleeper sleeper) {
Instance<StepFunctionsService> instance = mock(Instance.class);
when(instance.get()).thenReturn(sfnService);
return new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.class),
mock(CloudFormationQueryHandler.class),
mock(Ec2Service.class),
mock(S3Service.class),
mock(EcsService.class),
mock(EcsJsonHandler.class),
mock(EventBridgeHandler.class),
mock(SchedulerService.class),
mock(SchedulerController.class),
objectMapper,
new JsonataEvaluator(objectMapper),
instance,
mock(EmulatorConfig.class),
null,
null,
Clock.systemUTC(),
sleeper,
null);
return AslExecutorFixture.builder()
.objectMapper(objectMapper)
.sfnService(instance)
.customResourceLiveness(null)
.sleeper(sleeper)
.build();
}
private Execution run(AslExecutor executor, String mode, int timeoutSeconds, boolean catchTimeout) {
@@ -1,21 +1,6 @@
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.cloudformation.CloudFormationQueryHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsService;
import io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.scheduler.SchedulerController;
import io.github.hectorvent.floci.services.scheduler.SchedulerService;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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;
@@ -24,7 +9,6 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import java.time.Clock;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -414,29 +398,13 @@ class AslExecutorParallelCutTest {
private AslExecutor newExecutor(AslExecutor.Sleeper sleeper) {
Instance<StepFunctionsService> instance = mock(Instance.class);
when(instance.get()).thenReturn(sfnService);
return new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.class),
mock(CloudFormationQueryHandler.class),
mock(Ec2Service.class),
mock(S3Service.class),
mock(EcsService.class),
mock(EcsJsonHandler.class),
mock(EventBridgeHandler.class),
mock(SchedulerService.class),
mock(SchedulerController.class),
objectMapper,
new JsonataEvaluator(objectMapper),
instance,
mock(EmulatorConfig.class),
null,
null,
Clock.systemUTC(),
sleeper,
30);
return AslExecutorFixture.builder()
.objectMapper(objectMapper)
.sfnService(instance)
.customResourceLiveness(null)
.sleeper(sleeper)
.maxWaitSeconds(30)
.build();
}
private Execution run(String parallelState, int waitingBranches, int executionTimeoutSeconds) {
@@ -2,14 +2,6 @@ package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
import io.github.hectorvent.floci.services.sqs.SqsJsonHandler;
import jakarta.enterprise.inject.Instance;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -17,7 +9,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
/**
* Unit coverage for the JSONPath/intrinsic features DPS's provisioning state machine relies on:
@@ -32,26 +23,10 @@ class AslExecutorPathIntrinsicsTest {
@BeforeEach
@SuppressWarnings("unchecked")
void setUp() {
executor = new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.class),
mock(io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler.class),
mock(io.github.hectorvent.floci.services.ec2.Ec2Service.class),
mock(io.github.hectorvent.floci.services.s3.S3Service.class),
mock(io.github.hectorvent.floci.services.ecs.EcsService.class),
mock(io.github.hectorvent.floci.services.ecs.EcsJsonHandler.class),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
mapper,
new JsonataEvaluator(mapper),
mock(Instance.class),
mock(EmulatorConfig.class),
null,
null);
executor = AslExecutorFixture.builder()
.objectMapper(mapper)
.customResourceLiveness(null)
.build();
}
@Test
@@ -53,9 +53,13 @@ class AslExecutorRedshiftDataDisabledTest {
RedshiftDataService service = mock(RedshiftDataService.class);
when(service.listStatements(any())).thenReturn(objectMapper.createObjectNode());
RedshiftDataJsonHandler handler = spy(new RedshiftDataJsonHandler(service));
AslExecutor executor = new AslExecutor(null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, objectMapper,
new JsonataEvaluator(objectMapper), null, config, null, null, handler, serviceRegistry, null);
AslExecutor executor = AslExecutorFixture.builder()
.objectMapper(objectMapper)
.config(config)
.customResourceLiveness(null)
.redshiftDataHandler(handler)
.serviceRegistry(serviceRegistry)
.build();
StateMachine stateMachine = new StateMachine();
stateMachine.setStateMachineArn("arn:aws:states:us-east-1:000000000000:stateMachine:disabled-data");
@@ -1,29 +1,15 @@
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.cloudformation.CloudFormationQueryHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsService;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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 jakarta.enterprise.inject.Instance;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
/**
* End-to-end coverage for the ResultPath fix: a non-applicable ResultPath fails the execution with
@@ -43,16 +29,10 @@ class AslExecutorResultPathTest {
@BeforeEach
@SuppressWarnings("unchecked")
void setUp() {
executor = new AslExecutor(
mock(LambdaExecutorService.class), mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class), mock(DynamoDbJsonHandler.class), mock(SqsJsonHandler.class), mock(SnsJsonHandler.class),
mock(CloudFormationQueryHandler.class), mock(Ec2Service.class), mock(S3Service.class),
mock(EcsService.class), mock(EcsJsonHandler.class),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
mapper, new JsonataEvaluator(mapper),
mock(Instance.class), mock(EmulatorConfig.class), null, null);
executor = AslExecutorFixture.builder()
.objectMapper(mapper)
.customResourceLiveness(null)
.build();
}
private Execution run(String definition, String input) {
@@ -6,13 +6,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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;
@@ -61,26 +55,13 @@ class AslExecutorResultWriterTest {
when(sfnService.get()).thenReturn(mock(StepFunctionsService.class));
EmulatorConfig config = mock(EmulatorConfig.class);
when(config.defaultRegion()).thenReturn("us-east-1");
executor = new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.class),
mock(io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler.class),
mock(io.github.hectorvent.floci.services.ec2.Ec2Service.class),
s3Service,
mock(io.github.hectorvent.floci.services.ecs.EcsService.class),
mock(io.github.hectorvent.floci.services.ecs.EcsJsonHandler.class),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
mapper,
new JsonataEvaluator(mapper),
sfnService,
config,
null,
null);
executor = AslExecutorFixture.builder()
.s3Service(s3Service)
.objectMapper(mapper)
.sfnService(sfnService)
.config(config)
.customResourceLiveness(null)
.build();
sm = new StateMachine();
sm.setStateMachineArn("arn:aws:states:us-east-1:000000000000:stateMachine:orderProcessing");
@@ -2,22 +2,16 @@ 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.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
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.sns.SnsJsonHandler;
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;
@@ -74,23 +68,14 @@ class AslExecutorRetryTest {
when(servicesConfig.stepfunctions()).thenReturn(stepFunctionsConfig);
when(stepFunctionsConfig.maxWaitSeconds()).thenReturn(30);
executor = new AslExecutor(
lambdaExecutor,
functionStore,
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.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),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
objectMapper,
new JsonataEvaluator(objectMapper),
mock(Instance.class), config, vertx, null);
executor = AslExecutorFixture.builder()
.lambdaExecutor(lambdaExecutor)
.functionStore(functionStore)
.objectMapper(objectMapper)
.config(config)
.vertx(vertx)
.customResourceLiveness(null)
.build();
}
@Test
@@ -1,23 +1,9 @@
package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsService;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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 jakarta.enterprise.inject.Instance;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -26,7 +12,6 @@ import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
class AslExecutorStatePathTest {
@@ -36,25 +21,10 @@ class AslExecutorStatePathTest {
@BeforeEach
@SuppressWarnings("unchecked")
void setUp() {
executor = new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.class),
mock(CloudFormationQueryHandler.class),
mock(Ec2Service.class),
mock(S3Service.class),
mock(EcsService.class),
mock(EcsJsonHandler.class),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
mapper,
new JsonataEvaluator(mapper),
mock(Instance.class),
mock(EmulatorConfig.class),
null, null);
executor = AslExecutorFixture.builder()
.objectMapper(mapper)
.customResourceLiveness(null)
.build();
}
@AfterEach
@@ -0,0 +1,247 @@
package io.github.hectorvent.floci.services.stepfunctions;
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.stepfunctions.model.Execution;
import io.github.hectorvent.floci.services.stepfunctions.model.HistoryEvent;
import io.github.hectorvent.floci.services.stepfunctions.model.StateMachine;
import org.junit.jupiter.api.Test;
import org.mockito.stubbing.Answer;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/**
* An Express execution, synchronous or not, is one AWS ends with States.Timeout once it has run for
* its maximum execution time. Once it has timed out it runs no further state, and the first
* outcome published, the timeout or one the execution reached in time, is the one that stands.
*
* <p>Every case runs on a test clock that Wait states and slow integrations move forward, so none
* takes real time. What the synchronous caller does once its own wait runs out is exercised by
* calling that step directly.
*/
class AslExecutorSyncTimeoutTest {
private static final Duration MAX_EXECUTION_TIME = Duration.ofSeconds(1);
private static final String FUNCTION_ARN = "arn:aws:lambda:us-east-1:000000000000:function:slow";
private static final Set<String> TERMINAL_EVENTS =
Set.of("ExecutionSucceeded", "ExecutionFailed", "ExecutionTimedOut", "ExecutionAborted");
private static final String WAIT_THEN_PASS = """
{"StartAt":"Pause","States":{
"Pause":{"Type":"Wait","Seconds":2,"Next":"After"},
"After":{"Type":"Pass","End":true}}}
""";
private final LambdaExecutorService lambdaExecutor = mock(LambdaExecutorService.class);
private final LambdaFunctionStore functionStore = mock(LambdaFunctionStore.class);
private final AtomicLong testNanos = new AtomicLong();
private final AslExecutor executor = AslExecutorFixture.builder()
.lambdaExecutor(lambdaExecutor)
.functionStore(functionStore)
.maxWaitSeconds(30)
.expressMaxExecutionTime(MAX_EXECUTION_TIME)
.nanoTime(testNanos::get)
.sleeper(testNanos::addAndGet)
.build();
private final List<HistoryEvent> history = new CopyOnWriteArrayList<>();
@Test
void executionPastItsMaximumTimeRunsNoFurtherStateAndStaysTimedOut() {
StateMachine stateMachine = stateMachine(WAIT_THEN_PASS);
Execution execution = execution(stateMachine);
executor.executeSync(stateMachine, execution, history, (updated, events) -> {
});
assertEndedTimedOut(execution);
assertFalse(history.stream().anyMatch(event -> "PassStateEntered".equals(event.getType())),
"the state after the timeout ran");
}
@Test
void lastStateFinishingPastTheMaximumTimeStillEndsTimedOut() {
lambdaAnswers(invocation -> {
advance(Duration.ofSeconds(2));
return new InvokeResult(200, null, bytes("{}"), null, "late-success");
});
StateMachine stateMachine = stateMachine(lambdaTask());
Execution execution = execution(stateMachine);
executor.executeSync(stateMachine, execution, history, (updated, events) -> {
});
assertEndedTimedOut(execution);
}
@Test
void lastStateFailingPastTheMaximumTimeStillEndsTimedOut() {
lambdaAnswers(invocation -> {
advance(Duration.ofSeconds(2));
return new InvokeResult(200, "Unhandled",
bytes("{\"errorType\":\"Boom\",\"errorMessage\":\"late\"}"), null, "late-failure");
});
StateMachine stateMachine = stateMachine(lambdaTask());
Execution execution = execution(stateMachine);
executor.executeSync(stateMachine, execution, history, (updated, events) -> {
});
assertEndedTimedOut(execution);
}
@Test
void lastStateThrowingPastTheMaximumTimeStillEndsTimedOut() {
lambdaAnswers(invocation -> {
advance(Duration.ofSeconds(2));
throw new IllegalStateException("runtime broke after the deadline");
});
StateMachine stateMachine = stateMachine(lambdaTask());
Execution execution = execution(stateMachine);
executor.executeSync(stateMachine, execution, history, (updated, events) -> {
});
assertEndedTimedOut(execution);
}
@Test
void expressExecutionStartedAsynchronouslyEndsAtItsMaximumTime() {
StateMachine stateMachine = stateMachine(WAIT_THEN_PASS);
stateMachine.setType("EXPRESS");
Execution execution = execution(stateMachine);
executor.executeAsync(stateMachine, execution, history, (updated, events) -> {
});
awaitTerminalEvent();
assertEndedTimedOut(execution);
assertFalse(history.stream().anyMatch(event -> "PassStateEntered".equals(event.getType())),
"the state after the timeout ran");
}
@Test
void standardExecutionStartedAsynchronouslyHasNoSuchLimit() {
StateMachine stateMachine = stateMachine(WAIT_THEN_PASS);
stateMachine.setType("STANDARD");
Execution execution = execution(stateMachine);
executor.executeAsync(stateMachine, execution, history, (updated, events) -> {
});
awaitTerminalEvent();
assertEquals("SUCCEEDED", execution.getStatus());
}
@Test
void callerTimeoutLeavesAnExecutionThatAlreadyEndedAsItWas() {
Execution execution = execution(stateMachine(WAIT_THEN_PASS));
execution.setStatus("SUCCEEDED");
AtomicInteger updates = new AtomicInteger();
executor.answerTimedOutUnlessEnded(execution, history, (updated, events) -> updates.incrementAndGet());
assertEquals("SUCCEEDED", execution.getStatus());
assertEquals(0, updates.get());
}
@Test
void callerTimeoutEndsAStillRunningExecutionTimedOut() {
Execution execution = execution(stateMachine(WAIT_THEN_PASS));
AtomicInteger updates = new AtomicInteger();
executor.answerTimedOutUnlessEnded(execution, history, (updated, events) -> updates.incrementAndGet());
assertEquals("TIMED_OUT", execution.getStatus());
assertNotNull(execution.getStopDate());
assertEquals(1, updates.get());
}
@Test
void lateOutcomeAfterTheCallerWasAnsweredKeepsTheTimeout() {
lambdaAnswers(invocation -> {
advance(Duration.ofSeconds(2));
return new InvokeResult(200, null, bytes("{}"), null, "late-success");
});
StateMachine stateMachine = stateMachine(lambdaTask());
Execution execution = execution(stateMachine);
// The caller's wait ran out first; the worker's late outcome arrives after it.
executor.answerTimedOutUnlessEnded(execution, history, (updated, events) -> {
});
executor.executeSync(stateMachine, execution, history, (updated, events) -> {
});
assertEndedTimedOut(execution);
}
private void advance(Duration duration) {
testNanos.addAndGet(duration.toNanos());
}
private void lambdaAnswers(Answer<InvokeResult> answer) {
LambdaFunction function = new LambdaFunction();
function.setFunctionName("slow");
function.setFunctionArn(FUNCTION_ARN);
when(functionStore.get("us-east-1", "slow")).thenReturn(Optional.of(function));
when(lambdaExecutor.invoke(eq(function), any(byte[].class), eq(InvocationType.RequestResponse)))
.thenAnswer(answer);
}
private void awaitTerminalEvent() {
await().atMost(Duration.ofSeconds(10))
.until(() -> history.stream().anyMatch(event -> TERMINAL_EVENTS.contains(event.getType())));
}
private void assertEndedTimedOut(Execution execution) {
assertEquals("TIMED_OUT", execution.getStatus());
assertEquals("ExecutionTimedOut", history.getLast().getType());
}
private static String lambdaTask() {
return """
{"StartAt":"Slow","States":{"Slow":{"Type":"Task","Resource":"%s","End":true}}}
""".formatted(FUNCTION_ARN);
}
private static byte[] bytes(String text) {
return text.getBytes(StandardCharsets.UTF_8);
}
private static StateMachine stateMachine(String definition) {
StateMachine stateMachine = new StateMachine();
stateMachine.setName("sync-timeout-test");
stateMachine.setStateMachineArn(
"arn:aws:states:us-east-1:000000000000:stateMachine:sync-timeout-test");
stateMachine.setDefinition(definition);
return stateMachine;
}
private static Execution execution(StateMachine stateMachine) {
Execution execution = new Execution();
execution.setName("sync-timeout-exec");
execution.setExecutionArn(
"arn:aws:states:us-east-1:000000000000:execution:sync-timeout-test:sync-timeout-exec");
execution.setStateMachineArn(stateMachine.getStateMachineArn());
execution.setInput("{}");
execution.setStatus("RUNNING");
return execution;
}
}
@@ -5,7 +5,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.dynamodb.backend.RecordingDynamoDbBackend;
import io.github.hectorvent.floci.services.dynamodb.backend.RecordingDynamoDbBackend.Invocation;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
@@ -13,9 +12,6 @@ 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.sns.SnsJsonHandler;
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.MockedResponseStep;
@@ -23,7 +19,6 @@ import io.github.hectorvent.floci.services.stepfunctions.model.MockedTestCase;
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;
@@ -77,24 +72,14 @@ class AslExecutorTaskHistoryEventsTest {
EmulatorConfig config = mock(EmulatorConfig.class, RETURNS_DEEP_STUBS);
when(config.services().stepfunctions().maxWaitSeconds()).thenReturn(30);
return new AslExecutor(
lambdaExecutor,
functionStore,
dynamoDb,
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.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),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
objectMapper,
new JsonataEvaluator(objectMapper),
mock(Instance.class), config, vertx,
mock(io.github.hectorvent.floci.core.common.CustomResourceLiveness.class));
return AslExecutorFixture.builder()
.lambdaExecutor(lambdaExecutor)
.functionStore(functionStore)
.dynamoDb(dynamoDb)
.objectMapper(objectMapper)
.config(config)
.vertx(vertx)
.build();
}
/**
@@ -1,20 +1,11 @@
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.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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;
@@ -24,7 +15,6 @@ import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.mock;
/**
* Guards the terminal metadata written on the outer catch in {@code doExecute}, the path that
@@ -50,23 +40,11 @@ class AslExecutorTerminalStateTest {
@BeforeEach
void setUp() {
executor = new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class), mock(SnsJsonHandler.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),
mock(io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerService.class),
mock(io.github.hectorvent.floci.services.scheduler.SchedulerController.class),
objectMapper,
new JsonataEvaluator(objectMapper),
mock(Instance.class), mock(EmulatorConfig.class), vertx, null);
executor = AslExecutorFixture.builder()
.objectMapper(objectMapper)
.vertx(vertx)
.customResourceLiveness(null)
.build();
}
@Test
@@ -22,8 +22,11 @@ class AslExecutorUnresolvableJsonPathTest {
private final ObjectMapper mapper = new ObjectMapper();
private AslExecutor newExecutor() {
return new AslExecutor(null, null, null, null, null, null, null, null, null,
null, null, null, null, null, mapper, null, null, null, null, null);
return AslExecutorFixture.builder()
.objectMapper(mapper)
.config(null)
.customResourceLiveness(null)
.build();
}
@Test
@@ -1,26 +1,9 @@
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.core.common.CustomResourceLiveness;
import io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbFacade;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsService;
import io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.scheduler.SchedulerController;
import io.github.hectorvent.floci.services.scheduler.SchedulerService;
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
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 jakarta.enterprise.inject.Instance;
import org.junit.jupiter.api.Test;
import java.time.Clock;
@@ -32,7 +15,6 @@ import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
/**
* Wait states must honor {@code Seconds}, {@code SecondsPath}, {@code Timestamp}, and
@@ -197,30 +179,12 @@ class AslExecutorWaitStateTest {
private static AslExecutor newExecutor(RecordingSleeper sleeper, int maxWaitSeconds) {
ObjectMapper objectMapper = new ObjectMapper();
return new AslExecutor(
mock(LambdaExecutorService.class),
mock(LambdaFunctionStore.class),
mock(DynamoDbFacade.class),
mock(DynamoDbJsonHandler.class),
mock(SqsJsonHandler.class),
mock(SnsJsonHandler.class),
mock(CloudFormationQueryHandler.class),
mock(Ec2Service.class),
mock(S3Service.class),
mock(EcsService.class),
mock(EcsJsonHandler.class),
mock(EventBridgeHandler.class),
mock(SchedulerService.class),
mock(SchedulerController.class),
objectMapper,
new JsonataEvaluator(objectMapper),
mock(Instance.class),
mock(EmulatorConfig.class),
null,
mock(CustomResourceLiveness.class),
Clock.fixed(NOW, ZoneOffset.UTC),
sleeper,
maxWaitSeconds);
return AslExecutorFixture.builder()
.objectMapper(objectMapper)
.clock(Clock.fixed(NOW, ZoneOffset.UTC))
.sleeper(sleeper)
.maxWaitSeconds(maxWaitSeconds)
.build();
}
private static Execution run(AslExecutor executor, String definition, String input) {