From 2d94076d3eda2ff69ed1c8107c6cc57a5972ca7b Mon Sep 17 00:00:00 2001 From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com> Date: Sun, 18 Oct 2026 10:28:14 -0400 Subject: [PATCH] test: share the sidecar profile with five more container test classes (#5931) Slice 12 of #4542. CodeArtifactPypiDockerIntegrationTest, EcsContainerManagerEphemeralVolumesDockerIntegrationTest and RedshiftSpectrumIntegrationTest each set their own floci.docker.resource-namespace, for the reason the slice 3 profiles did: keep a manager's remove-before-start away from a developer's running Floci. The Spectrum one also pinned port 17866 and floci.base-url so floci-duck could read Floci's S3. ServerlessTestProfile namespaced the ElastiCache serverless containers and mocked RDS and DocumentDB, which neither of its two classes calls. All five now use SidecarContainersProfile, which already gives a per-run namespace and a free port with a matching base URL, so CodeArtifactPypiSidecarProfile and ServerlessTestProfile go away. The PyPI class uses SidecarContainersProfile.requireDockerAndImage in place of its own copy of the image check, and counts its pypiserver containers by the shared namespace. The ECS class checks the owner label against the shared namespace and port. With a namespace per run, what a killed run leaves behind is in a namespace no later run shares, so neither a manager's remove-before-start nor the ECS volume sweep, which filters on the current owner, reaches it. The profile's sweep of abandoned namespaces now removes their volumes as well, after their containers, and a new requireDocker runs it for a class whose manager pulls its own image. The ECS, Spectrum and ElastiCache classes check for Docker through it, so the sweep runs even when one of them runs alone. Now that they share an application with the other sidecar classes, the PyPI class ends with a test that deletes the domains and repositories it created, and the Spectrum class deletes its IAM role after each test, but only when that test created it. The ECS and ElastiCache classes already removed what they made. Each class gains a javadoc paragraph saying what it gets from the profile, the ElastiCache ones also why the RDS and DocumentDB mocks are not needed, and the profile's javadoc names the new containers. --- ...astiCacheServerlessCfnIntegrationTest.java | 13 ++-- ...CodeArtifactPypiDockerIntegrationTest.java | 64 +++++++++++++++---- .../CodeArtifactPypiSidecarProfile.java | 52 --------------- ...EphemeralVolumesDockerIntegrationTest.java | 33 +++++----- .../ElastiCacheServerlessIntegrationTest.java | 18 ++++-- .../elasticache/ServerlessTestProfile.java | 13 ---- .../RedshiftSpectrumIntegrationTest.java | 44 ++++++------- .../testing/SidecarContainersProfile.java | 45 +++++++++---- 8 files changed, 139 insertions(+), 143 deletions(-) delete mode 100644 src/test/java/io/github/hectorvent/floci/services/codeartifact/CodeArtifactPypiSidecarProfile.java delete mode 100644 src/test/java/io/github/hectorvent/floci/services/elasticache/ServerlessTestProfile.java diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/ElastiCacheServerlessCfnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/ElastiCacheServerlessCfnIntegrationTest.java index 603e8a655c..d1b1649495 100644 --- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/ElastiCacheServerlessCfnIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/ElastiCacheServerlessCfnIntegrationTest.java @@ -1,14 +1,12 @@ package io.github.hectorvent.floci.services.cloudformation; import io.github.hectorvent.floci.core.common.XmlParser; -import io.github.hectorvent.floci.services.elasticache.ServerlessTestProfile; -import io.github.hectorvent.floci.testing.DockerAvailability; import io.github.hectorvent.floci.testing.RestAssuredJsonUtils; +import io.github.hectorvent.floci.testing.SidecarContainersProfile; import io.quarkus.test.common.http.TestHTTPResource; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; import io.restassured.specification.RequestSpecification; -import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; @@ -33,9 +31,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * Provisions AWS::ElastiCache::ServerlessCache through CloudFormation. Output values are asserted, * not only the stack status: an unmapped type is stubbed as CREATE_COMPLETE, and its Fn::GetAtt * resolves to the literal "LogicalId.Attr". + * + *
The cache containers are namespaced by {@link SidecarContainersProfile}, which this class + * shares with the other classes whose managers start real containers. The profile it used before + * also mocked RDS and DocumentDB; the stack creates neither, and ElastiCache does not reach them, + * so the shared profile leaves both at the test default. */ @QuarkusTest -@TestProfile(ServerlessTestProfile.class) +@TestProfile(SidecarContainersProfile.class) class ElastiCacheServerlessCfnIntegrationTest { private static final String CFN_AUTH = @@ -85,7 +88,7 @@ class ElastiCacheServerlessCfnIntegrationTest { @Test void serverlessCacheExposesEndpointsAndIsRemovedWithTheStack() throws Exception { - Assumptions.assumeTrue(DockerAvailability.isAvailable(), "Docker is required for the cache data plane"); + SidecarContainersProfile.requireDocker(); cloudFormation(STACK, "CreateStack", TEMPLATE); String stacks = describeStacks(STACK, "CREATE_COMPLETE"); diff --git a/src/test/java/io/github/hectorvent/floci/services/codeartifact/CodeArtifactPypiDockerIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/codeartifact/CodeArtifactPypiDockerIntegrationTest.java index 50eee4ee10..def19ff616 100644 --- a/src/test/java/io/github/hectorvent/floci/services/codeartifact/CodeArtifactPypiDockerIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/codeartifact/CodeArtifactPypiDockerIntegrationTest.java @@ -1,8 +1,12 @@ package io.github.hectorvent.floci.services.codeartifact; +import io.github.hectorvent.floci.config.EmulatorConfig; +import io.github.hectorvent.floci.core.common.docker.ContainerStorageHelper; import io.github.hectorvent.floci.testing.RestAssuredJsonUtils; +import io.github.hectorvent.floci.testing.SidecarContainersProfile; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; +import jakarta.inject.Inject; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; @@ -12,6 +16,7 @@ import org.junit.jupiter.api.TestMethodOrder; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Base64; +import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -23,6 +28,7 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.startsWith; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -34,13 +40,20 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * is already covered by its own unit tests and by {@code CodeArtifactPypiControllerTest}, so what * this class needs to prove is the real container's behavior, not the parser's fidelity to one * exact client's byte-for-byte output. + * + *
The containers are namespaced by {@link SidecarContainersProfile}, which this class shares
+ * with the other sidecar classes, so its last test deletes the repositories and domains it created.
*/
@QuarkusTest
-@TestProfile(CodeArtifactPypiSidecarProfile.class)
+@TestProfile(SidecarContainersProfile.class)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class CodeArtifactPypiDockerIntegrationTest {
private static final String AUTH = "AWS4-HMAC-SHA256 Credential=AKID/20260904/us-east-1/codeartifact/aws4_request";
+ private static final String NON_DEFAULT_REGION_AUTH =
+ "AWS4-HMAC-SHA256 Credential=AKID/20260904/us-west-2/codeartifact/aws4_request";
+ private static final String OTHER_ACCOUNT_AUTH =
+ "AWS4-HMAC-SHA256 Credential=111122223333/20260904/us-east-1/codeartifact/aws4_request";
private static final String DOMAIN = "pypi-sidecar-domain";
private static final String REPO = "pypi-sidecar-repo";
private static final String PACKAGE_NAME = "floci-pypiserver-spike";
@@ -51,9 +64,12 @@ class CodeArtifactPypiDockerIntegrationTest {
private static String bearerToken;
+ @Inject
+ EmulatorConfig config;
+
@BeforeAll
static void setUp() {
- CodeArtifactPypiSidecarProfile.requireDockerAndTheSidecarImage();
+ SidecarContainersProfile.requireDockerAndImage("floci.services.codeartifact.pypi-image");
RestAssuredJsonUtils.configureAwsContentTypes();
}
@@ -290,17 +306,15 @@ class CodeArtifactPypiDockerIntegrationTest {
@Test
@Order(10)
void aDomainCreatedInANonDefaultRegionIsServedThroughTheTokensOwnRegion() {
- String nonDefaultRegionAuth =
- "AWS4-HMAC-SHA256 Credential=AKID/20260904/us-west-2/codeartifact/aws4_request";
String domain = "pypi-sidecar-non-default-region-domain";
- given().contentType("application/json").header("Authorization", nonDefaultRegionAuth).body("{}")
+ given().contentType("application/json").header("Authorization", NON_DEFAULT_REGION_AUTH).body("{}")
.post("/v1/domain?domain=" + domain)
.then().statusCode(200);
- given().contentType("application/json").header("Authorization", nonDefaultRegionAuth).body("{}")
+ given().contentType("application/json").header("Authorization", NON_DEFAULT_REGION_AUTH).body("{}")
.post("/v1/repository?domain=" + domain + "&repository=" + REPO)
.then().statusCode(200);
- String token = given().header("Authorization", nonDefaultRegionAuth)
+ String token = given().header("Authorization", NON_DEFAULT_REGION_AUTH)
.post("/v1/authorization-token?domain=" + domain)
.then().statusCode(200)
.extract().jsonPath().getString("authorizationToken");
@@ -319,16 +333,15 @@ class CodeArtifactPypiDockerIntegrationTest {
@Test
@Order(11)
void aDomainCreatedUnderANonDefaultAccountIsServedThroughTheTokensOwnAccount() {
- String otherAccountAuth = "AWS4-HMAC-SHA256 Credential=111122223333/20260904/us-east-1/codeartifact/aws4_request";
String domain = "pypi-sidecar-cross-account-domain";
- given().contentType("application/json").header("Authorization", otherAccountAuth).body("{}")
+ given().contentType("application/json").header("Authorization", OTHER_ACCOUNT_AUTH).body("{}")
.post("/v1/domain?domain=" + domain)
.then().statusCode(200);
- given().contentType("application/json").header("Authorization", otherAccountAuth).body("{}")
+ given().contentType("application/json").header("Authorization", OTHER_ACCOUNT_AUTH).body("{}")
.post("/v1/repository?domain=" + domain + "&repository=" + REPO)
.then().statusCode(200);
- String token = given().header("Authorization", otherAccountAuth)
+ String token = given().header("Authorization", OTHER_ACCOUNT_AUTH)
.post("/v1/authorization-token?domain=" + domain)
.then().statusCode(200)
.extract().jsonPath().getString("authorizationToken");
@@ -497,9 +510,34 @@ class CodeArtifactPypiDockerIntegrationTest {
"state reset must stop reset-repo's pypiserver container");
}
- private static int runningPypiserverTestContainerCount() throws IOException, InterruptedException {
+ /**
+ * Last, since the class shares {@link SidecarContainersProfile}'s application with the other
+ * sidecar classes: deletes the repositories and domains the tests above created, which also stops
+ * their pypiserver containers.
+ */
+ @Test
+ @Order(99)
+ void cleanupDeletesTheRepositoriesAndDomainsItCreated() {
+ deleteDomain(AUTH, DOMAIN, REPO, "other-repo", "concurrent-repo", "reused-name");
+ deleteDomain(AUTH, "other-pypi-token-domain");
+ deleteDomain(NON_DEFAULT_REGION_AUTH, "pypi-sidecar-non-default-region-domain", REPO);
+ deleteDomain(OTHER_ACCOUNT_AUTH, "pypi-sidecar-cross-account-domain", REPO);
+ }
+
+ private static void deleteDomain(String auth, String domain, String... repositories) {
+ for (String repository : repositories) {
+ given().header("Authorization", auth)
+ .delete("/v1/repository?domain=" + domain + "&repository=" + repository);
+ }
+ given().header("Authorization", auth).delete("/v1/domain?domain=" + domain);
+ List The task containers and volumes carry the namespace of {@link SidecarContainersProfile} in
+ * their owner label, so the leftover removal under test can only reach those of this test run,
+ * never a developer's running Floci.
+ */
@QuarkusTest
-@TestProfile(EcsContainerManagerEphemeralVolumesDockerIntegrationTest.VolumeProfile.class)
+@TestProfile(SidecarContainersProfile.class)
class EcsContainerManagerEphemeralVolumesDockerIntegrationTest {
@Inject
@@ -43,22 +51,14 @@ class EcsContainerManagerEphemeralVolumesDockerIntegrationTest {
@Inject
DockerClient dockerClient;
- private final List The cache containers are namespaced by {@link SidecarContainersProfile}, which this class
+ * shares with the other classes whose managers start real containers. The profile it used before
+ * also mocked RDS and DocumentDB; this class calls neither, and ElastiCache does not reach them, so
+ * the shared profile leaves both at the test default.
+ */
@QuarkusTest
-@TestProfile(ServerlessTestProfile.class)
+@TestProfile(SidecarContainersProfile.class)
class ElastiCacheServerlessIntegrationTest {
@TestHTTPResource
URI endpoint;
@@ -100,7 +108,7 @@ class ElastiCacheServerlessIntegrationTest {
@Test
void dockerValkeyPreservesDataAndAuthenticatesCurrentGroupMembers() throws Exception {
- Assumptions.assumeTrue(DockerAvailability.isAvailable(), "Docker is required for the serverless data plane");
+ SidecarContainersProfile.requireDocker();
try (ElastiCacheClient client = client()) {
client.createUser(request -> request.userId("serverless-alice").userName("alice").engine("valkey")
.accessString("on ~* +@all").passwords("alice-password-123"));
@@ -164,7 +172,7 @@ class ElastiCacheServerlessIntegrationTest {
@Test
void dockerMemcachedPreservesValuesAcrossMetadataChanges() throws Exception {
- Assumptions.assumeTrue(DockerAvailability.isAvailable(), "Docker is required for the serverless Memcached data plane");
+ SidecarContainersProfile.requireDocker();
try (ElastiCacheClient client = client()) {
try {
ServerlessCache cache = client.createServerlessCache(request -> request.serverlessCacheName("serverless-memcached")
diff --git a/src/test/java/io/github/hectorvent/floci/services/elasticache/ServerlessTestProfile.java b/src/test/java/io/github/hectorvent/floci/services/elasticache/ServerlessTestProfile.java
deleted file mode 100644
index 18be39a490..0000000000
--- a/src/test/java/io/github/hectorvent/floci/services/elasticache/ServerlessTestProfile.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package io.github.hectorvent.floci.services.elasticache;
-
-import io.quarkus.test.junit.QuarkusTestProfile;
-
-import java.util.Map;
-
-public class ServerlessTestProfile implements QuarkusTestProfile {
- @Override
- public Map The sidecar reads the objects back from Floci's S3 at {@code floci.base-url}, which
+ * {@link SidecarContainersProfile} points at the port the test application listens on, and the
+ * profile namespaces the containers. The class shares that application with the other sidecar
+ * classes, so as each test ends it deletes the IAM role it created, and only one it created.
+ */
@QuarkusTest
-@TestProfile(RedshiftSpectrumIntegrationTest.SpectrumProfile.class)
+@TestProfile(SidecarContainersProfile.class)
class RedshiftSpectrumIntegrationTest {
- public static class SpectrumProfile implements QuarkusTestProfile {
- @Override
- public Map Namespaces the containers as {@code floci-aws-sidecar-test- Also sets the HTTP port, {@code floci.port} and {@code floci.base-url} together. The AppSync
* resolver callback URL a launched container uses is built from {@code quarkus.http.port}, which in
@@ -117,19 +119,29 @@ public class SidecarContainersProfile implements QuarkusTestProfile {
* in CI a missing image is a failure, since a vanished tag must not pass silently.
*/
public static void requireDockerAndImage(String imageProperty) {
- Assumptions.assumeTrue(isDockerAvailable(), "Docker daemon must be available for sidecar integration tests");
- removeAbandonedSidecars();
+ requireDocker();
String image = ConfigProvider.getConfig().getValue(imageProperty, String.class);
Assumptions.assumeTrue(imageUsable(image), "Sidecar image " + image + " is not present locally");
}
/**
- * Removes the sidecars of earlier runs that were killed before they could stop them: containers
- * in a {@code sidecar-test-