diff --git a/src/test/java/io/floci/aws/services/ecs/EcsBackgroundTaskLaunchIntegrationTest.java b/src/test/java/io/floci/aws/services/ecs/EcsBackgroundTaskLaunchIntegrationTest.java index 65c97124a8..bd79873228 100644 --- a/src/test/java/io/floci/aws/services/ecs/EcsBackgroundTaskLaunchIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ecs/EcsBackgroundTaskLaunchIntegrationTest.java @@ -7,6 +7,7 @@ import io.floci.aws.services.ecs.container.EcsTaskHandle; import io.floci.aws.services.ecs.model.ContainerDefinition; import io.floci.aws.services.ecs.model.EcsTask; import io.floci.aws.services.ecs.model.LaunchType; +import io.floci.aws.testing.CloudFormationSettingsProfile; import io.quarkus.test.InjectMock; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; @@ -31,7 +32,7 @@ import static org.mockito.Mockito.when; * so this runs in Quarkus, in Docker mode over a container manager that starts nothing for real. */ @QuarkusTest -@TestProfile(EcsBackgroundTaskStopIntegrationTest.DockerModeProfile.class) +@TestProfile(CloudFormationSettingsProfile.class) class EcsBackgroundTaskLaunchIntegrationTest { private static final String REGION = "us-east-1"; diff --git a/src/test/java/io/floci/aws/services/ecs/EcsBackgroundTaskStopIntegrationTest.java b/src/test/java/io/floci/aws/services/ecs/EcsBackgroundTaskStopIntegrationTest.java index f3dc9f5c5a..f1ef5e1b08 100644 --- a/src/test/java/io/floci/aws/services/ecs/EcsBackgroundTaskStopIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ecs/EcsBackgroundTaskStopIntegrationTest.java @@ -7,9 +7,9 @@ import io.floci.aws.services.ecs.model.Container; import io.floci.aws.services.ecs.model.ContainerDefinition; import io.floci.aws.services.ecs.model.EcsTask; import io.floci.aws.services.ecs.model.LaunchType; +import io.floci.aws.testing.CloudFormationSettingsProfile; import io.quarkus.test.InjectMock; 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.Test; @@ -32,24 +32,16 @@ import static org.mockito.Mockito.when; * request context, and account-aware storage reads the account from that context. Only a running * Arc container has one, so this runs in Quarkus, in Docker mode over a container manager that * stops nothing for real: a stop that landed in the wrong account would leave the task's own - * cluster still counting it. + * cluster still counting it. {@link CloudFormationSettingsProfile} turns Docker mode on, with no + * sweep of a previous run's containers, which the mock would refuse. */ @QuarkusTest -@TestProfile(EcsBackgroundTaskStopIntegrationTest.DockerModeProfile.class) +@TestProfile(CloudFormationSettingsProfile.class) class EcsBackgroundTaskStopIntegrationTest { private static final String REGION = "us-east-1"; private static final String ACCOUNT = "111122223333"; - /** Docker mode, with no sweep of a previous run's containers, which the mock would refuse. */ - public static final class DockerModeProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of("floci.services.ecs.mock", "false", - "floci.services.ecs.reconcile-containers-on-startup", "false"); - } - } - @Inject EcsService ecsService; diff --git a/src/test/java/io/floci/aws/services/kinesis/KinesisStatusWindowIntegrationTest.java b/src/test/java/io/floci/aws/services/kinesis/KinesisStatusWindowIntegrationTest.java index 089022a48d..63ea0613ce 100644 --- a/src/test/java/io/floci/aws/services/kinesis/KinesisStatusWindowIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/kinesis/KinesisStatusWindowIntegrationTest.java @@ -1,10 +1,10 @@ package io.floci.aws.services.kinesis; import io.floci.aws.services.kinesis.model.KinesisStream; +import io.floci.aws.testing.CloudFormationSettingsProfile; import io.floci.aws.testing.PartitionCleanup; import io.floci.aws.testing.RestAssuredJsonUtils; 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.BeforeAll; @@ -12,12 +12,15 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import java.time.Instant; -import java.util.Map; import static org.hamcrest.Matchers.equalTo; +/** + * A stream is seen CREATING and UPDATING over the wire. The delays, a minute each, come from + * {@link CloudFormationSettingsProfile}, so nothing moves on while the test runs. + */ @QuarkusTest -@TestProfile(KinesisStatusWindowIntegrationTest.WindowProfile.class) +@TestProfile(CloudFormationSettingsProfile.class) class KinesisStatusWindowIntegrationTest { private static final String KINESIS_TARGET = "Kinesis_20131202"; @@ -97,12 +100,4 @@ class KinesisStatusWindowIntegrationTest { .statusCode(200) .body("StreamDescription.StreamStatus", equalTo("ACTIVE")); } - - public static final class WindowProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of("floci.services.kinesis.creating-delay-millis", "60000", - "floci.services.kinesis.updating-delay-millis", "60000"); - } - } } diff --git a/src/test/java/io/floci/aws/services/rds/RdsTemplateDatabaseRestoreIntegrationTest.java b/src/test/java/io/floci/aws/services/rds/RdsTemplateDatabaseRestoreIntegrationTest.java index b24872ffa0..dd8500e069 100644 --- a/src/test/java/io/floci/aws/services/rds/RdsTemplateDatabaseRestoreIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/rds/RdsTemplateDatabaseRestoreIntegrationTest.java @@ -1,14 +1,12 @@ package io.floci.aws.services.rds; +import io.floci.aws.testing.CloudFormationSettingsProfile; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.junit.QuarkusTestProfile; import io.quarkus.test.junit.TestProfile; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import java.util.Map; - import static io.floci.aws.testing.RdsRequests.assumeDocker; import static io.floci.aws.testing.RdsRequests.deleteInstance; import static io.floci.aws.testing.RdsRequests.rds; @@ -17,20 +15,14 @@ import static org.junit.jupiter.api.Assertions.assertEquals; /** * A snapshot restores on an image that creates a template database at startup, such as PostGIS's - * {@code template_postgis}, which the snapshot's dump creates again. + * {@code template_postgis}, which the snapshot's dump creates again. The PostGIS image is the + * default PostgreSQL image {@link CloudFormationSettingsProfile} sets. */ @QuarkusTest @Tag("docker") -@TestProfile(RdsTemplateDatabaseRestoreIntegrationTest.PostgisImageProfile.class) +@TestProfile(CloudFormationSettingsProfile.class) class RdsTemplateDatabaseRestoreIntegrationTest { - public static class PostgisImageProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of("floci.services.rds.default-postgres-image", "postgis/postgis:17-3.5-alpine"); - } - } - @BeforeEach void checkDocker() throws InterruptedException { assumeDocker(); diff --git a/src/test/java/io/floci/aws/testing/CloudFormationSettingsProfile.java b/src/test/java/io/floci/aws/testing/CloudFormationSettingsProfile.java index 97682f6221..699f43a1a1 100644 --- a/src/test/java/io/floci/aws/testing/CloudFormationSettingsProfile.java +++ b/src/test/java/io/floci/aws/testing/CloudFormationSettingsProfile.java @@ -47,12 +47,24 @@ import java.util.Map; * {@code cdi} mode with the device the {@value #SAGEMAKER_GPU_CDI_DEVICE_PROPERTY} system property * names, or in {@code count} mode when it names none. {@code SageMakerGpuDockerIntegrationTest} * relies on it. + *
  • {@code floci.services.ecs.mock=false} runs ECS in Docker mode, and + * {@code floci.services.ecs.reconcile-containers-on-startup=false} leaves a previous run's + * containers unswept at boot. {@code EcsBackgroundTaskStopIntegrationTest} and + * {@code EcsBackgroundTaskLaunchIntegrationTest} rely on them, over a container manager that + * starts and stops nothing for real.
  • + *
  • {@code floci.services.kinesis.creating-delay-millis} and {@code updating-delay-millis}, a + * minute each, keep a stream CREATING and UPDATING for the whole test. + * {@code KinesisStatusWindowIntegrationTest} relies on them.
  • + *
  • {@code floci.services.rds.default-postgres-image=postgis/postgis:17-3.5-alpine} starts a + * PostgreSQL instance on an image that creates a template database at startup. + * {@code RdsTemplateDatabaseRestoreIntegrationTest} relies on it.
  • * * *

    Each override is inert for the other classes: each is read by a single service, CloudFormation, * the Timestream for InfluxDB data plane, an EKS cluster's container start, the EMR and EMR - * Serverless runners, CloudFront, DynamoDB and SageMaker training, and no other class here calls - * that service. The persistent path is the one setting every class sees: it moves where this + * Serverless runners, CloudFront, DynamoDB, SageMaker training, ECS, Kinesis and RDS, and no other + * class here calls that service. Boot-time reconciliation only acts on containers a previous run + * left, which this application never adopts. The persistent path is the one setting every class sees: it moves where this * application writes what services keep on disk whatever their storage mode, Timestream backups and * Lambda code-volume markers among them, each under a directory of its own, and DynamoDB is the only * service here that stores its records there. @@ -91,7 +103,12 @@ public class CloudFormationSettingsProfile implements QuarkusTestProfile { Map.entry("floci.storage.services.dynamodb.item-layout", "per-table"), Map.entry("floci.storage.services.dynamodb.item-shards", "4"), Map.entry("floci.storage.persistent-path", DYNAMODB_PARTITIONED_STORAGE_DIR), - Map.entry("floci.services.sagemaker.gpu.enabled", "true"))); + Map.entry("floci.services.sagemaker.gpu.enabled", "true"), + Map.entry("floci.services.ecs.mock", "false"), + Map.entry("floci.services.ecs.reconcile-containers-on-startup", "false"), + Map.entry("floci.services.kinesis.creating-delay-millis", "60000"), + Map.entry("floci.services.kinesis.updating-delay-millis", "60000"), + Map.entry("floci.services.rds.default-postgres-image", "postgis/postgis:17-3.5-alpine"))); String device = System.getProperty(SAGEMAKER_GPU_CDI_DEVICE_PROPERTY); if (device != null && !device.isBlank()) { overrides.put("floci.services.sagemaker.gpu.mode", "cdi");