mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
test(codepipeline): make the S3 source poll interval configurable so the negative tests wait less (#4236)
This commit is contained in:
1 parent
76cc27f2f1
commit
70df224189
7 files changed
+57
-8
No files matched your search
@@ -1232,6 +1232,10 @@ public interface EmulatorConfig {
|
||||
interface CodePipelineServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
|
||||
/** How often, in milliseconds, S3 sources are polled for a new object revision. */
|
||||
@WithDefault("500")
|
||||
long sourcePollIntervalMs();
|
||||
}
|
||||
|
||||
interface SsmServiceConfig {
|
||||
|
||||
+29
-4
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
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.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
|
||||
@@ -57,7 +58,6 @@ public class CodePipelineService {
|
||||
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 SOURCE_POLL_INTERVAL_MS = 500L;
|
||||
private static final String SOURCE_POLL_TYPE = "source-poll";
|
||||
private static final String MISSING_SOURCE_REVISION = "missing";
|
||||
|
||||
@@ -81,12 +81,36 @@ public class CodePipelineService {
|
||||
// An execution's status turns Failed as soon as one action fails, while its runner is still waiting
|
||||
// on sibling actions. Retries check this set so they never overlap a runner that has not finished.
|
||||
private final Set<String> activeRuns = ConcurrentHashMap.newKeySet();
|
||||
private final long sourcePollIntervalMs;
|
||||
|
||||
/** Matches the {@code source-poll-interval-ms} default in application.yml. */
|
||||
private static final long DEFAULT_SOURCE_POLL_INTERVAL_MS = 500L;
|
||||
|
||||
/**
|
||||
* Package-private constructor for the tests that build the service without CDI. The source
|
||||
* poll interval falls back to the configured default.
|
||||
*/
|
||||
CodePipelineService(StorageFactory storageFactory, ObjectMapper mapper,
|
||||
CodeBuildService codeBuildService, CodeDeployService codeDeployService,
|
||||
LambdaService lambdaService, S3Service s3Service) {
|
||||
this(storageFactory, mapper, codeBuildService, codeDeployService, lambdaService, s3Service,
|
||||
DEFAULT_SOURCE_POLL_INTERVAL_MS);
|
||||
}
|
||||
|
||||
@Inject
|
||||
@SuppressWarnings("unchecked")
|
||||
public CodePipelineService(StorageFactory storageFactory, ObjectMapper mapper,
|
||||
CodeBuildService codeBuildService, CodeDeployService codeDeployService,
|
||||
LambdaService lambdaService, S3Service s3Service) {
|
||||
LambdaService lambdaService, S3Service s3Service,
|
||||
EmulatorConfig config) {
|
||||
this(storageFactory, mapper, codeBuildService, codeDeployService, lambdaService, s3Service,
|
||||
config.services().codepipeline().sourcePollIntervalMs());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private CodePipelineService(StorageFactory storageFactory, ObjectMapper mapper,
|
||||
CodeBuildService codeBuildService, CodeDeployService codeDeployService,
|
||||
LambdaService lambdaService, S3Service s3Service,
|
||||
long sourcePollIntervalMs) {
|
||||
this.pipelineStore = storageFactory.create(
|
||||
"codepipeline", "codepipeline-pipelines.json", new TypeReference<Map<String, CodePipelinePipeline>>() {});
|
||||
this.executionStore = storageFactory.create(
|
||||
@@ -98,6 +122,7 @@ public class CodePipelineService {
|
||||
this.codeDeployService = codeDeployService;
|
||||
this.lambdaService = lambdaService;
|
||||
this.s3Service = s3Service;
|
||||
this.sourcePollIntervalMs = sourcePollIntervalMs;
|
||||
}
|
||||
|
||||
public JsonNode handle(String action, JsonNode request, String region, String account) {
|
||||
@@ -174,7 +199,7 @@ public class CodePipelineService {
|
||||
}
|
||||
initializePersistedSourcePollingBaselines();
|
||||
sourcePoller.scheduleWithFixedDelay(
|
||||
this::pollS3SourcesSafely, SOURCE_POLL_INTERVAL_MS, SOURCE_POLL_INTERVAL_MS, TimeUnit.MILLISECONDS);
|
||||
this::pollS3SourcesSafely, sourcePollIntervalMs, sourcePollIntervalMs, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
private void initializePersistedSourcePollingBaselines() {
|
||||
|
||||
Reference in new issue
Block a user