test(rds): share the RDS and DocumentDB mock test profiles instead of ten identical ones (#4183)

Ten test classes declared an identical nested profile for the RDS and
DocumentDB mock configuration. Quarkus restarts and re-augments the
application once per distinct profile class, so ten copies meant ten starts
for three distinct configurations. Share one profile class per configuration
instead, leaving the classes that need extra overrides on their own.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-09-22 20:00:51 -05:00
1 parent 04b75fd1f5
commit 60b4e3fb82
13 files changed
+72 -108

No files matched your search

@@ -1,14 +1,12 @@
package io.github.hectorvent.floci.services.cloudformation;
import io.github.hectorvent.floci.testing.RdsMockProfile;
import io.github.hectorvent.floci.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.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@@ -27,7 +25,7 @@ import static org.junit.jupiter.api.Assertions.fail;
* leaves the whole suite green and breaks {@code ssm-secure} on the one resource that accepts it.
*/
@QuarkusTest
@TestProfile(CloudFormationRdsDynamicReferenceIntegrationTest.RdsMockProfile.class)
@TestProfile(RdsMockProfile.class)
class CloudFormationRdsDynamicReferenceIntegrationTest {
private static final String CFN_AUTH =
@@ -190,11 +188,4 @@ class CloudFormationRdsDynamicReferenceIntegrationTest {
}
fail("stack " + stackName + " was not deleted within the timeout");
}
public static final class RdsMockProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.rds.mock", "true");
}
}
}
@@ -3,15 +3,13 @@ package io.github.hectorvent.floci.services.cloudformation;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.core.common.XmlParser;
import io.github.hectorvent.floci.testing.RdsMockProfile;
import io.github.hectorvent.floci.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.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -20,7 +18,7 @@ import static org.junit.jupiter.api.Assertions.fail;
/** End-to-end coverage for attaching and detaching an external secret from an RDS target. */
@QuarkusTest
@TestProfile(CloudFormationSecretTargetAttachmentIntegrationTest.RdsMockProfile.class)
@TestProfile(RdsMockProfile.class)
class CloudFormationSecretTargetAttachmentIntegrationTest {
private static final String CFN_AUTH =
@@ -415,11 +413,4 @@ class CloudFormationSecretTargetAttachmentIntegrationTest {
}
fail("stack " + stackName + " was not deleted within the timeout");
}
public static final class RdsMockProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.rds.mock", "true");
}
}
}
@@ -3,16 +3,14 @@ package io.github.hectorvent.floci.services.docdb;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.services.ec2.model.SecurityGroup;
import io.github.hectorvent.floci.services.kms.KmsService;
import io.github.hectorvent.floci.testing.RdsAndDocDbMockProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import io.restassured.specification.RequestSpecification;
import jakarta.inject.Inject;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import java.util.Map;
import static io.restassured.RestAssured.given;
import static io.restassured.http.ContentType.URLENC;
import static org.hamcrest.Matchers.containsString;
@@ -23,16 +21,9 @@ import static org.hamcrest.Matchers.containsString;
* default subnet group, parameter group and security group.
*/
@QuarkusTest
@TestProfile(DocDbClusterSettingsIntegrationTest.NoContainersProfile.class)
@TestProfile(RdsAndDocDbMockProfile.class)
class DocDbClusterSettingsIntegrationTest {
public static class NoContainersProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.rds.mock", "true", "floci.services.docdb.mock", "true");
}
}
private static final String ID = "settings-cluster";
@Inject
@@ -1,14 +1,12 @@
package io.github.hectorvent.floci.services.docdb;
import io.github.hectorvent.floci.testing.DocDbMockProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import io.restassured.specification.RequestSpecification;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;
import java.util.Map;
import static io.restassured.RestAssured.given;
import static io.restassured.http.ContentType.URLENC;
import static org.hamcrest.Matchers.containsString;
@@ -25,16 +23,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
* region it was in fact created under.
*/
@QuarkusTest
@TestProfile(DocDbLegacyRecordArnIntegrationTest.NoContainersProfile.class)
@TestProfile(DocDbMockProfile.class)
class DocDbLegacyRecordArnIntegrationTest {
public static class NoContainersProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.docdb.mock", "true");
}
}
@Inject
DocDbService service;
@@ -1,14 +1,12 @@
package io.github.hectorvent.floci.services.docdb;
import io.github.hectorvent.floci.testing.DocDbMockProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import io.restassured.specification.RequestSpecification;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;
import java.util.Map;
import static io.restassured.RestAssured.given;
import static io.restassured.http.ContentType.URLENC;
import static org.hamcrest.Matchers.containsString;
@@ -24,16 +22,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* were keyed by identifier alone — so the name a caller used in one region was spent everywhere.
*/
@QuarkusTest
@TestProfile(DocDbRegionScopedIdentifierIntegrationTest.NoContainersProfile.class)
@TestProfile(DocDbMockProfile.class)
class DocDbRegionScopedIdentifierIntegrationTest {
public static class NoContainersProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.docdb.mock", "true");
}
}
@Inject
DocDbService service;
@@ -1,8 +1,8 @@
package io.github.hectorvent.floci.services.docdb;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.testing.DocDbMockProfile;
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;
@@ -24,17 +24,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* that no describe created and no delete can remove.
*/
@QuarkusTest
@TestProfile(DocDbTagConcurrencyTest.NoContainersProfile.class)
@TestProfile(DocDbMockProfile.class)
class DocDbTagConcurrencyTest {
/** The race is in storage, not in the container: starting one per attempt only adds seconds. */
public static class NoContainersProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.docdb.mock", "true");
}
}
@Inject
DocDbService service;
@@ -1,14 +1,12 @@
package io.github.hectorvent.floci.services.docdb;
import io.github.hectorvent.floci.testing.RdsAndDocDbMockProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import io.restassured.specification.RequestSpecification;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import java.util.Map;
import static io.restassured.RestAssured.given;
import static io.restassured.http.ContentType.URLENC;
import static org.hamcrest.Matchers.containsString;
@@ -22,17 +20,9 @@ import static org.hamcrest.Matchers.not;
* CLIs sign with the {@code rds} scope, and Floci accepts {@code docdb} as well.
*/
@QuarkusTest
@TestProfile(RdsFamilyListingIntegrationTest.NoContainersProfile.class)
@TestProfile(RdsAndDocDbMockProfile.class)
class RdsFamilyListingIntegrationTest {
public static class NoContainersProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.rds.mock", "true",
"floci.services.docdb.mock", "true");
}
}
private static final String AURORA = "family-aurora";
private static final String DOCS = "family-docs";
private static final String DOCS_INSTANCE = "family-docs-1";
@@ -1,8 +1,8 @@
package io.github.hectorvent.floci.services.docdb;
import io.github.hectorvent.floci.services.rds.RdsService;
import io.github.hectorvent.floci.testing.RdsAndDocDbMockProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import io.restassured.specification.RequestSpecification;
import jakarta.inject.Inject;
@@ -25,18 +25,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* name in different stores would share one ARN, and no tag call could say which was meant.
*/
@QuarkusTest
@TestProfile(SharedClusterIdentifierIntegrationTest.NoContainersProfile.class)
@TestProfile(RdsAndDocDbMockProfile.class)
class SharedClusterIdentifierIntegrationTest {
/** Neither engine's container is what this is about, and starting one costs the test 30s. */
public static class NoContainersProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.rds.mock", "true",
"floci.services.docdb.mock", "true");
}
}
@Inject
DocDbService docDbService;
@@ -1,13 +1,11 @@
package io.github.hectorvent.floci.services.rds;
import io.github.hectorvent.floci.testing.RdsMockProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import java.util.Map;
import static io.restassured.RestAssured.given;
import static io.restassured.http.ContentType.URLENC;
import static org.hamcrest.Matchers.containsString;
@@ -20,16 +18,9 @@ import static org.hamcrest.Matchers.containsString;
* reports EngineMode (defaulting to provisioned) in DescribeDBClusters, same as StorageEncrypted.
*/
@QuarkusTest
@TestProfile(RdsClusterEngineModeStorageEncryptedIntegrationTest.NoContainersProfile.class)
@TestProfile(RdsMockProfile.class)
class RdsClusterEngineModeStorageEncryptedIntegrationTest {
public static class NoContainersProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.rds.mock", "true");
}
}
private static final String ID = "engine-mode-cluster";
private static final String NON_AURORA_ID = "engine-mode-non-aurora-cluster";
@@ -1,15 +1,13 @@
package io.github.hectorvent.floci.services.rds;
import io.github.hectorvent.floci.testing.RdsMockProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.response.ValidatableResponse;
import io.restassured.specification.RequestSpecification;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import java.util.Map;
import static io.restassured.RestAssured.given;
import static io.restassured.http.ContentType.URLENC;
import static org.hamcrest.Matchers.containsString;
@@ -25,16 +23,9 @@ import static org.hamcrest.Matchers.not;
* <p>Each member's documented default and valid values come from the RDS model.
*/
@QuarkusTest
@TestProfile(RdsInstanceMonitoringFieldsIntegrationTest.NoContainersProfile.class)
@TestProfile(RdsMockProfile.class)
class RdsInstanceMonitoringFieldsIntegrationTest {
public static class NoContainersProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.rds.mock", "true");
}
}
private static final String ID = "monitoring-fields-db";
private static final String ROLE = "arn:aws:iam::000000000000:role/rds-monitoring-role";
private static final String RESULT =
@@ -0,0 +1,18 @@
package io.github.hectorvent.floci.testing;
import io.quarkus.test.junit.QuarkusTestProfile;
import java.util.Map;
/**
* Mocks the DocumentDB container layer, and nothing else. DocumentDB shares the RDS API surface,
* so this deliberately leaves {@code floci.services.rds.mock} alone: the classes using it exercise
* those shared paths unmocked.
*/
public class DocDbMockProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.docdb.mock", "true");
}
}
@@ -0,0 +1,16 @@
package io.github.hectorvent.floci.testing;
import io.quarkus.test.junit.QuarkusTestProfile;
import java.util.Map;
/**
* Mocks both the RDS and the DocumentDB container layers, for the classes that span the two.
*/
public class RdsAndDocDbMockProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.rds.mock", "true", "floci.services.docdb.mock", "true");
}
}
@@ -0,0 +1,18 @@
package io.github.hectorvent.floci.testing;
import io.quarkus.test.junit.QuarkusTestProfile;
import java.util.Map;
/**
* Mocks the RDS container layer, and nothing else. Quarkus restarts and re-augments 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.
*/
public class RdsMockProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.rds.mock", "true");
}
}