mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -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
+20
-4
@@ -1,9 +1,11 @@
|
||||
package io.github.hectorvent.floci.services.codepipeline;
|
||||
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.response.Response;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -34,6 +36,20 @@ class CodePipelineIntegrationTest {
|
||||
private static final String CONTENT_TYPE = "application/x-amz-json-1.1";
|
||||
private static final String TARGET = "CodePipeline_20150709.";
|
||||
|
||||
@Inject
|
||||
EmulatorConfig config;
|
||||
|
||||
/**
|
||||
* Blocks until the S3 source poller has had {@code cycles} chances to run. The assertions that
|
||||
* follow these waits are all negative ("no execution was started"), so what matters is that the
|
||||
* poller really did get its turns and declined, not that a fixed number of milliseconds passed.
|
||||
* Deriving the wait from the configured interval keeps that guarantee whatever the interval is
|
||||
* set to.
|
||||
*/
|
||||
private void awaitSourcePollCycles(int cycles) throws InterruptedException {
|
||||
Thread.sleep(config.services().codepipeline().sourcePollIntervalMs() * cycles);
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
@@ -394,7 +410,7 @@ class CodePipelineIntegrationTest {
|
||||
"""))
|
||||
.then().statusCode(200);
|
||||
|
||||
Thread.sleep(1200);
|
||||
awaitSourcePollCycles(5);
|
||||
post("ListPipelineExecutions", """
|
||||
{"pipelineName": "%s"}
|
||||
""".formatted(pipelineName))
|
||||
@@ -423,7 +439,7 @@ class CodePipelineIntegrationTest {
|
||||
.statusCode(200)
|
||||
.body(equalTo("changed artifact"));
|
||||
|
||||
Thread.sleep(1200);
|
||||
awaitSourcePollCycles(5);
|
||||
post("ListPipelineExecutions", """
|
||||
{"pipelineName": "%s"}
|
||||
""".formatted(pipelineName))
|
||||
@@ -480,7 +496,7 @@ class CodePipelineIntegrationTest {
|
||||
"""))
|
||||
.then().statusCode(200);
|
||||
|
||||
Thread.sleep(700);
|
||||
awaitSourcePollCycles(3);
|
||||
post("ListPipelineExecutions", """
|
||||
{"pipelineName": "%s"}
|
||||
""".formatted(pipelineName))
|
||||
@@ -551,7 +567,7 @@ class CodePipelineIntegrationTest {
|
||||
.then().statusCode(200);
|
||||
|
||||
putObject("codepipeline-poll-disabled-source", "source.zip", "changed artifact");
|
||||
Thread.sleep(1200);
|
||||
awaitSourcePollCycles(5);
|
||||
|
||||
post("ListPipelineExecutions", """
|
||||
{"pipelineName": "%s"}
|
||||
|
||||
Reference in new issue
Block a user