diff --git a/src/test/java/io/github/hectorvent/floci/services/eks/EksImdsDockerIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/eks/EksImdsDockerIntegrationTest.java index b41d66694c..a3581ac55d 100644 --- a/src/test/java/io/github/hectorvent/floci/services/eks/EksImdsDockerIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/eks/EksImdsDockerIntegrationTest.java @@ -9,8 +9,8 @@ import io.github.hectorvent.floci.core.common.docker.ContainerSpec; import io.github.hectorvent.floci.core.common.docker.DockerHostResolver; import io.github.hectorvent.floci.services.ec2.Ec2MetadataServer; import io.github.hectorvent.floci.services.eks.model.Cluster; +import io.github.hectorvent.floci.testing.ContainerDataPlaneProfile; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.junit.QuarkusTestProfile; import io.quarkus.test.junit.TestProfile; import jakarta.inject.Inject; import org.jboss.logging.Logger; @@ -20,7 +20,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.util.List; -import java.util.Map; import java.util.UUID; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -28,19 +27,16 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +/** + * Configures the link-local IMDS endpoint on a stand-in cluster container and queries it from the + * node and from a pod network namespace. The settings come from + * {@link ContainerDataPlaneProfile}, which this class shares with + * {@code TimestreamInfluxDbDockerIntegrationTest}. + */ @QuarkusTest -@TestProfile(EksImdsDockerIntegrationTest.Profile.class) +@TestProfile(ContainerDataPlaneProfile.class) class EksImdsDockerIntegrationTest { - public static final class Profile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of( - "floci.services.eks.imds", "true", - "floci.services.eks.imds-pod-network", "true"); - } - } - private static final Logger LOG = Logger.getLogger(EksImdsDockerIntegrationTest.class); private static final String TEST_IMAGE = "alpine:3.21"; diff --git a/src/test/java/io/github/hectorvent/floci/services/timestreaminfluxdb/TimestreamInfluxDbDockerIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/timestreaminfluxdb/TimestreamInfluxDbDockerIntegrationTest.java index b34eed7890..fdba301192 100644 --- a/src/test/java/io/github/hectorvent/floci/services/timestreaminfluxdb/TimestreamInfluxDbDockerIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/timestreaminfluxdb/TimestreamInfluxDbDockerIntegrationTest.java @@ -1,9 +1,9 @@ package io.github.hectorvent.floci.services.timestreaminfluxdb; import com.github.dockerjava.api.DockerClient; +import io.github.hectorvent.floci.testing.ContainerDataPlaneProfile; import io.github.hectorvent.floci.testing.RestAssuredJsonUtils; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.junit.QuarkusTestProfile; import io.quarkus.test.junit.TestProfile; import io.restassured.response.ValidatableResponse; import jakarta.inject.Inject; @@ -28,9 +28,14 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; +/** + * Runs Timestream for InfluxDB on real InfluxDB containers, published on host ports 18186 to 18285. + * The settings come from {@link ContainerDataPlaneProfile}, which this class shares with + * {@code EksImdsDockerIntegrationTest}. + */ @Tag("docker") @QuarkusTest -@TestProfile(TimestreamInfluxDbDockerIntegrationTest.RealContainerProfile.class) +@TestProfile(ContainerDataPlaneProfile.class) // Three 180 s status waits on real containers, plus the requests and cleanup around them. @Timeout(value = 15, unit = TimeUnit.MINUTES) class TimestreamInfluxDbDockerIntegrationTest { @@ -40,16 +45,6 @@ class TimestreamInfluxDbDockerIntegrationTest { private static final String USERNAME = "operator"; private static final String PASSWORD = "password123"; - public static class RealContainerProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of( - "floci.services.timestream-influxdb.mock", "false", - "floci.services.timestream-influxdb.host-port-base", "18186", - "floci.services.timestream-influxdb.host-port-max", "18285"); - } - } - @Inject DockerClient dockerClient; diff --git a/src/test/java/io/github/hectorvent/floci/testing/ContainerDataPlaneProfile.java b/src/test/java/io/github/hectorvent/floci/testing/ContainerDataPlaneProfile.java new file mode 100644 index 0000000000..f0cea61cc6 --- /dev/null +++ b/src/test/java/io/github/hectorvent/floci/testing/ContainerDataPlaneProfile.java @@ -0,0 +1,44 @@ +package io.github.hectorvent.floci.testing; + +import io.quarkus.test.junit.QuarkusTestProfile; + +import java.util.Map; + +/** + * Runs the container-backed data planes the test defaults mock or leave off, for the classes that + * test them. Quarkus builds the application once per distinct profile class, so they share this + * one rather than each declaring their own. + * + *

The overrides, and who relies on them: + *

+ * + *

Each override is inert for the other class. An InfluxDB container only starts when a DB + * instance is created, which the IMDS test never does. The IMDS settings only act when a cluster's + * container starts, and the test defaults keep EKS mocked, so only {@code EksImdsDockerIntegrationTest}, + * which configures the endpoint on its own container, reaches them. The metadata server it starts + * stays up for the Timestream test, on a port that test does not use. + * + *

The ELBv2 data-plane classes stay on {@link RealElbV2DataPlaneProfile}: one of them, + * {@code ElbV2WebSocketIntegrationTest}, injects a spy, and a class that does is not merged into + * another group. + */ +public class ContainerDataPlaneProfile implements QuarkusTestProfile { + + @Override + public Map getConfigOverrides() { + return Map.of( + "floci.services.timestream-influxdb.mock", "false", + "floci.services.timestream-influxdb.host-port-base", "18186", + "floci.services.timestream-influxdb.host-port-max", "18285", + "floci.services.eks.imds", "true", + "floci.services.eks.imds-pod-network", "true"); + } +}