mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
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.
This commit is contained in:
1 parent
240ab6b381
commit
8418c7e674
3 files changed
+42
-26
No files matched your search
@@ -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<String, String> getConfigOverrides() {
|
||||
return Map.of("EXTRA_CORS_ALLOWED_ORIGINS", "http://localhost:4000");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<String, String> getConfigOverrides() {
|
||||
return Map.of("floci.services.ec2.mock-public-addresses", "documentation");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
*
|
||||
* <p>The overrides, and who relies on them:
|
||||
* <ul>
|
||||
* <li>{@code floci.storage.services.dynamodb.mode=wal}, {@code item-layout=per-table},
|
||||
* {@code item-shards=4} and {@code floci.storage.persistent-path=}{@value #STORAGE_DIR}.
|
||||
* {@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.</li>
|
||||
* <li>{@code floci.services.ec2.mock-public-addresses=documentation} gives a mock instance due an
|
||||
* automatic public address one from 203.0.113.0/24. {@code Ec2MockPublicAddressIntegrationTest}
|
||||
* relies on it.</li>
|
||||
* <li>{@code EXTRA_CORS_ALLOWED_ORIGINS=http://localhost:4000}, the environment-style alias of
|
||||
* {@code floci.security.extra-cors-allowed-origins}, allows that one extra CORS origin.
|
||||
* {@code GlobalCorsFilterAliasIntegrationTest} relies on it, to check the alias.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>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.
|
||||
*
|
||||
* <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 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");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user