From 8418c7e674f1b668ee9d90fae3cf363b8f499755 Mon Sep 17 00:00:00 2001 From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com> Date: Wed, 18 Nov 2026 00:57:54 -0400 Subject: [PATCH] test: fold two Quarkus test profiles into DynamoDbPartitionedWalStorageProfile (#8828) 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. The profiles nested in Ec2MockPublicAddressIntegrationTest (documentation public addresses) and GlobalCorsFilterAliasIntegrationTest (the EXTRA_CORS_ALLOWED_ORIGINS alias) now share DynamoDbPartitionedWalStorageProfile: the address range only reaches EC2 instances, the origin only requests that send it, and DynamoDB storage only DynamoDB requests, which no other class here sends. --- .../GlobalCorsFilterAliasIntegrationTest.java | 17 ++++------ .../Ec2MockPublicAddressIntegrationTest.java | 17 ++++------ .../DynamoDbPartitionedWalStorageProfile.java | 34 ++++++++++++++++--- 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/test/java/io/floci/aws/core/common/GlobalCorsFilterAliasIntegrationTest.java b/src/test/java/io/floci/aws/core/common/GlobalCorsFilterAliasIntegrationTest.java index 14753e5231..7da42b80ac 100644 --- a/src/test/java/io/floci/aws/core/common/GlobalCorsFilterAliasIntegrationTest.java +++ b/src/test/java/io/floci/aws/core/common/GlobalCorsFilterAliasIntegrationTest.java @@ -1,20 +1,22 @@ package io.floci.aws.core.common; +import io.floci.aws.testing.DynamoDbPartitionedWalStorageProfile; 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 org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import java.util.Map; - import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; +/** + * {@code EXTRA_CORS_ALLOWED_ORIGINS}, the environment-style alias of the extra CORS origins setting, + * set to {@code http://localhost:4000} by {@link DynamoDbPartitionedWalStorageProfile}. + */ @QuarkusTest -@TestProfile(GlobalCorsFilterAliasIntegrationTest.AliasProfile.class) +@TestProfile(DynamoDbPartitionedWalStorageProfile.class) public class GlobalCorsFilterAliasIntegrationTest { @BeforeAll @@ -45,11 +47,4 @@ public class GlobalCorsFilterAliasIntegrationTest { .statusCode(403) .header("Access-Control-Allow-Origin", nullValue()); } - - public static final class AliasProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of("EXTRA_CORS_ALLOWED_ORIGINS", "http://localhost:4000"); - } - } } diff --git a/src/test/java/io/floci/aws/services/ec2/Ec2MockPublicAddressIntegrationTest.java b/src/test/java/io/floci/aws/services/ec2/Ec2MockPublicAddressIntegrationTest.java index f20bd8c853..3e3db77974 100644 --- a/src/test/java/io/floci/aws/services/ec2/Ec2MockPublicAddressIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ec2/Ec2MockPublicAddressIntegrationTest.java @@ -3,9 +3,9 @@ package io.floci.aws.services.ec2; import io.floci.aws.core.common.RequestScopes; import io.floci.aws.services.autoscaling.AutoScalingReconciler; import io.floci.aws.services.autoscaling.AutoScalingService; +import io.floci.aws.testing.DynamoDbPartitionedWalStorageProfile; import io.floci.aws.testing.EnforcementFixtures; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.junit.QuarkusTestProfile; import io.quarkus.test.junit.TestProfile; import io.restassured.path.xml.XmlPath; import io.restassured.response.ValidatableResponse; @@ -17,7 +17,6 @@ import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.ValueSource; import java.util.List; -import java.util.Map; import java.util.concurrent.atomic.AtomicLong; import static io.restassured.RestAssured.given; @@ -27,8 +26,12 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +/** + * Mock instances due an automatic address take one from 203.0.113.0/24, as + * {@link DynamoDbPartitionedWalStorageProfile} sets. + */ @QuarkusTest -@TestProfile(Ec2MockPublicAddressIntegrationTest.DocumentationAddresses.class) +@TestProfile(DynamoDbPartitionedWalStorageProfile.class) class Ec2MockPublicAddressIntegrationTest { private static final AtomicLong ACCOUNTS = new AtomicLong(722000000000L); private static final String DOCUMENTATION_ADDRESS = "203\\.0\\.113\\.([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-4])"; @@ -730,12 +733,4 @@ class Ec2MockPublicAddressIntegrationTest { String service = action.contains("AutoScaling") ? "autoscaling" : "ec2"; return given().formParam("Action", action).header("Authorization", EnforcementFixtures.auth(owner, service)); } - - /** Mock instances due an automatic address take one from 203.0.113.0/24. */ - public static class DocumentationAddresses implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of("floci.services.ec2.mock-public-addresses", "documentation"); - } - } } diff --git a/src/test/java/io/floci/aws/testing/DynamoDbPartitionedWalStorageProfile.java b/src/test/java/io/floci/aws/testing/DynamoDbPartitionedWalStorageProfile.java index dcc9b96905..bc216a2c34 100644 --- a/src/test/java/io/floci/aws/testing/DynamoDbPartitionedWalStorageProfile.java +++ b/src/test/java/io/floci/aws/testing/DynamoDbPartitionedWalStorageProfile.java @@ -6,9 +6,33 @@ import java.util.Map; /** * DynamoDB in {@code wal} mode with its items in the {@code per-table} layout, split into four - * shards, on a directory of its own. Every other service stays on the test default, memory. - * {@code DynamoDbPartitionedWalStorageIntegrationTest} relies on all of it: it checks that the - * configuration reaches the item store and that the item store writes the journal and shards. + * shards, on a directory of its own, and the settings of two other classes that share the + * application. Every other service stays on the test default, memory. Quarkus builds the + * application once per distinct profile class, and keeps every one it built for the rest of the + * test JVM, 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 classes: DynamoDB storage only reaches DynamoDB requests, + * the address range only an EC2 instance due an automatic public address, and the extra origin only + * a request that sends that {@code Origin}, and no other class here makes such a request. The + * persistent path moves where this application writes what services keep on disk whatever their + * storage mode, each under its own directory. + * + *

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 DynamoDbPartitionedWalStorageProfile implements QuarkusTestProfile { @@ -20,6 +44,8 @@ public class DynamoDbPartitionedWalStorageProfile implements QuarkusTestProfile "floci.storage.services.dynamodb.mode", "wal", "floci.storage.services.dynamodb.item-layout", "per-table", "floci.storage.services.dynamodb.item-shards", "4", - "floci.storage.persistent-path", STORAGE_DIR); + "floci.storage.persistent-path", STORAGE_DIR, + "floci.services.ec2.mock-public-addresses", "documentation", + "EXTRA_CORS_ALLOWED_ORIGINS", "http://localhost:4000"); } }