From 6f8316b7d11e63bcd5dc54d9d64ef95c5e5edd84 Mon Sep 17 00:00:00 2001 From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com> Date: Fri, 16 Oct 2026 18:26:08 -0400 Subject: [PATCH] test: share one profile between the Timestream and EKS IMDS Docker tests (#5829) Slice 9 of #4542. TimestreamInfluxDbDockerIntegrationTest and EksImdsDockerIntegrationTest each declared a profile of their own, the first for real InfluxDB containers on host ports 18186 to 18285 and the second for the link-local IMDS endpoint on the node and its pods. They now share ContainerDataPlaneProfile. Each setting only reaches the class that tests it. An InfluxDB container starts only when a DB instance is created, which the IMDS test never does. The IMDS settings act only when a cluster's container starts, and the test defaults keep EKS mocked, so only the IMDS test, which configures the endpoint on its own container, reaches them. The issue had the Timestream test joining RealElbV2DataPlaneProfile instead. The ELBv2 classes stay where they are, because one of them, ElbV2WebSocketIntegrationTest, injects a spy, and a class that does is not merged into another group. The new profile's javadoc lists each override, the class that relies on it, why it is inert for the other, and why the ELBv2 classes stay apart. The two moved classes gain a class javadoc naming what they get from it. --- .../eks/EksImdsDockerIntegrationTest.java | 20 ++++----- ...mestreamInfluxDbDockerIntegrationTest.java | 19 +++----- .../testing/ContainerDataPlaneProfile.java | 44 +++++++++++++++++++ 3 files changed, 59 insertions(+), 24 deletions(-) create mode 100644 src/test/java/io/github/hectorvent/floci/testing/ContainerDataPlaneProfile.java 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"); + } +}