test: run two more ECS Docker classes on ScopedServiceSettingsProfile (#8868)

Both classes ran on a profile of their own for real ECS containers, as
ScopedServiceSettingsProfile already does for the image pull class, with the
startup sweep off. The Linux parameters class's two switches, /dev/null as
the one host path a device may take and privileged containers allowed, move
there: only a task definition that asks for a device or privilege reaches
them, and only that class asks. Their tasks run in bridge mode, which
security-group enforcement never protects, and the pull on every launch the
image pull class needs runs their busybox tasks the same way, falling back to
the cached image when a pull fails.

Dropping the essential-exit class's own namespace would leave its containers
labelled by the port alone, so the profile now names its containers in this
run's sidecar namespace, which also covers the image pull class.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-18 10:31:58 -04:00
1 parent 4fe226c253
commit 81c5ecf777
3 files changed
+28 -36

No files matched your search

@@ -6,9 +6,9 @@ import com.github.dockerjava.api.exception.NotFoundException;
import com.github.dockerjava.api.model.Frame;
import io.floci.aws.testing.AwsTestClients;
import io.floci.aws.testing.DockerAvailability;
import io.floci.aws.testing.ScopedServiceSettingsProfile;
import io.floci.aws.testing.TestImages;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import jakarta.inject.Inject;
import org.junit.jupiter.api.AfterEach;
@@ -23,7 +23,6 @@ import software.amazon.awssdk.services.ecs.model.RunTaskResponse;
import software.amazon.awssdk.services.ecs.model.Task;
import java.time.Duration;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@@ -35,18 +34,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
@QuarkusTest
@TestProfile(EcsEssentialContainerExitDockerIntegrationTest.DockerEcsProfile.class)
@TestProfile(ScopedServiceSettingsProfile.class)
class EcsEssentialContainerExitDockerIntegrationTest {
public static final class DockerEcsProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.ecs.mock", "false",
"floci.services.ecs.reconcile-containers-on-startup", "false",
"floci.docker.resource-namespace", "ecs-essential-exit-it");
}
}
@Inject
DockerClient docker;
@@ -9,9 +9,9 @@ import com.github.dockerjava.api.model.HostConfig;
import io.floci.aws.services.ecs.model.EcsTask;
import io.floci.aws.testing.DockerAvailability;
import io.floci.aws.testing.RestAssuredJsonUtils;
import io.floci.aws.testing.ScopedServiceSettingsProfile;
import io.floci.aws.testing.TestImages;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import jakarta.inject.Inject;
import org.junit.jupiter.api.AfterEach;
@@ -38,7 +38,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* size of {@code /dev/shm} and the tmpfs mount, as ECS hands each of them to Docker.
*/
@QuarkusTest
@TestProfile(EcsLinuxParametersDockerIntegrationTest.DockerEcsProfile.class)
@TestProfile(ScopedServiceSettingsProfile.class)
class EcsLinuxParametersDockerIntegrationTest {
private static final String REGION = "us-east-1";
@@ -46,20 +46,6 @@ class EcsLinuxParametersDockerIntegrationTest {
private static final String ECS_TARGET = "AmazonEC2ContainerServiceV20141113.";
private static final long MIB = 1024L * 1024L;
/**
* Real containers, with security-group enforcement back to its shipped default of off, and
* {@code /dev/null} the one host path a device may take, since devices are refused by default.
*/
public static final class DockerEcsProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.ecs.mock", "false",
"floci.network.security-group-enforcement.enabled", "false",
"floci.services.ecs.host-volume-roots", "/dev/null",
"floci.services.ecs.allow-privileged-containers", "true");
}
}
@Inject
EcsService ecsService;
@@ -11,15 +11,24 @@ import java.util.Map;
*
* <p>The overrides, and who relies on them:
* <ul>
* <li>{@code floci.services.ecs.mock=false} runs ECS tasks as Docker containers,
* <li>{@code floci.services.ecs.mock=false} runs ECS tasks as Docker containers.
* {@code EcsImagePullDockerIntegrationTest}, {@code EcsEssentialContainerExitDockerIntegrationTest}
* and {@code EcsLinuxParametersDockerIntegrationTest} rely on it.
* {@code floci.network.security-group-enforcement.enabled=false} puts security-group enforcement
* back to its shipped default of off, and {@code floci.services.ecs.image-pull-behavior=default}
* back to the shipped pull on every launch, which the shared test config swaps for
* {@code prefer-cached}. {@code EcsImagePullDockerIntegrationTest} relies on them.
* {@code prefer-cached}. The image pull class relies on them.
* {@code floci.services.ecs.reconcile-containers-on-startup=false} keeps the application from
* sweeping the Docker daemon for ECS containers and volumes a previous run left when it starts,
* which a class that runs no container would otherwise trigger too. The image pull class stops
* its own tasks and removes the registry it starts, so it needs no sweep.</li>
* which a class that runs no container would otherwise trigger too. Each ECS class stops its own
* tasks, so none needs the sweep. {@code floci.docker.resource-namespace} names their containers
* in this run's {@link SidecarContainersProfile#namespace() sidecar namespace}, so another test
* JVM on the same Docker daemon and port, whose startup sweep is on, never takes them for its own
* leftovers.</li>
* <li>{@code floci.services.ecs.host-volume-roots=/dev/null} makes {@code /dev/null} the one host
* path a device may take, since devices are refused by default, and
* {@code floci.services.ecs.allow-privileged-containers=true} lets a task definition ask for
* privilege. {@code EcsLinuxParametersDockerIntegrationTest} relies on them.</li>
* <li>The extra CORS origins, allowed and exposed headers, and
* {@code floci.security.cors-allow-private-network=true} are what a browser's preflight is
* answered with. {@code GlobalCorsFilterIntegrationTest} relies on them.</li>
@@ -32,10 +41,14 @@ import java.util.Map;
* them.</li>
* </ul>
*
* <p>Each is inert for the other classes. Only {@code EcsImagePullDockerIntegrationTest} runs an
* ECS task or any other container. Only {@code GlobalCorsFilterIntegrationTest} sends an
* {@code Origin} header, the only request the CORS settings answer differently. Every other class
* signs its requests for the commercial partition, where AWS publishes each service it calls. Only
* <p>Each is inert for the other classes. Only the three ECS classes run a task or any other
* container, so only their containers carry the namespace. Their tasks run in bridge mode, which security-group enforcement never protects, and
* only the Linux parameters class asks for a device or privilege. The pull on every launch reaches
* the other two ECS classes' tasks too, and changes nothing they check: their busybox tasks run
* the same way on the image the tag names now, and a failed pull runs the cached image. Only
* {@code GlobalCorsFilterIntegrationTest} sends an {@code Origin} header, the only request the CORS
* settings answer differently. Every other class signs its requests for the commercial partition,
* where AWS publishes each service it calls. Only
* {@code Ec2MockFixedPublicAddressIntegrationTest} launches an instance. It stays apart from
* {@link IndependentServiceSettingsProfile}, which runs EC2 for real.
*
@@ -54,6 +67,9 @@ public class ScopedServiceSettingsProfile implements QuarkusTestProfile {
Map.entry("floci.network.security-group-enforcement.enabled", "false"),
Map.entry("floci.services.ecs.image-pull-behavior", "default"),
Map.entry("floci.services.ecs.reconcile-containers-on-startup", "false"),
Map.entry("floci.docker.resource-namespace", SidecarContainersProfile.namespace()),
Map.entry("floci.services.ecs.host-volume-roots", "/dev/null"),
Map.entry("floci.services.ecs.allow-privileged-containers", "true"),
Map.entry("floci.security.extra-cors-allowed-origins", "http://localhost:3000,https://ui.example.test"),
Map.entry("floci.security.extra-cors-allowed-headers", "x-added-header"),
Map.entry("floci.security.extra-cors-expose-headers", "x-visible-header"),