test: share one sidecar profile across the AppSync, CodeArtifact and Cedar integration tests (#4665)

Five profiles existed only to give a sidecar container its own Docker resource namespace, so a manager's remove-before-start never touches a developer's running Floci, and each cost an application build. They become one SidecarContainersProfile with a single test namespace, the HTTP port and base URL pinned together for the AppSync resolver callback, and one Docker and image check in place of four copies.

CodeArtifactNpmDockerIntegrationTest now checks the tarball URL against config.effectiveBaseUrl() instead of a hard-coded localhost:4566, since the pinned base URL is what that URL is built from.

Part of #4542.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-09-29 19:01:36 -05:00
1 parent 5aae37a3ef
commit 1b87ed44c0
13 files changed
+106 -239

No files matched your search

@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.appsync;
import io.github.hectorvent.floci.core.common.ResolvedServiceCatalog;
import io.github.hectorvent.floci.services.appsync.graphql.AppSyncExecutionController;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.github.hectorvent.floci.testing.SidecarContainersProfile;
import io.github.hectorvent.floci.testutil.AppSyncRequestSigner;
import io.restassured.RestAssured;
import io.quarkus.test.junit.QuarkusTest;
@@ -26,7 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
/** Runs against the real GraphQL sidecar image, started by {@link GraphqlSidecarManager}. */
@QuarkusTest
@TestProfile(AppSyncGraphqlSidecarProfile.class)
@TestProfile(SidecarContainersProfile.class)
class AppSyncAuthIntegrationTest {
private static final String MGMT_AUTH =
@@ -37,7 +38,7 @@ class AppSyncAuthIntegrationTest {
@BeforeAll
static void configureRestAssured() {
AppSyncGraphqlSidecarProfile.requireDockerAndTheSidecarImage();
SidecarContainersProfile.requireDockerAndImage("floci.services.appsync.graphql-image");
RestAssuredJsonUtils.configureAwsContentTypes();
}
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.appsync;
import io.github.hectorvent.floci.services.appsync.graphql.AppSyncErrorFormatter;
import io.github.hectorvent.floci.services.appsync.graphql.SchemaRegistry;
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;
@@ -23,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
/** Runs against the real GraphQL sidecar image, started by {@link GraphqlSidecarManager}. */
@QuarkusTest
@TestProfile(AppSyncGraphqlSidecarProfile.class)
@TestProfile(SidecarContainersProfile.class)
class AppSyncExecutionIntegrationTest {
private static final String AUTH = "AWS4-HMAC-SHA256 Credential=test/20260205/us-east-1/appsync/aws4_request";
@@ -36,7 +37,7 @@ class AppSyncExecutionIntegrationTest {
@BeforeAll
static void configureRestAssured() {
AppSyncGraphqlSidecarProfile.requireDockerAndTheSidecarImage();
SidecarContainersProfile.requireDockerAndImage("floci.services.appsync.graphql-image");
RestAssuredJsonUtils.configureAwsContentTypes();
}
@@ -1,53 +0,0 @@
package io.github.hectorvent.floci.services.appsync;
import io.quarkus.test.junit.QuarkusTestProfile;
import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.api.Assumptions;
import java.util.Map;
/**
* Shared by every AppSync integration test that needs the real GraphQL sidecar container, started
* by {@link GraphqlSidecarManager} exactly as in production. Namespaces the container as
* {@code floci-appsync-test-graphql} so the manager's remove-before-start never touches a
* developer's real running Floci. Needs Docker; skipped without it. Locally it is also skipped
* when the pinned image is not present, so a developer without registry access is not stuck; in CI
* a missing image is a failure, since a vanished tag must not pass silently.
*
* <p>Every test class that uses this profile shares one Quarkus test application instance (and
* one running sidecar container) rather than paying a restart for each, since Quarkus keys its
* test-application cache by the profile class identity.
*/
public class AppSyncGraphqlSidecarProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.docker.resource-namespace", "appsync-test");
}
public static void requireDockerAndTheSidecarImage() {
Assumptions.assumeTrue(isDockerAvailable(), "Docker daemon must be available for AppSync integration tests");
String image = ConfigProvider.getConfig().getValue("floci.services.appsync.graphql-image", String.class);
Assumptions.assumeTrue(imageUsable(image), "GraphQL sidecar image " + image + " is not present locally");
}
private static boolean isDockerAvailable() {
return run("docker", "version", "--format", "{{.Server.Version}}");
}
private static boolean imageUsable(String image) {
if ("true".equals(System.getenv("CI"))) {
return true;
}
return run("docker", "image", "inspect", image);
}
private static boolean run(String... command) {
try {
Process process = new ProcessBuilder(command).redirectErrorStream(true).start();
return process.waitFor() == 0;
} catch (Exception e) {
return false;
}
}
}
@@ -4,6 +4,7 @@ import io.github.hectorvent.floci.core.storage.StorageBackend;
import io.github.hectorvent.floci.services.appsync.model.SchemaCreationStatus;
import io.github.hectorvent.floci.services.appsync.model.SchemaCreationStatusType;
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 org.junit.jupiter.api.BeforeAll;
@@ -24,7 +25,7 @@ import static org.hamcrest.Matchers.*;
* {@code StartSchemaCreation} validates against it, so it needs to be up.
*/
@QuarkusTest
@TestProfile(AppSyncGraphqlSidecarProfile.class)
@TestProfile(SidecarContainersProfile.class)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class AppSyncIntegrationTest {
@@ -37,7 +38,7 @@ class AppSyncIntegrationTest {
@BeforeAll
static void configureRestAssured() {
AppSyncGraphqlSidecarProfile.requireDockerAndTheSidecarImage();
SidecarContainersProfile.requireDockerAndImage("floci.services.appsync.graphql-image");
RestAssuredJsonUtils.configureAwsContentTypes();
}
@@ -1,6 +1,7 @@
package io.github.hectorvent.floci.services.appsync;
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 org.junit.jupiter.api.BeforeAll;
@@ -31,7 +32,7 @@ import static org.hamcrest.Matchers.nullValue;
* <p>Needs Docker for both sidecars, and skips without it.
*/
@QuarkusTest
@TestProfile(AppSyncResolverCallbackProfile.class)
@TestProfile(SidecarContainersProfile.class)
class AppSyncJsResolverDockerIntegrationTest {
private static final String AUTH =
@@ -173,7 +174,7 @@ class AppSyncJsResolverDockerIntegrationTest {
@BeforeAll
static void configure() {
AppSyncGraphqlSidecarProfile.requireDockerAndTheSidecarImage();
SidecarContainersProfile.requireDockerAndImage("floci.services.appsync.graphql-image");
RestAssuredJsonUtils.configureAwsContentTypes();
}
@@ -1,26 +0,0 @@
package io.github.hectorvent.floci.services.appsync;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* {@link AppSyncGraphqlSidecarProfile} plus a Floci base URL the sidecar container can actually
* reach back on.
*
* <p>The resolver callback URL is built from {@code floci.base-url}'s port, which in production is
* the port Floci listens on. Under {@code @QuarkusTest} the application listens on the test port
* instead, so without this the sidecar would call back to 4566 and every resolver-backed field
* would fail with a connection error. Both values are pinned together here so they cannot drift.
*/
public class AppSyncResolverCallbackProfile extends AppSyncGraphqlSidecarProfile {
private static final String TEST_PORT = "8081";
@Override
public Map<String, String> getConfigOverrides() {
Map<String, String> overrides = new LinkedHashMap<>(super.getConfigOverrides());
overrides.put("quarkus.http.test-port", TEST_PORT);
overrides.put("floci.base-url", "http://localhost:" + TEST_PORT);
return overrides;
}
}
@@ -1,7 +1,7 @@
package io.github.hectorvent.floci.services.cloudformation;
import io.github.hectorvent.floci.core.common.XmlParser;
import io.github.hectorvent.floci.services.appsync.AppSyncGraphqlSidecarProfile;
import io.github.hectorvent.floci.testing.SidecarContainersProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;
import io.restassured.response.ValidatableResponse;
@@ -37,12 +37,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* never touches a developer's own running sidecar, and skips (rather than fails) without Docker.
*/
@QuarkusTest
@TestProfile(AppSyncGraphqlSidecarProfile.class)
@TestProfile(SidecarContainersProfile.class)
class AppSyncCfnIntegrationTest {
@BeforeAll
static void requireDockerAndTheSidecarImage() {
AppSyncGraphqlSidecarProfile.requireDockerAndTheSidecarImage();
SidecarContainersProfile.requireDockerAndImage("floci.services.appsync.graphql-image");
}
private static final String CFN_AUTH =
@@ -2,6 +2,7 @@ package io.github.hectorvent.floci.services.codeartifact;
import com.fasterxml.jackson.databind.ObjectMapper;
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;
@@ -36,7 +37,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* Docker-gated form.
*/
@QuarkusTest
@TestProfile(CodeArtifactMavenSidecarProfile.class)
@TestProfile(SidecarContainersProfile.class)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class CodeArtifactMavenDockerIntegrationTest {
@@ -49,7 +50,7 @@ class CodeArtifactMavenDockerIntegrationTest {
@BeforeAll
static void setUp() {
CodeArtifactMavenSidecarProfile.requireDockerAndTheSidecarImage();
SidecarContainersProfile.requireDockerAndImage("floci.services.codeartifact.maven-image");
RestAssuredJsonUtils.configureAwsContentTypes();
}
@@ -1,50 +0,0 @@
package io.github.hectorvent.floci.services.codeartifact;
import io.quarkus.test.junit.QuarkusTestProfile;
import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.api.Assumptions;
import java.util.Map;
/**
* Shared by every CodeArtifact integration test that needs the real Reposilite sidecar container,
* started by {@link ReposiliteSidecarManager} exactly as in production. Namespaces the container
* as {@code floci-codeartifact-maven-test-reposilite} so the manager's remove-before-start never
* touches a developer's real running Floci. Needs Docker; skipped without it. Locally it is also
* skipped when the pinned image is not present, so a developer without registry access is not
* stuck; in CI a missing image is a failure, since a vanished tag must not pass silently.
*/
public class CodeArtifactMavenSidecarProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.docker.resource-namespace", "codeartifact-maven-test");
}
public static void requireDockerAndTheSidecarImage() {
Assumptions.assumeTrue(isDockerAvailable(), "Docker daemon must be available for CodeArtifact Maven "
+ "sidecar integration tests");
String image = ConfigProvider.getConfig().getValue("floci.services.codeartifact.maven-image", String.class);
Assumptions.assumeTrue(imageUsable(image), "Reposilite sidecar image " + image + " is not present locally");
}
private static boolean isDockerAvailable() {
return run("docker", "version", "--format", "{{.Server.Version}}");
}
private static boolean imageUsable(String image) {
if ("true".equals(System.getenv("CI"))) {
return true;
}
return run("docker", "image", "inspect", image);
}
private static boolean run(String... command) {
try {
Process process = new ProcessBuilder(command).redirectErrorStream(true).start();
return process.waitFor() == 0;
} catch (Exception e) {
return false;
}
}
}
@@ -2,9 +2,12 @@ package io.github.hectorvent.floci.services.codeartifact;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.config.EmulatorConfig;
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.hamcrest.Matcher;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
@@ -43,7 +46,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* internal, client-unreachable address instead of back through this proxy.
*/
@QuarkusTest
@TestProfile(CodeArtifactNpmSidecarProfile.class)
@TestProfile(SidecarContainersProfile.class)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class CodeArtifactNpmDockerIntegrationTest {
@@ -52,13 +55,16 @@ class CodeArtifactNpmDockerIntegrationTest {
private static final String REPO = "npm-sidecar-repo";
private static final String PACKAGE_NAME = "floci-verdaccio-spike";
@Inject
EmulatorConfig config;
private static String bearerToken;
private static byte[] publishFixture;
private static byte[] expectedTarballBytes;
@BeforeAll
static void setUp() throws IOException {
CodeArtifactNpmSidecarProfile.requireDockerAndTheSidecarImage();
SidecarContainersProfile.requireDockerAndImage("floci.services.codeartifact.npm-image");
RestAssuredJsonUtils.configureAwsContentTypes();
ObjectMapper mapper = new ObjectMapper();
@@ -104,11 +110,12 @@ class CodeArtifactNpmDockerIntegrationTest {
// Pins VERDACCIO_PUBLIC_URL: without it this would be the container's own internal,
// client-unreachable address instead of a URL back through this same proxy.
assertTrue(tarballUrl.startsWith("http://localhost:4566/codeartifact/npm/" + DOMAIN + "/" + REPO + "/"),
String publicUrl = config.effectiveBaseUrl();
assertTrue(tarballUrl.startsWith(publicUrl + "/codeartifact/npm/" + DOMAIN + "/" + REPO + "/"),
"tarball URL must point back through the proxy, was: " + tarballUrl);
byte[] fetchedTarball = given().header("Authorization", "Bearer " + bearerToken)
.get(tarballUrl.substring("http://localhost:4566".length()))
.get(tarballUrl.substring(publicUrl.length()))
.then().statusCode(200)
.extract().asByteArray();
assertArrayEquals(expectedTarballBytes, fetchedTarball);
@@ -326,7 +333,7 @@ class CodeArtifactNpmDockerIntegrationTest {
private static int runningVerdaccioTestContainerCount() throws IOException, InterruptedException {
Process process = new ProcessBuilder("docker", "ps", "-q",
"--filter", "name=floci-aws-codeartifact-npm-test-verdaccio-")
"--filter", "name=floci-aws-" + SidecarContainersProfile.NAMESPACE + "-verdaccio-")
.redirectErrorStream(true).start();
String output = new String(process.getInputStream().readAllBytes(), StandardCharsets.UTF_8);
process.waitFor();
@@ -1,52 +0,0 @@
package io.github.hectorvent.floci.services.codeartifact;
import io.quarkus.test.junit.QuarkusTestProfile;
import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.api.Assumptions;
import java.util.Map;
/**
* Shared by every CodeArtifact integration test that needs a real Verdaccio sidecar container,
* started by {@link VerdaccioSidecarManager} exactly as in production. Namespaces containers as
* {@code floci-codeartifact-npm-test-*} so the manager's remove-before-start never touches a
* developer's real running Floci. Needs Docker; skipped without it. Locally it is also skipped
* when the pinned image is not present, so a developer without registry access is not stuck; in
* CI a missing image is a failure, since a vanished tag must not pass silently.
*/
public class CodeArtifactNpmSidecarProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.docker.resource-namespace", "codeartifact-npm-test");
}
public static void requireDockerAndTheSidecarImage() {
Assumptions.assumeTrue(isDockerAvailable(), "Docker daemon must be available for CodeArtifact npm "
+ "sidecar integration tests");
String image = ConfigProvider.getConfig().getValue("floci.services.codeartifact.npm-image", String.class);
Assumptions.assumeTrue(imageUsable(image), "Verdaccio sidecar image " + image + " is not present locally");
}
private static boolean isDockerAvailable() {
return run("docker", "version", "--format", "{{.Server.Version}}");
}
private static boolean imageUsable(String image) {
if ("true".equals(System.getenv("CI"))) {
return true;
}
return run("docker", "image", "inspect", image);
}
private static boolean run(String... command) {
try {
Process process = new ProcessBuilder(command).redirectErrorStream(true).start();
return process.waitFor() == 0;
} catch (Exception ignored) {
// Docker (or the image) isn't available; the caller turns this into a skipped test,
// not a failure, so there is nothing more useful to log here.
return false;
}
}
}
@@ -1,11 +1,9 @@
package io.github.hectorvent.floci.services.verifiedpermissions;
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.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -25,50 +23,15 @@ import static org.hamcrest.Matchers.matchesPattern;
* not pass silently.
*/
@QuarkusTest
@TestProfile(VerifiedPermissionsIntegrationTest.CedarSidecarProfile.class)
@TestProfile(SidecarContainersProfile.class)
class VerifiedPermissionsIntegrationTest {
private static final String CONTENT_TYPE = "application/x-amz-json-1.0";
private static final String AUTH = "AWS4-HMAC-SHA256 Credential=111122223333/20260101/us-east-1/verifiedpermissions/aws4_request";
/**
* Namespaces the sidecar container as {@code floci-vp-test-cedar}: the manager removes any
* container of its name before starting, and the test config uses the same empty namespace
* as a developer's running Floci, whose live sidecar would otherwise be killed.
*/
public static class CedarSidecarProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.docker.resource-namespace", "vp-test");
}
}
@BeforeAll
static void requireDockerAndTheSidecarImage() {
RestAssuredJsonUtils.configureAwsContentTypes();
Assumptions.assumeTrue(isDockerAvailable(),
"Docker daemon must be available for Verified Permissions integration tests");
String image = ConfigProvider.getConfig().getValue("floci.services.verifiedpermissions.cedar-image", String.class);
Assumptions.assumeTrue(imageUsable(image), "Cedar sidecar image " + image + " is not present locally");
}
private static boolean isDockerAvailable() {
return run("docker", "version", "--format", "{{.Server.Version}}");
}
private static boolean imageUsable(String image) {
if ("true".equals(System.getenv("CI"))) {
return true;
}
return run("docker", "image", "inspect", image);
}
private static boolean run(String... command) {
try {
Process process = new ProcessBuilder(command).redirectErrorStream(true).start();
return process.waitFor() == 0;
} catch (Exception e) {
return false;
}
SidecarContainersProfile.requireDockerAndImage("floci.services.verifiedpermissions.cedar-image");
}
@Test
@@ -0,0 +1,73 @@
package io.github.hectorvent.floci.testing;
import io.quarkus.test.junit.QuarkusTestProfile;
import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.api.Assumptions;
import java.util.Map;
/**
* Shared by every integration test that runs a real sidecar container, started by its manager
* exactly as in production: the AppSync GraphQL sidecar, the CodeArtifact Reposilite and Verdaccio
* sidecars, and the Verified Permissions Cedar sidecar. Quarkus builds the application once per
* distinct profile class, so these classes share one application rather than each paying for
* their own.
*
* <p>Namespaces the containers as {@code floci-aws-sidecar-test-<sidecar>}. Each manager removes
* any container of its name before starting one, and the test config uses the same empty namespace
* as a developer's running Floci, whose live sidecars would otherwise be killed. Every sidecar type
* keeps its own name inside the namespace, so they never collide with each other.
*
* <p>Also pins the HTTP port and {@code floci.base-url} together. The AppSync resolver callback URL
* is built from the base URL's port, which in production is the port Floci listens on. Under
* {@code @QuarkusTest} the application listens on the test port instead, so without this the
* sidecar would call back to 4566 and every resolver-backed field would fail with a connection
* error.
*/
public class SidecarContainersProfile implements QuarkusTestProfile {
public static final String NAMESPACE = "sidecar-test";
private static final String TEST_PORT = "8081";
@Override
public Map<String, String> getConfigOverrides() {
return Map.of(
"floci.docker.resource-namespace", NAMESPACE,
"quarkus.http.test-port", TEST_PORT,
"floci.base-url", "http://localhost:" + TEST_PORT);
}
/**
* Skips the calling class without Docker. Locally it is also skipped when the sidecar image named
* by {@code imageProperty} is not present, so a developer without registry access is not stuck;
* 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");
String image = ConfigProvider.getConfig().getValue(imageProperty, String.class);
Assumptions.assumeTrue(imageUsable(image), "Sidecar image " + image + " is not present locally");
}
private static boolean isDockerAvailable() {
return run("docker", "version", "--format", "{{.Server.Version}}");
}
private static boolean imageUsable(String image) {
if ("true".equals(System.getenv("CI"))) {
return true;
}
return run("docker", "image", "inspect", image);
}
private static boolean run(String... command) {
try {
Process process = new ProcessBuilder(command).redirectErrorStream(true).start();
return process.waitFor() == 0;
} catch (Exception ignored) {
// Docker (or the image) isn't available; the caller turns this into a skipped test,
// not a failure, so there is nothing more useful to log here.
return false;
}
}
}