mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
test: fold the ECS service-discovery Docker profile into ValidateSignaturesProfile (#8833)
Quarkus builds one application per distinct test profile at discovery and keeps each for the rest of the surefire JVM, so every profile a shard holds costs heap. EcsServiceDiscoveryDockerIntegrationTest's nested profile (ECS unmocked, security groups off), also used by EcsLeftoverContainersDockerIntegrationTest, now shares ValidateSignaturesProfile: the ECS classes drive ECS through its injected services, so signature validation never sees their requests, and no signature class starts an ECS task or a container security groups would govern.
This commit is contained in:
1 parent
3b2401433b
commit
7fb37956be
3 files changed
+34
-21
No files matched your search
+2
-1
@@ -12,6 +12,7 @@ import io.floci.aws.services.ecs.model.LaunchType;
|
||||
import io.floci.aws.services.ecs.model.NetworkMode;
|
||||
import io.floci.aws.services.ecs.model.TaskDefinition;
|
||||
import io.floci.aws.testing.TestImages;
|
||||
import io.floci.aws.testing.ValidateSignaturesProfile;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.junit.TestProfile;
|
||||
import jakarta.inject.Inject;
|
||||
@@ -39,7 +40,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
* and tells this run's containers from a previous run's by the run label rather than by time.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestProfile(EcsServiceDiscoveryDockerIntegrationTest.DockerEcsProfile.class)
|
||||
@TestProfile(ValidateSignaturesProfile.class)
|
||||
class EcsLeftoverContainersDockerIntegrationTest {
|
||||
|
||||
private static final String REGION = "us-east-1";
|
||||
|
||||
+6
-16
@@ -15,8 +15,8 @@ import io.floci.aws.services.ecs.model.NetworkMode;
|
||||
import io.floci.aws.services.ecs.model.TaskDefinition;
|
||||
import io.floci.aws.services.ecs.model.UpdateServiceRequest;
|
||||
import io.floci.aws.testing.TestImages;
|
||||
import io.floci.aws.testing.ValidateSignaturesProfile;
|
||||
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.Assumptions;
|
||||
@@ -39,9 +39,13 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
* <p>Nothing here touches the registrar. A service that declares {@code serviceRegistries} has a
|
||||
* real container launched for it, and the assertions are that the Cloud Map name resolves to the
|
||||
* task's address while it runs and stops resolving once the task does.
|
||||
*
|
||||
* <p>ECS runs unmocked here, and security-group enforcement goes back to its shipped default of
|
||||
* off, both from {@link ValidateSignaturesProfile}: the suite turns enforcement on, and its helper
|
||||
* needs rootful Docker, a requirement of security groups rather than of service discovery.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestProfile(EcsServiceDiscoveryDockerIntegrationTest.DockerEcsProfile.class)
|
||||
@TestProfile(ValidateSignaturesProfile.class)
|
||||
class EcsServiceDiscoveryDockerIntegrationTest {
|
||||
|
||||
private static final String REGION = "us-east-1";
|
||||
@@ -51,20 +55,6 @@ class EcsServiceDiscoveryDockerIntegrationTest {
|
||||
private static final String CLOUD_MAP_SERVICE_NAME = "cache";
|
||||
private static final String ECS_SERVICE_NAME = "cache-svc";
|
||||
|
||||
/**
|
||||
* The registration hooks only run for a task with a container behind it, so ECS runs
|
||||
* unmocked. Security-group enforcement goes back to its shipped default of off: the test
|
||||
* suite turns it on, and its helper needs rootful Docker, which is a requirement of security
|
||||
* groups rather than of service discovery.
|
||||
*/
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
EcsService ecsService;
|
||||
|
||||
|
||||
@@ -5,14 +5,36 @@ import io.quarkus.test.junit.QuarkusTestProfile;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Turns {@code floci.auth.validate-signatures} on, and nothing else. Quarkus builds the application
|
||||
* once per distinct profile class, so the classes that need only this override share this one
|
||||
* rather than each declaring an identical nested profile.
|
||||
* Turns {@code floci.auth.validate-signatures} on, and carries the settings of two ECS classes that
|
||||
* share the application. Quarkus builds the application once per distinct profile class, and keeps
|
||||
* every one it built for the rest of the test JVM, so classes share this one rather than each
|
||||
* declaring their own.
|
||||
*
|
||||
* <p>The overrides, and who relies on them:
|
||||
* <ul>
|
||||
* <li>{@code floci.auth.validate-signatures=true} checks every request's SigV4 signature. The
|
||||
* signature, STS, presigned URL and SigV4a classes here rely on it.</li>
|
||||
* <li>{@code floci.services.ecs.mock=false} runs ECS tasks as real containers, and
|
||||
* {@code floci.network.security-group-enforcement.enabled=false} puts security groups back to
|
||||
* their shipped default of off, since the enforcement helper needs rootful Docker.
|
||||
* {@code EcsServiceDiscoveryDockerIntegrationTest} and {@code EcsLeftoverContainersDockerIntegrationTest}
|
||||
* rely on them.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>Each override is inert for the other classes: the ECS classes drive ECS through its injected
|
||||
* services, so no request of theirs is signed or checked, and no signature class starts an ECS task
|
||||
* or a container that security groups would govern.
|
||||
*
|
||||
* <p>A class joins if every setting here is either one it relies on or one that never reaches its
|
||||
* requests, and if any setting it adds never reaches the requests of a class already here.
|
||||
*/
|
||||
public class ValidateSignaturesProfile implements QuarkusTestProfile {
|
||||
|
||||
@Override
|
||||
public Map<String, String> getConfigOverrides() {
|
||||
return Map.of("floci.auth.validate-signatures", "true");
|
||||
return Map.of(
|
||||
"floci.auth.validate-signatures", "true",
|
||||
"floci.services.ecs.mock", "false",
|
||||
"floci.network.security-group-enforcement.enabled", "false");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user