Light, fluffy, and always free - The AWS Local Emulator alternative
fix(codepipeline): stop superseded workers at stage boundaries (#5723)
Daniël van Ziel74124690b8f3
diff --git a/docs/services/codepipeline.md b/docs/services/codepipeline.mdindex 4db6b6a34b..ce177529f4 100644--- a/docs/services/codepipeline.md+++ b/docs/services/codepipeline.md@@ -25,6 +25,11 @@ Stages execute in declaration order. Actions with the same `runOrder` execute inA `QUEUED` or `PARALLEL` pipeline holds at most 50 active executions, as on AWS;`StartPipelineExecution` beyond that returns `ConcurrentPipelineExecutionsLimitExceededException`.+In `SUPERSEDED` mode, a newer execution supersedes an older execution waiting at the same stage+transition only when it catches up to that transition, not when it starts. If the newer execution+fails before reaching that transition, the older execution can continue when the transition is enabled.+Enabling the transition lets the newer execution proceed. Already-running stages are not interrupted.+S3 source actions poll for source changes by default, matching AWS when `PollForSourceChanges` isomitted or set to `true`. Floci establishes a baseline for the configured object and starts one newexecution when its version ID or ETag changes, recording `PollForSourceChanges` as the execution@@ -108,6 +113,7 @@ the approval token, `expires` as an ISO-8601 timestamp, `consoleLink`, `approval| `FLOCI_STORAGE_SERVICES_CODEPIPELINE_MODE` | global mode | Overrides CodePipeline storage mode || `FLOCI_STORAGE_SERVICES_CODEPIPELINE_FLUSH_INTERVAL_MS` | `5000` | Hybrid storage flush interval || `FLOCI_SERVICES_CODEPIPELINE_SOURCE_POLL_INTERVAL_MS` | `500` | How often (ms) S3 sources are polled for a new object revision |+| `FLOCI_SERVICES_CODEPIPELINE_WORKER_POLL_INTERVAL_MS` | `100` | How often (ms) execution workers check for progress, independently of S3 source polling |## Examplediff --git a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.javaindex 853bec0f63..2ba42ec79c 100644--- a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java+++ b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java@@ -1334,6 +1334,10 @@ public interface EmulatorConfig {/** How often, in milliseconds, S3 sources are polled for a new object revision. */@WithDefault("500")long sourcePollIntervalMs();++ /** How often, in milliseconds, execution workers check for progress. */+ @WithDefault("100")+ long workerPollIntervalMs();}interface SsmServiceConfig {diff --git a/src/main/java/io/github/hectorvent/floci/services/codepipeline/CodePipelineService.java b/src/main/java/io/github/hectorvent/floci/services/codepipeline/CodePipelineService.javaindex cee4b9fadc..7607ed0c5c 100644--- a/src/main/java/io/github/hectorvent/floci/services/codepipeline/CodePipelineService.java+++ b/src/main/java/io/github/hectorvent/floci/services/codepipeline/CodePipelineService.java@@ -80,7 +80,7 @@ public class CodePipelineService {private static final String DEFAULT_EXECUTION_MODE = "SUPERSEDED";private static final String DEFAULT_PIPELINE_TYPE = "V1";private static final int MAX_ACTIVE_EXECUTIONS = 50;- private static final long POLL_INTERVAL_MS = 100L;+ private static final long DEFAULT_WORKER_POLL_INTERVAL_MS = 100L;private static final String SOURCE_POLL_TYPE = "source-poll";private static final String MISSING_SOURCE_REVISION = "missing";private static final long MAX_ARCHIVE_BYTES = 128L << 20;@@ -127,6 +127,7 @@ public class CodePipelineService {// on sibling actions. Retries check this set so they never overlap a runner that has not finished.final Set<String> activeRuns = ConcurrentHashMap.newKeySet();private final long sourcePollIntervalMs;+ private long workerPollIntervalMs = DEFAULT_WORKER_POLL_INTERVAL_MS;// Test hooks, set only through the package-private constructor: a shortened wait, and a probe// for the gap before the override timeout cleanup.private final long runFinishWaitNanos;@@ -169,6 +170,7 @@ public class CodePipelineService {eventPublisher,resolveSourcePollInterval(config.services().codepipeline().sourcePollIntervalMs()),DEFAULT_RUN_FINISH_WAIT_NANOS, () -> { });+ this.workerPollIntervalMs = config.services().codepipeline().workerPollIntervalMs();}/**@@ -277,6 +279,7 @@ public class CodePipelineService {execution.setStatusSummary("Pipeline execution resumed after restart.");execution.setStopRequested(false);execution.setAbandon(false);+ execution.setWaitingStage(null);execution.setActionExecutions(new ArrayList<>());execution.setStageExecutionStatuses(new LinkedHashMap<>());putExecution(execution);@@ -598,7 +601,6 @@ public class CodePipelineService {throw new AwsException("ConcurrentPipelineExecutionsLimitExceededException","The pipeline has reached the limit for concurrent pipeline executions", 400);}- applyExecutionMode(execution);eventPublisher.pipelineStateChange(execution, "STARTED");try {executor.submit(() -> runExecution(pipeline, execution));@@ -614,14 +616,15 @@ public class CodePipelineService {}private boolean persistExecutionIfSlotAvailable(CodePipelineExecution execution) {- if (!List.of("QUEUED", "PARALLEL").contains(execution.getExecutionMode())) {- putExecution(execution);- return true;- }return startLocks.withLock(lockKey(execution), () -> {- if (activeExecutionCount(execution) >= MAX_ACTIVE_EXECUTIONS) {+ if (List.of("QUEUED", "PARALLEL").contains(execution.getExecutionMode())+ && activeExecutionCount(execution) >= MAX_ACTIVE_EXECUTIONS) {return false;}+ long lastOrdinal = executions(execution.getAccountId(), execution.getRegion(), execution.getPipelineName())+ .stream().map(CodePipelineExecution::getAdmissionOrdinal)+ .filter(Objects::nonNull).mapToLong(Long::longValue).max().orElse(0L);+ execution.setAdmissionOrdinal(Math.incrementExact(lastOrdinal));putExecution(execution);return true;});@@ -1050,7 +1053,6 @@ public class CodePipelineService {if (!persistExecutionIfSlotAvailable(rollback)) {throw pipelineBusy();}- applyExecutionMode(rollback);eventPublisher.pipelineStateChange(rollback, "STARTED");try {executor.submit(() -> runExecution(pipeline, rollback));@@ -1527,11 +1529,7 @@ public class CodePipelineService {try {runStagesFrom(pipeline, execution, 0, includeStagesFor(pipeline, execution));} catch (Exception e) {- if (execution.getCurrentStage() != null) {- execution.getStageExecutionStatuses().put(execution.getCurrentStage(), "Failed");- }- execution.setStatus("Failed");- execution.setStatusSummary(e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage());+ failExecutionRun(execution, e);LOG.errorf(e, "CodePipeline execution %s failed", execution.getPipelineExecutionId());} finally {finishExecutionRun(execution);@@ -1564,17 +1562,27 @@ public class CodePipelineService {}runStagesFrom(pipeline, execution, stageIndex + 1, includeStagesFor(pipeline, execution));} catch (Exception e) {- if (execution.getCurrentStage() != null) {- execution.getStageExecutionStatuses().put(execution.getCurrentStage(), "Failed");- }- execution.setStatus("Failed");- execution.setStatusSummary(e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage());+ failExecutionRun(execution, e);LOG.errorf(e, "CodePipeline retry for execution %s failed", execution.getPipelineExecutionId());} finally {finishExecutionRun(execution);}}+ private void failExecutionRun(CodePipelineExecution execution, Exception exception) {+ synchronized (execution) {+ execution.setWaitingStage(null);+ if (!isTerminal(execution.getStatus())) {+ if (execution.getCurrentStage() != null) {+ execution.getStageExecutionStatuses().put(execution.getCurrentStage(), "Failed");+ }+ execution.setStatus("Failed");+ execution.setStatusSummary(exception.getMessage() == null+ ? exception.getClass().getSimpleName() : exception.getMessage());+ }+ }+ }+private void runStagesFrom(CodePipelinePipeline pipeline, CodePipelineExecution execution, int startIndex,Set<String> includeStages) throws InterruptedException {JsonNode stages = pipeline.getDeclaration().path("stages");@@ -1585,15 +1593,19 @@ public class CodePipelineService {continue;}waitForTransition(pipeline, execution, stageName);- if (finishIfStopped(execution)) {+ if (isTerminal(execution.getStatus()) || finishIfStopped(execution)) {return;}if (!runStageInRun(pipeline, execution, stage, "ALL_ACTIONS", Map.of())) {return;}}- execution.setStatus("Succeeded");- execution.setStatusSummary("Pipeline execution succeeded.");+ synchronized (execution) {+ if (!isTerminal(execution.getStatus())) {+ execution.setStatus("Succeeded");+ execution.setStatusSummary("Pipeline execution succeeded.");+ }+ }}/**@@ -1605,10 +1617,18 @@ public class CodePipelineService {private boolean runStageInRun(CodePipelinePipeline pipeline, CodePipelineExecution execution, JsonNode stage,String retryMode, Map<String, String> previousStatuses) {String stageName = stage.path("name").asText();- execution.setCurrentStage(stageName);- execution.getStageExecutionStatuses().put(stageName, "InProgress");- execution.setLastUpdateTime(now());- putExecution(execution);+ synchronized (execution) {+ // Wait clearing and stage entry share the supersession monitor: a newer arrival+ // either supersedes this waiter first, or sees an active stage and leaves it alone.+ execution.setWaitingStage(null);+ if (isTerminal(execution.getStatus())) {+ return false;+ }+ execution.setCurrentStage(stageName);+ execution.getStageExecutionStatuses().put(stageName, "InProgress");+ execution.setLastUpdateTime(now());+ putExecution(execution);+ }// Evaluated before STARTED is published: AWS documents no skipped-stage event, so a stage// skipped by its beforeEntry condition emits no stage events at all.@@ -1811,7 +1831,10 @@ public class CodePipelineService {private void finishExecutionRun(CodePipelineExecution execution) {startLocks.withLock(lockKey(execution), () -> {try {- execution.setCurrentStage(null);+ synchronized (execution) {+ execution.setWaitingStage(null);+ execution.setCurrentStage(null);+ }execution.setLastUpdateTime(now());putExecution(execution);boolean pipelineDeleted = pipelineStore.getForAccount(execution.getAccountId(),@@ -2329,7 +2352,7 @@ public class CodePipelineService {if (abandonExternalActionIfRequested(execution, state)) {return;}- TimeUnit.MILLISECONDS.sleep(POLL_INTERVAL_MS);+ TimeUnit.MILLISECONDS.sleep(workerPollIntervalMs);build = codeBuildService.getBuild(execution.getRegion(), execution.getAccountId(), build.getId());}if (abandonExternalActionIfRequested(execution, state)) {@@ -2362,7 +2385,7 @@ public class CodePipelineService {if (abandonExternalActionIfRequested(execution, state)) {return;}- TimeUnit.MILLISECONDS.sleep(POLL_INTERVAL_MS);+ TimeUnit.MILLISECONDS.sleep(workerPollIntervalMs);deployment = codeDeployService.getDeployment(execution.getRegion(), deploymentId);}if (abandonExternalActionIfRequested(execution, state)) {@@ -2432,7 +2455,7 @@ public class CodePipelineService {now() + TimeUnit.DAYS.toSeconds(7));}while ("InProgress".equals(state.getStatus()) && !execution.isStopRequested()) {- TimeUnit.MILLISECONDS.sleep(POLL_INTERVAL_MS);+ TimeUnit.MILLISECONDS.sleep(workerPollIntervalMs);}if (execution.isStopRequested()) {state.setStatus(execution.isAbandon() ? "Abandoned" : "Stopped");@@ -2487,34 +2510,69 @@ public class CodePipelineService {}throw new AwsException("ActionExecutionFailed", message, 400);}- TimeUnit.MILLISECONDS.sleep(POLL_INTERVAL_MS);+ TimeUnit.MILLISECONDS.sleep(workerPollIntervalMs);}state.setStatus("Abandoned");state.setSummary("Action abandoned.");}- private void applyExecutionMode(CodePipelineExecution execution) {- if (!"SUPERSEDED".equals(execution.getExecutionMode())) {+ private void supersedeOlderWaiters(CodePipelineExecution execution, String stageName) {+ if (!"SUPERSEDED".equals(execution.getExecutionMode())+ || !"InProgress".equals(execution.getStatus()) || execution.getStartTime() == null) {return;}+ // Do not hold the arriving execution's monitor while acquiring another execution's monitor.executions(execution.getAccountId(), execution.getRegion(), execution.getPipelineName()).stream()- .filter(e -> !e.getPipelineExecutionId().equals(execution.getPipelineExecutionId()))- .filter(e -> "InProgress".equals(e.getStatus()) && e.getCurrentStage() == null)+ .filter(e -> isOlderExecution(e, execution)).forEach(e -> {- e.setStatus("Superseded");- e.setStatusSummary("Superseded by " + execution.getPipelineExecutionId());- e.setLastUpdateTime(now());- putExecution(e);+ synchronized (e) {+ if ("SUPERSEDED".equals(e.getExecutionMode())+ && "InProgress".equals(e.getStatus()) && e.getCurrentStage() == null+ && stageName.equals(e.getWaitingStage())) {+ e.setStatus("Superseded");+ e.setWaitingStage(null);+ e.setStatusSummary("Superseded by " + execution.getPipelineExecutionId());+ e.setLastUpdateTime(now());+ putExecution(e);+ }+ }});}- private void waitForTransition(CodePipelinePipeline pipeline, CodePipelineExecution execution,+ private boolean isOlderExecution(CodePipelineExecution candidate, CodePipelineExecution execution) {+ if (candidate.getStartTime() == null || execution.getStartTime() == null) {+ return false;+ }+ int timeOrder = Double.compare(candidate.getStartTime(), execution.getStartTime());+ if (timeOrder != 0) {+ return timeOrder < 0;+ }+ // Legacy equal-time executions have no reliable ordering. Do not guess from UUIDs or+ // treat equality as older: either could otherwise supersede the other on worker arrival.+ return candidate.getAdmissionOrdinal() != null && execution.getAdmissionOrdinal() != null+ && candidate.getAdmissionOrdinal() < execution.getAdmissionOrdinal();+ }++ void waitForTransition(CodePipelinePipeline pipeline, CodePipelineExecution execution,String stageName) throws InterruptedException {- while (!pipeline.getTransitions().getOrDefault(stageName, enabledTransition()).isEnabled()) {- if (execution.isStopRequested()) {+ while (true) {+ boolean enabled = pipeline.getTransitions().getOrDefault(stageName, enabledTransition()).isEnabled();+ synchronized (execution) {+ if (isTerminal(execution.getStatus()) || execution.isStopRequested()) {+ execution.setWaitingStage(null);+ return;+ }+ if (!enabled && !stageName.equals(execution.getWaitingStage())) {+ execution.setWaitingStage(stageName);+ putExecution(execution);+ }+ }+ // Arrival matters even when enabled: an older worker may still be polling its wait.+ supersedeOlderWaiters(execution, stageName);+ if (enabled) {return;}- TimeUnit.MILLISECONDS.sleep(POLL_INTERVAL_MS);+ TimeUnit.MILLISECONDS.sleep(workerPollIntervalMs);pipeline = requirePipeline(execution.getAccountId(), execution.getRegion(), execution.getPipelineName());}}@@ -2754,7 +2812,8 @@ public class CodePipelineService {node = mapper.valueToTree(execution);}node.remove(List.of("accountId", "region", "startTime", "lastUpdateTime",- "sourceRevisions", "sourceRevisionOverrides", "actionExecutions", "currentStage",+ "sourceRevisions", "sourceRevisionOverrides", "actionExecutions", "currentStage", "waitingStage",+ "admissionOrdinal","stopRequested", "abandon", "rollbackTargetPipelineExecutionId", "rollbackStageName","stageExecutionStatuses", "artifactsReleased", "ruleExecutions", "conditionOverrides"));if (execution.getRollbackTargetPipelineExecutionId() != null) {diff --git a/src/main/java/io/github/hectorvent/floci/services/codepipeline/model/CodePipelineExecution.java b/src/main/java/io/github/hectorvent/floci/services/codepipeline/model/CodePipelineExecution.javaindex 3909a1dc99..6c0b530d42 100644--- a/src/main/java/io/github/hectorvent/floci/services/codepipeline/model/CodePipelineExecution.java+++ b/src/main/java/io/github/hectorvent/floci/services/codepipeline/model/CodePipelineExecution.java@@ -19,11 +19,12 @@ public class CodePipelineExecution {private String pipelineExecutionId;private String pipelineName;private Integer pipelineVersion;- private String status;+ private volatile String status;private String statusSummary;private String executionMode;private String executionType;private Double startTime;+ private Long admissionOrdinal;private Double lastUpdateTime;private List<Map<String, Object>> artifactRevisions = new ArrayList<>();private List<Map<String, Object>> sourceRevisions = new ArrayList<>();@@ -32,7 +33,8 @@ public class CodePipelineExecution {private Map<String, String> trigger = new LinkedHashMap<>();private List<ActionExecution> actionExecutions = new ArrayList<>();private Map<String, String> stageExecutionStatuses = new LinkedHashMap<>();- private String currentStage;+ private volatile String currentStage;+ private volatile String waitingStage;private volatile boolean stopRequested;private volatile boolean abandon;private volatile boolean artifactsReleased;@@ -122,6 +124,14 @@ public class CodePipelineExecution {this.startTime = startTime;}+ public Long getAdmissionOrdinal() {+ return admissionOrdinal;+ }++ public void setAdmissionOrdinal(Long admissionOrdinal) {+ this.admissionOrdinal = admissionOrdinal;+ }+public Double getLastUpdateTime() {return lastUpdateTime;}@@ -195,6 +205,14 @@ public class CodePipelineExecution {this.currentStage = currentStage;}+ public String getWaitingStage() {+ return waitingStage;+ }++ public void setWaitingStage(String waitingStage) {+ this.waitingStage = waitingStage;+ }+public boolean isStopRequested() {return stopRequested;}diff --git a/src/main/resources/application.yml b/src/main/resources/application.ymlindex b0116ea081..544ce54464 100644--- a/src/main/resources/application.yml+++ b/src/main/resources/application.yml@@ -843,6 +843,7 @@ floci:codepipeline:enabled: truesource-poll-interval-ms: 500+ worker-poll-interval-ms: ${FLOCI_SERVICES_CODEPIPELINE_WORKER_POLL_INTERVAL_MS:100}autoscaling:enabled: trueapplicationautoscaling:diff --git a/src/test/java/io/github/hectorvent/floci/services/codepipeline/CodePipelineServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/codepipeline/CodePipelineServiceTest.javaindex e9b0aded70..4a78d2479d 100644--- a/src/test/java/io/github/hectorvent/floci/services/codepipeline/CodePipelineServiceTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/codepipeline/CodePipelineServiceTest.java@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.codepipeline;import com.fasterxml.jackson.core.type.TypeReference;import com.fasterxml.jackson.databind.JsonNode;import com.fasterxml.jackson.databind.ObjectMapper;+import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;import io.github.hectorvent.floci.config.EmulatorConfig;import io.github.hectorvent.floci.core.common.AwsException;import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;@@ -11,31 +12,42 @@ import io.github.hectorvent.floci.services.codebuild.CodeBuildService;import io.github.hectorvent.floci.services.codebuild.model.Build;import io.github.hectorvent.floci.services.codedeploy.CodeDeployService;import io.github.hectorvent.floci.services.codedeploy.model.Deployment;+import io.github.hectorvent.floci.services.codepipeline.model.CodePipelineExecution;import io.github.hectorvent.floci.services.codepipeline.model.CodePipelinePipeline;+import io.github.hectorvent.floci.services.codepipeline.model.CodePipelinePipeline.TransitionState;import io.github.hectorvent.floci.services.lambda.LambdaService;import io.github.hectorvent.floci.services.s3.S3Service;import io.github.hectorvent.floci.services.s3.model.S3Object;+import io.smallrye.config.SmallRyeConfigBuilder;import org.junit.jupiter.api.Test;import java.lang.reflect.InvocationHandler;import java.lang.reflect.Method;import java.lang.reflect.Proxy;+import java.nio.file.Path;+import java.time.Duration;import java.util.Map;+import java.util.Set;import java.util.concurrent.CompletableFuture;+import java.util.concurrent.ConcurrentHashMap;import java.util.concurrent.CountDownLatch;import java.util.concurrent.TimeUnit;import java.util.concurrent.atomic.AtomicInteger;import java.util.concurrent.atomic.AtomicReference;+import static org.awaitility.Awaitility.await;import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;import static org.junit.jupiter.api.Assertions.assertEquals;import static org.junit.jupiter.api.Assertions.assertFalse;+import static org.junit.jupiter.api.Assertions.assertNull;import static org.junit.jupiter.api.Assertions.assertThrows;import static org.junit.jupiter.api.Assertions.assertTrue;import static org.mockito.ArgumentMatchers.any;import static org.mockito.ArgumentMatchers.anyString;+import static org.mockito.Mockito.doAnswer;import static org.mockito.Mockito.mock;import static org.mockito.Mockito.never;+import static org.mockito.Mockito.spy;import static org.mockito.Mockito.verify;import static org.mockito.Mockito.when;@@ -45,13 +57,64 @@ class CodePipelineServiceTest {private static final String ACCOUNT = "000000000000";private final ObjectMapper mapper = new ObjectMapper();+ private final CapturingStorageFactory storage = new CapturingStorageFactory();private final CodePipelineService service = new CodePipelineService(- new InMemoryStorageFactory(),+ storage,mapper,mock(CodeBuildService.class),mock(CodeDeployService.class),mock(LambdaService.class),- mock(S3Service.class));+ mock(S3Service.class), configWithPollInterval(500L));++ @Test+ void pollingConfigDefaultsKeepWorkerAndSourceIntervalsIndependent() {+ EmulatorConfig config = new SmallRyeConfigBuilder()+ .addDefaultInterceptors()+ .withMapping(EmulatorConfig.class)+ .build().getConfigMapping(EmulatorConfig.class);++ assertEquals(100L, config.services().codepipeline().workerPollIntervalMs());+ assertEquals(500L, config.services().codepipeline().sourcePollIntervalMs());+ }++ @Test+ void workerPollingConfigOverrideDoesNotChangeSourcePolling() {+ EmulatorConfig config = new SmallRyeConfigBuilder()+ .addDefaultInterceptors()+ .withMapping(EmulatorConfig.class)+ .withDefaultValue("floci.services.codepipeline.worker-poll-interval-ms", "1")+ .build().getConfigMapping(EmulatorConfig.class);++ assertEquals(1L, config.services().codepipeline().workerPollIntervalMs());+ assertEquals(500L, config.services().codepipeline().sourcePollIntervalMs());+ }++ @Test+ void sourcePollingConfigOverrideDoesNotChangeWorkerPolling() {+ EmulatorConfig config = new SmallRyeConfigBuilder()+ .addDefaultInterceptors()+ .withMapping(EmulatorConfig.class)+ .withDefaultValue("floci.services.codepipeline.source-poll-interval-ms", "739")+ .build().getConfigMapping(EmulatorConfig.class);++ assertEquals(739L, config.services().codepipeline().sourcePollIntervalMs());+ assertEquals(100L, config.services().codepipeline().workerPollIntervalMs());+ }++ @Test+ void applicationYamlDeclaresIndependentProductionAndTestPollingIntervals() throws Exception {+ YAMLMapper yaml = new YAMLMapper();+ JsonNode production = yaml.readTree(Path.of("src/main/resources/application.yml").toFile())+ .path("floci").path("services").path("codepipeline");+ JsonNode test = yaml.readTree(Path.of("src/test/resources/application.yml").toFile())+ .path("floci").path("services").path("codepipeline");++ assertEquals("${FLOCI_SERVICES_CODEPIPELINE_WORKER_POLL_INTERVAL_MS:100}",+ production.path("worker-poll-interval-ms").asText());+ assertEquals(1L, test.path("worker-poll-interval-ms").asLong());+ assertEquals(500L, production.path("source-poll-interval-ms").asLong());+ assertEquals(100L, test.path("source-poll-interval-ms").asLong());+ }/*** The configured interval reaches {@code scheduleWithFixedDelay}, which rejects a non-positive@@ -59,7 +122,7 @@ class CodePipelineServiceTest {* would leave CodePipeline unavailable rather than merely mis-scheduled.*/@Test- void nonPositiveConfiguredPollInterval_doesNotPreventStartup() {+ void nonPositiveConfiguredPollInterval_doesNotPreventStartup() throws Exception {for (long interval : new long[] {0L, -1L, Long.MIN_VALUE}) {CodePipelineService configured = new CodePipelineService(new InMemoryStorageFactory(),@@ -79,7 +142,7 @@ class CodePipelineServiceTest {}/**- * The guard above is unreachable while the constructor reads only the one key, so this is what+ * The guard below is unreachable while the constructor reads only the answered keys, so this is what* keeps the message it produces from rotting. {@code enabled()} returns a primitive and is not* in the answers map, which is exactly the shape that used to fail as "not an interface".*/@@ -95,17 +158,16 @@ class CodePipelineServiceTest {}/**- * Minimal {@link EmulatorConfig} view: the constructor reads only the source poll interval, so- * a proxy answering that avoids standing up the Quarkus config container.+ * Minimal {@link EmulatorConfig} view answering both polling intervals without standing up the+ * Quarkus config container.** <p>Anything not in the answers map is assumed to be a further config view and is proxied in- * turn. That assumption holds only while the constructor reads exactly one key. If a second read- * lands and it returns a {@code String} or a primitive there is no interface to proxy, so the+ * turn. If another read returns a {@code String} or a primitive there is no interface to proxy, so the* handler says which method it could not answer instead of letting the JDK fail further down* with "not an interface".*/private static EmulatorConfig configWithPollInterval(long intervalMs) {- Map<String, Object> answers = Map.of("sourcePollIntervalMs", intervalMs);+ Map<String, Object> answers = Map.of("sourcePollIntervalMs", intervalMs, "workerPollIntervalMs", 1L);InvocationHandler handler = new InvocationHandler() {@Override@@ -137,7 +199,7 @@ class CodePipelineServiceTest {mock(CodeBuildService.class),mock(CodeDeployService.class),mock(LambdaService.class),- mock(S3Service.class));+ mock(S3Service.class), configWithPollInterval(500L));CodePipelinePipeline pipeline = mapper.readValue("""{"accountId": "000000000000",@@ -197,7 +259,7 @@ class CodePipelineServiceTest {mock(CodeBuildService.class),mock(CodeDeployService.class),mock(LambdaService.class),- s3Service);+ s3Service, configWithPollInterval(500L));String pipelineRequest = """{"pipeline": {@@ -471,11 +533,446 @@ class CodePipelineServiceTest {return service.handle(action, mapper.readTree(body), REGION, ACCOUNT);}+ @Test+ void supersededExecutionLeavesDisabledTransitionWithoutStartingActions() throws Exception {+ String pipeline = "superseded-pipeline";+ String transition = """+ {"pipelineName":"%s","stageName":"External","transitionType":"Inbound","reason":"paused"}+ """.formatted(pipeline);+ try {+ createExternalActionPipeline(service, pipeline, """+ {"name":"Approve","actionTypeId":{+ "category":"Approval","owner":"AWS","provider":"Manual","version":"1"}}+ """);+ handle("DisableStageTransition", transition);+ String first = startExecution(service, pipeline);+ awaitWaitingStage(service, pipeline, first, "External");+ String second = startExecution(service, pipeline);+ waitForExecutionStatus(service, pipeline, first, "Superseded");+ await().pollInterval(Duration.ofMillis(1)).atMost(Duration.ofSeconds(3))+ .until(() -> !service.activeRuns.contains(ACCOUNT + ":" + first));++ handle("EnableStageTransition", transition);+ await().pollInterval(Duration.ofMillis(1)).atMost(Duration.ofSeconds(3)).untilAsserted(() ->+ assertFalse(handle("ListActionExecutions", """+ {"pipelineName":"%s","filter":{"pipelineExecutionId":"%s"}}+ """.formatted(pipeline, second)).path("actionExecutionDetails").isEmpty()));+ assertEquals("Superseded", handle("GetPipelineExecution", """+ {"pipelineName":"%s","pipelineExecutionId":"%s"}+ """.formatted(pipeline, first)).path("pipelineExecution").path("status").asText());+ assertTrue(handle("ListActionExecutions", """+ {"pipelineName":"%s","filter":{"pipelineExecutionId":"%s"}}+ """.formatted(pipeline, first)).path("actionExecutionDetails").isEmpty());+ stopExecution(service, pipeline, second, true);+ waitForExecutionStatus(service, pipeline, second, "Stopped");+ } finally {+ service.shutdown();+ }+ }++ @Test+ void enabledTransitionCatchUpOnlySupersedesOlderWaitersAtThatTransition() throws Exception {+ CapturingStorageFactory storage = new CapturingStorageFactory();+ CodePipelineService catchUpService = new CodePipelineService(storage, mapper,+ mock(CodeBuildService.class), mock(CodeDeployService.class),+ mock(LambdaService.class), mock(S3Service.class), configWithPollInterval(500L));+ String pipelineName = "enabled-catch-up";+ try {+ createExternalActionPipeline(catchUpService, pipelineName, """+ {"name":"Approve","actionTypeId":{+ "category":"Approval","owner":"AWS","provider":"Manual","version":"1"}}+ """);+ CodePipelineExecution older = waitingExecution(storage, pipelineName, "older", 1.0, "External");+ CodePipelineExecution newer = waitingExecution(storage, pipelineName, "newer", 2.0, null);+ newer.setAdmissionOrdinal(2L);+ CodePipelineExecution later = waitingExecution(storage, pipelineName, "later", 3.0, "External");+ later.setAdmissionOrdinal(4L);+ // Unsequenced legacy ties remain unordered; sequenced ties use admission order.+ CodePipelineExecution sameTime = waitingExecution(storage, pipelineName, "same-time", 2.0, "External");+ CodePipelineExecution sameTimeOlder = waitingExecution(+ storage, pipelineName, "same-time-older", 2.0, "External");+ sameTimeOlder.setAdmissionOrdinal(1L);+ CodePipelineExecution sameTimeNewer = waitingExecution(+ storage, pipelineName, "same-time-newer", 2.0, "External");+ sameTimeNewer.setAdmissionOrdinal(3L);+ CodePipelineExecution otherStage = waitingExecution(storage, pipelineName, "other-stage", 1.0, "Complete");+ CodePipelineExecution active = waitingExecution(storage, pipelineName, "active", 1.0, "External");+ active.setCurrentStage("External");+ CodePipelineExecution terminal = waitingExecution(storage, pipelineName, "terminal", 1.0, "External");+ terminal.setStatus("Failed");+ CodePipelineExecution parallel = waitingExecution(storage, pipelineName, "parallel", 1.0, "External");+ parallel.setExecutionMode("PARALLEL");++ // Exercise arrival at an enabled transition while the older execution is still marked+ // waiting (the window before its polling worker observes EnableStageTransition).+ CodePipelinePipeline pipeline = storage.pipelineStore()+ .getForAccount(ACCOUNT, REGION + ":" + pipelineName).orElseThrow();+ for (String mode : new String[] {"QUEUED", "PARALLEL"}) {+ newer.setExecutionMode(mode);+ catchUpService.waitForTransition(pipeline, newer, "External");+ assertEquals("InProgress", older.getStatus(), mode + " must not supersede waiters");+ }+ newer.setExecutionMode("SUPERSEDED");+ catchUpService.waitForTransition(pipeline, newer, "External");++ assertEquals("Superseded", older.getStatus());+ assertEquals("Superseded", sameTimeOlder.getStatus());+ assertNull(older.getWaitingStage());+ for (CodePipelineExecution untouched : new CodePipelineExecution[] {+ newer, later, sameTime, sameTimeNewer, otherStage, active, parallel}) {+ assertEquals("InProgress", untouched.getStatus(), untouched.getPipelineExecutionId());+ }+ assertEquals("Failed", terminal.getStatus());+ JsonNode response = handle(catchUpService, "GetPipelineExecution", """+ {"pipelineName":"%s","pipelineExecutionId":"later"}+ """.formatted(pipelineName));+ assertFalse(response.path("pipelineExecution").has("waitingStage"),+ "Internal waiting identity must not leak into the public execution response");+ assertFalse(response.path("pipelineExecution").has("admissionOrdinal"));+ } finally {+ catchUpService.shutdown();+ }+ }++ @Test+ void realAdmissionsPersistIncreasingOrdinalsDespiteEqualStartTimes() throws Exception {+ CapturingStorageFactory storage = new CapturingStorageFactory();+ // Force a wall-clock collision at the persistence boundary, without changing production now().+ // Both real StartPipelineExecution calls still traverse normal admission and worker startup.+ storage.fixedExecutionStartTime = 10.0;+ CodePipelineService pipelineService = new CodePipelineService(storage, mapper,+ mock(CodeBuildService.class), mock(CodeDeployService.class),+ mock(LambdaService.class), mock(S3Service.class), configWithPollInterval(500L));+ String pipeline = "ordinal-admission";+ try {+ createExternalActionPipeline(pipelineService, pipeline, """+ {"name":"Approve","actionTypeId":{+ "category":"Approval","owner":"AWS","provider":"Manual","version":"1"}}+ """);+ CodePipelineExecution persisted = waitingExecution(storage, pipeline, "persisted", 1.0, null);+ persisted.setStatus("Succeeded");+ persisted.setAdmissionOrdinal(40L);+ // A deserialized record must seed the next ordinal, just as after process restart.+ storage.executionStore.putForAccount(ACCOUNT, REGION + ":" + pipeline + ":persisted",+ mapper.readValue(mapper.writeValueAsBytes(persisted), CodePipelineExecution.class));++ String firstId = startExecution(pipelineService, pipeline);+ String secondId = startExecution(pipelineService, pipeline);+ CodePipelineExecution first = storage.executionStore+ .getForAccount(ACCOUNT, REGION + ":" + pipeline + ":" + firstId).orElseThrow();+ CodePipelineExecution second = storage.executionStore+ .getForAccount(ACCOUNT, REGION + ":" + pipeline + ":" + secondId).orElseThrow();+ assertEquals(first.getStartTime(), second.getStartTime());+ assertEquals(Long.valueOf(41L), first.getAdmissionOrdinal());+ assertEquals(Long.valueOf(42L), second.getAdmissionOrdinal());+ synchronized (second) {+ CodePipelineExecution restored = mapper.readValue(mapper.writeValueAsBytes(second),+ CodePipelineExecution.class);+ assertEquals(second.getAdmissionOrdinal(), restored.getAdmissionOrdinal());+ }++ // Observe both actual workers reaching their first action before cleanup.+ await().pollInterval(Duration.ofMillis(1)).atMost(Duration.ofSeconds(3)).untilAsserted(() -> {+ for (String id : new String[] {firstId, secondId}) {+ assertFalse(handle(pipelineService, "ListActionExecutions", """+ {"pipelineName":"%s","filter":{"pipelineExecutionId":"%s"}}+ """.formatted(pipeline, id)).path("actionExecutionDetails").isEmpty());+ }+ });+ stopExecution(pipelineService, pipeline, firstId, true);+ stopExecution(pipelineService, pipeline, secondId, true);+ waitForExecutionStatus(pipelineService, pipeline, firstId, "Stopped");+ waitForExecutionStatus(pipelineService, pipeline, secondId, "Stopped");+ } finally {+ pipelineService.shutdown();+ }+ }++ @Test+ void equalTimeReverseWorkerArrivalCannotSupersedeNewerOrMutuallySupersede() throws Exception {+ CapturingStorageFactory storage = new CapturingStorageFactory();+ CodePipelineService pipelineService = new CodePipelineService(storage, mapper,+ mock(CodeBuildService.class), mock(CodeDeployService.class),+ mock(LambdaService.class), mock(S3Service.class), configWithPollInterval(500L));+ String pipeline = "ordinal-reverse-arrival";+ try {+ createExternalActionPipeline(pipelineService, pipeline, """+ {"name":"Approve","actionTypeId":{+ "category":"Approval","owner":"AWS","provider":"Manual","version":"1"}}+ """);+ CodePipelineExecution older = waitingExecution(storage, pipeline, "older", 10.0, "External");+ older.setAdmissionOrdinal(1L);+ CodePipelineExecution newer = waitingExecution(storage, pipeline, "newer", 10.0, "External");+ newer.setAdmissionOrdinal(2L);+ CodePipelinePipeline definition = storage.pipelineStore()+ .getForAccount(ACCOUNT, REGION + ":" + pipeline).orElseThrow();++ // B has reached the transition before A's delayed worker catches up. A cannot kill B.+ pipelineService.waitForTransition(definition, older, "External");+ assertEquals("InProgress", newer.getStatus());+ assertEquals("InProgress", older.getStatus());+ // B's next observation catches the older waiter; A's subsequent observation stays terminal.+ pipelineService.waitForTransition(definition, newer, "External");+ assertEquals("Superseded", older.getStatus());+ pipelineService.waitForTransition(definition, older, "External");+ assertEquals("InProgress", newer.getStatus());+ assertEquals("Superseded", older.getStatus());+ assertNull(older.getWaitingStage());+ } finally {+ pipelineService.shutdown();+ }+ }++ @Test+ void newerExecutionFailingBuildDoesNotSupersedeOlderWaitingAtDeploy() throws Exception {+ try (CatchUpFixture fixture = new CatchUpFixture()) {+ String older = fixture.start();+ fixture.complete(fixture.job("Build", older), true);+ fixture.awaitDeployWaiters(1);+ fixture.assertAction(older, "Build", "Succeeded");+ fixture.assertNoDeploy(older);++ String newer = fixture.start();+ JsonNode newerBuild = fixture.job("Build", newer);+ fixture.complete(newerBuild, false);+ fixture.awaitStatus(newer, "Failed");+ fixture.awaitWorkerExit(newer);+ fixture.assertAction(newer, "Build", "Failed");+ fixture.assertNoDeploy(newer);+ assertEquals(1, fixture.deployWaiters.size(), "B must fail before reaching Deploy");++ assertEquals("InProgress", fixture.status(older),+ "A waiting at Deploy must survive B failing in Build");+ assertTrue(service.activeRuns.contains(ACCOUNT + ":" + older));+ fixture.enableDeploy();+ fixture.complete(fixture.job("Deploy", older), true);+ fixture.awaitStatus(older, "Succeeded");+ fixture.awaitWorkerExit(older);+ fixture.assertAction(older, "Deploy", "Succeeded");+ assertEquals("Failed", fixture.status(newer));+ }+ }++ @Test+ void olderExecutionIsSupersededOnlyWhenNewerReachesSameDisabledDeploy() throws Exception {+ try (CatchUpFixture fixture = new CatchUpFixture()) {+ String older = fixture.start();+ fixture.complete(fixture.job("Build", older), true);+ fixture.awaitDeployWaiters(1);+ fixture.assertAction(older, "Build", "Succeeded");+ fixture.assertNoDeploy(older);++ String newer = fixture.start();+ JsonNode newerBuild = fixture.job("Build", newer);+ // The job is deliberately unfinished: B's real worker is still in Build, not Deploy.+ fixture.assertAction(newer, "Build", "InProgress");+ assertEquals(1, fixture.deployWaiters.size());+ assertEquals("InProgress", fixture.status(older),+ "Starting B is not catch-up: A must remain live while B is in Build");+ assertTrue(service.activeRuns.contains(ACCOUNT + ":" + older));++ fixture.complete(newerBuild, true);+ fixture.awaitDeployWaiters(2);+ fixture.assertAction(newer, "Build", "Succeeded");+ fixture.awaitStatus(older, "Superseded");+ fixture.awaitWorkerExit(older);+ fixture.assertNoDeploy(older);+ fixture.assertNoDeploy(newer);+ assertEquals("InProgress", fixture.status(newer));++ fixture.enableDeploy();+ fixture.complete(fixture.job("Deploy", newer), true);+ fixture.awaitStatus(newer, "Succeeded");+ fixture.awaitWorkerExit(newer);+ fixture.assertAction(newer, "Deploy", "Succeeded");+ assertEquals("Superseded", fixture.status(older));+ fixture.assertNoDeploy(older);+ }+ }++ /** Custom jobs provide explicit action barriers without external services or timed sleeps. */+ private final class CatchUpFixture implements AutoCloseable {+ private static final String PIPELINE = "review-catch-up";+ private static final Duration TIMEOUT = Duration.ofSeconds(5);+ private final Set<Thread> deployWaiters = ConcurrentHashMap.newKeySet();++ private CatchUpFixture() throws Exception {+ handle("CreatePipeline", """+ {"pipeline": {+ "name":"review-catch-up", "executionMode":"SUPERSEDED",+ "roleArn":"arn:aws:iam::000000000000:role/codepipeline-role",+ "artifactStore":{"type":"S3","location":"artifacts"},+ "stages":[+ {"name":"Build","actions":[{"name":"BuildAction",+ "actionTypeId":{"category":"Build","owner":"Custom",+ "provider":"ReviewBuild","version":"1"}}]},+ {"name":"Deploy","actions":[{"name":"DeployAction",+ "actionTypeId":{"category":"Deploy","owner":"Custom",+ "provider":"ReviewDeploy","version":"1"}}]}+ ]}}+ """);+ transition("DisableStageTransition");+ CodePipelinePipeline pipeline = storage.pipelineStore()+ .getForAccount(ACCOUNT, REGION + ":" + PIPELINE).orElseThrow();+ TransitionState disabled = spy(pipeline.getTransitions().get("Deploy"));+ // Probe the actual transition read, not merely activeRuns admission or Build completion.+ // Only execution workers read this transition in this fixture (no GetPipelineState calls).+ doAnswer(invocation -> {+ deployWaiters.add(Thread.currentThread());+ return invocation.callRealMethod();+ }).when(disabled).isEnabled();+ pipeline.getTransitions().put("Deploy", disabled);+ }++ private String start() throws Exception {+ return handle("StartPipelineExecution", "{\"name\":\"" + PIPELINE + "\"}")+ .path("pipelineExecutionId").asText();+ }++ private void transition(String action) throws Exception {+ handle(action, """+ {"pipelineName":"review-catch-up","stageName":"Deploy",+ "transitionType":"Inbound","reason":"test barrier"}+ """);+ }++ private void enableDeploy() throws Exception {+ transition("EnableStageTransition");+ }++ private void awaitDeployWaiters(int count) {+ await().pollInterval(Duration.ofMillis(1)).atMost(TIMEOUT).until(() -> deployWaiters.size() == count);+ }++ private JsonNode job(String stage, String execution) {+ AtomicReference<JsonNode> found = new AtomicReference<>();+ await().pollInterval(Duration.ofMillis(1)).atMost(TIMEOUT).until(() -> {+ JsonNode response = handle("PollForJobs", """+ {"actionTypeId":{"category":"%s","owner":"Custom",+ "provider":"Review%s","version":"1"},"maxBatchSize":10}+ """.formatted(stage, stage));+ for (JsonNode job : response.path("jobs")) {+ if (execution.equals(job.path("data").path("pipelineContext")+ .path("pipelineExecutionId").asText())) {+ found.set(job);+ return true;+ }+ }+ return false;+ });+ return found.get();+ }++ private void complete(JsonNode job, boolean success) throws Exception {+ handle("AcknowledgeJob", mapper.createObjectNode().put("jobId", job.path("id").asText())+ .put("nonce", job.path("nonce").asText()).toString());+ handle(success ? "PutJobSuccessResult" : "PutJobFailureResult", """+ {"jobId":"%s","failureDetails":{"type":"JobFailed","message":"Build failed"}}+ """.formatted(job.path("id").asText()));+ }++ private String status(String execution) throws Exception {+ return handle("GetPipelineExecution", """+ {"pipelineName":"review-catch-up","pipelineExecutionId":"%s"}+ """.formatted(execution)).path("pipelineExecution").path("status").asText();+ }++ private void awaitStatus(String execution, String expected) {+ await().pollInterval(Duration.ofMillis(1)).atMost(TIMEOUT)+ .untilAsserted(() -> assertEquals(expected, status(execution)));+ }++ private void awaitWorkerExit(String execution) {+ await().pollInterval(Duration.ofMillis(1)).atMost(TIMEOUT)+ .until(() -> !service.activeRuns.contains(ACCOUNT + ":" + execution));+ }++ private JsonNode actions(String execution) throws Exception {+ return handle("ListActionExecutions", """+ {"pipelineName":"review-catch-up","filter":{"pipelineExecutionId":"%s"}}+ """.formatted(execution)).path("actionExecutionDetails");+ }++ private void assertAction(String execution, String stage, String expected) throws Exception {+ int count = 0;+ for (JsonNode action : actions(execution)) {+ if (stage.equals(action.path("stageName").asText())) {+ count++;+ assertEquals(expected, action.path("status").asText());+ }+ }+ assertEquals(1, count, "Expected exactly one " + stage + " action for " + execution);+ }++ private void assertNoDeploy(String execution) throws Exception {+ for (JsonNode action : actions(execution)) {+ assertFalse("Deploy".equals(action.path("stageName").asText()),+ "Disabled/superseded execution must not run Deploy: " + execution);+ }+ }++ @Override+ public void close() {+ service.shutdown();+ }+ }++ private CodePipelineExecution waitingExecution(CapturingStorageFactory storage, String pipeline,+ String id, double start, String stage) {+ CodePipelineExecution execution = new CodePipelineExecution();+ execution.setAccountId(ACCOUNT);+ execution.setRegion(REGION);+ execution.setPipelineName(pipeline);+ execution.setPipelineExecutionId(id);+ execution.setStartTime(start);+ execution.setStatus("InProgress");+ execution.setExecutionMode("SUPERSEDED");+ execution.setWaitingStage(stage);+ storage.executionStore.putForAccount(ACCOUNT, REGION + ":" + pipeline + ":" + id, execution);+ return execution;+ }++ private void awaitWaitingStage(CodePipelineService pipelineService, String pipeline,+ String executionId, String stage) throws Exception {+ await().pollInterval(Duration.ofMillis(1)).atMost(Duration.ofSeconds(3)).until(() -> {+ CodePipelineExecution execution = storage.executionStore+ .getForAccount(ACCOUNT, REGION + ":" + pipeline + ":" + executionId).orElseThrow();+ return stage.equals(execution.getWaitingStage())+ && pipelineService.activeRuns.contains(ACCOUNT + ":" + executionId);+ });+ }++ @Test+ void startingNewExecutionDoesNotSupersedeAnActiveStage() throws Exception {+ String pipeline = "active-stage-pipeline";+ try {+ createExternalActionPipeline(service, pipeline, """+ {"name":"Approve","actionTypeId":{+ "category":"Approval","owner":"AWS","provider":"Manual","version":"1"}}+ """);+ String first = startExecution(service, pipeline);+ await().pollInterval(Duration.ofMillis(1)).atMost(Duration.ofSeconds(3)).untilAsserted(() ->+ assertFalse(handle("ListActionExecutions", """+ {"pipelineName":"%s","filter":{"pipelineExecutionId":"%s"}}+ """.formatted(pipeline, first)).path("actionExecutionDetails").isEmpty()));+ String second = startExecution(service, pipeline);+ assertEquals("InProgress", handle("GetPipelineExecution", """+ {"pipelineName":"%s","pipelineExecutionId":"%s"}+ """.formatted(pipeline, first)).path("pipelineExecution").path("status").asText());+ stopExecution(service, pipeline, first, true);+ stopExecution(service, pipeline, second, true);+ waitForExecutionStatus(service, pipeline, first, "Stopped");+ waitForExecutionStatus(service, pipeline, second, "Stopped");+ } finally {+ service.shutdown();+ }+ }+private CodePipelineService serviceWith(CodeBuildService codeBuildService,CodeDeployService codeDeployService) {return new CodePipelineService(new InMemoryStorageFactory(), mapper, codeBuildService, codeDeployService,- mock(LambdaService.class), mock(S3Service.class));+ mock(LambdaService.class), mock(S3Service.class), configWithPollInterval(500L));}private void createExternalActionPipeline(CodePipelineService pipelineService,@@ -579,6 +1076,8 @@ class CodePipelineServiceTest {private static final class CapturingStorageFactory extends StorageFactory {private AccountAwareStorageBackend<CodePipelinePipeline> pipelineStore;+ private AccountAwareStorageBackend<CodePipelineExecution> executionStore;+ private Double fixedExecutionStartTime;private CapturingStorageFactory() {super(null, null);@@ -591,6 +1090,16 @@ class CodePipelineServiceTest {AccountAwareStorageBackend<V> store = AccountAwareStorageBackend.inMemory(ACCOUNT);if ("codepipeline-pipelines.json".equals(fileName)) {pipelineStore = (AccountAwareStorageBackend<CodePipelinePipeline>) (AccountAwareStorageBackend<?>) store;+ } else if ("codepipeline-executions.json".equals(fileName)) {+ if (fixedExecutionStartTime != null) {+ store = spy(store);+ doAnswer(invocation -> {+ CodePipelineExecution execution = invocation.getArgument(2);+ execution.setStartTime(fixedExecutionStartTime);+ return invocation.callRealMethod();+ }).when(store).putForAccount(anyString(), anyString(), any());+ }+ executionStore = (AccountAwareStorageBackend<CodePipelineExecution>) (AccountAwareStorageBackend<?>) store;}return store;}diff --git a/src/test/resources/application.yml b/src/test/resources/application.ymlindex 34c85887b8..dca4a32d2d 100644--- a/src/test/resources/application.yml+++ b/src/test/resources/application.yml@@ -405,6 +405,7 @@ floci:codepipeline:enabled: truesource-poll-interval-ms: 100 # a shorter cycle so the "did not trigger" tests wait less+ worker-poll-interval-ms: 1autoscaling:enabled: trueapplicationautoscaling: