mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
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.
This commit is contained in:
1 parent
792260ed49
commit
6f8316b7d1
3 files changed
+59
-24
No files matched your search
+8
-12
@@ -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<String, String> 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";
|
||||
|
||||
|
||||
+7
-12
@@ -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<String, String> 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;
|
||||
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
* <p>The overrides, and who relies on them:
|
||||
* <ul>
|
||||
* <li>{@code floci.services.timestream-influxdb.mock=false} backs each DB instance with an
|
||||
* InfluxDB container, published on a host port from {@code host-port-base} to
|
||||
* {@code host-port-max}, set here to 18186 and 18285. {@code TimestreamInfluxDbDockerIntegrationTest}
|
||||
* relies on it.</li>
|
||||
* <li>{@code floci.services.eks.imds=true} and {@code floci.services.eks.imds-pod-network=true}
|
||||
* program the link-local IMDS endpoint into a cluster's container, for the node and for its pods.
|
||||
* {@code EksImdsDockerIntegrationTest} relies on them.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>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.
|
||||
*
|
||||
* <p>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<String, String> 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");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user