test: share four duplicated Quarkus test profiles (#4249)

Nine nested @TestProfile classes across eleven test classes declared
config overrides that were byte-for-byte identical in four groups.
Quarkus augments the application once per distinct profile class, so
each duplicate paid a full build that an already-built profile would
have covered.

Move the four sets into io.github.hectorvent.floci.testing as
S3EnforceAuthProfile, S3IamEnforcementProfile, ConfiguredHostnameProfile
and SynchronousBillingEmissionProfile, and point the test classes at
them. The effective config for every class is unchanged; this only
removes redundant augmentations.

Distinct test profiles across src/test/java drop from 85 to 80.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-09-23 18:08:06 -05:00
1 parent 2e21c013c5
commit 9956b684db
15 files changed
+102 -115

No files matched your search

@@ -1,8 +1,8 @@
package io.github.hectorvent.floci.services.apigateway;
import com.sun.net.httpserver.HttpServer;
import io.github.hectorvent.floci.testing.ConfiguredHostnameProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.AfterAll;
@@ -15,14 +15,13 @@ import org.junit.jupiter.api.TestMethodOrder;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
@QuarkusTest
@TestProfile(ApiGatewayExecuteApiHostIntegrationTest.ConfiguredHostnameProfile.class)
@TestProfile(ConfiguredHostnameProfile.class)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class ApiGatewayExecuteApiHostIntegrationTest {
@@ -329,11 +328,4 @@ class ApiGatewayExecuteApiHostIntegrationTest {
.then()
.statusCode(201);
}
public static class ConfiguredHostnameProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.hostname", "floci");
}
}
}
@@ -7,8 +7,8 @@ import io.github.hectorvent.floci.services.cloudfront.model.DistributionConfig;
import io.github.hectorvent.floci.services.cloudfront.model.Origin;
import io.github.hectorvent.floci.services.cloudfront.model.OriginAccessControl;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.testing.S3EnforceAuthProfile;
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;
@@ -22,7 +22,7 @@ import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
@QuarkusTest
@TestProfile(CloudFrontS3AuthServingTest.S3AuthProfile.class)
@TestProfile(S3EnforceAuthProfile.class)
class CloudFrontS3AuthServingTest {
@Inject
@@ -225,11 +225,4 @@ class CloudFrontS3AuthServingTest {
+ "/20260730/us-east-1/s3/aws4_request, "
+ "SignedHeaders=host;x-amz-date, Signature=abc123";
}
public static final class S3AuthProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.s3.enforce-auth", "true");
}
}
}
@@ -3,15 +3,14 @@ package io.github.hectorvent.floci.services.cur;
import io.github.hectorvent.floci.services.floci.duck.FlociDuckClient;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.github.hectorvent.floci.testing.SynchronousBillingEmissionProfile;
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;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -35,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
* {@link ParquetEmitterIntegrationTest} for prerequisites.
*/
@QuarkusTest
@TestProfile(CurEmissionIntegrationTest.SyncProfile.class)
@TestProfile(SynchronousBillingEmissionProfile.class)
@EnabledIfEnvironmentVariable(named = "FLOCI_DUCK_CROSS_CONTAINER_TEST", matches = "1|true|yes")
class CurEmissionIntegrationTest {
@@ -45,22 +44,6 @@ class CurEmissionIntegrationTest {
private static final String S3_AUTH =
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/s3/aws4_request";
/**
* Wires the full sync path: emit-mode=synchronous, fixed Floci HTTP port so
* the DuckDB sidecar can reach Floci S3 over the network.
*/
public static final class SyncProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
Map<String, String> o = new HashMap<>();
o.put("quarkus.http.test-port", "4566");
o.put("floci.base-url", "http://localhost:4566");
o.put("floci.services.cur.emit-mode", "synchronous");
o.put("floci.services.bcm-data-exports.emit-mode", "synchronous");
return o;
}
}
@BeforeAll
static void configureRestAssured() {
RestAssuredJsonUtils.configureAwsContentTypes();
@@ -1,16 +1,13 @@
package io.github.hectorvent.floci.services.cur;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.github.hectorvent.floci.testing.SynchronousBillingEmissionProfile;
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 org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.anyOf;
@@ -30,7 +27,7 @@ import static org.hamcrest.Matchers.equalTo;
* {@link ParquetEmitterIntegrationTest} for prerequisites.
*/
@QuarkusTest
@TestProfile(CurNonDefaultAccountEmissionIntegrationTest.SyncProfile.class)
@TestProfile(SynchronousBillingEmissionProfile.class)
@EnabledIfEnvironmentVariable(named = "FLOCI_DUCK_CROSS_CONTAINER_TEST", matches = "1|true|yes")
class CurNonDefaultAccountEmissionIntegrationTest {
@@ -41,18 +38,6 @@ class CurNonDefaultAccountEmissionIntegrationTest {
private static final String S3_AUTH =
"AWS4-HMAC-SHA256 Credential=" + ACCOUNT_ID + "/20260101/us-east-1/s3/aws4_request";
public static final class SyncProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
Map<String, String> o = new HashMap<>();
o.put("quarkus.http.test-port", "4566");
o.put("floci.base-url", "http://localhost:4566");
o.put("floci.services.cur.emit-mode", "synchronous");
o.put("floci.services.bcm-data-exports.emit-mode", "synchronous");
return o;
}
}
@BeforeAll
static void configureRestAssured() {
RestAssuredJsonUtils.configureAwsContentTypes();
@@ -1,17 +1,15 @@
package io.github.hectorvent.floci.services.iot;
import io.github.hectorvent.floci.testing.ConfiguredHostnameProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import org.junit.jupiter.api.Test;
import java.util.Map;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
@QuarkusTest
@TestProfile(IotEndpointHostnameIntegrationTest.HostnameProfile.class)
@TestProfile(ConfiguredHostnameProfile.class)
class IotEndpointHostnameIntegrationTest {
@Test
@@ -23,11 +21,4 @@ class IotEndpointHostnameIntegrationTest {
.statusCode(200)
.body("endpointAddress", equalTo("floci:4566"));
}
public static class HostnameProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.hostname", "floci");
}
}
}
@@ -3,8 +3,8 @@ package io.github.hectorvent.floci.services.redshift;
import io.github.hectorvent.floci.services.iam.IamService;
import io.github.hectorvent.floci.services.redshift.model.Cluster;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.testing.S3EnforceAuthProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import jakarta.inject.Inject;
import org.awaitility.Awaitility;
@@ -29,11 +29,11 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Covers COPY IAM_ROLE authorization when {@code FLOCI_SERVICES_S3_ENFORCE_AUTH} is on, so the
* role's identity-based policy actually gates S3 access. Kept in its own {@code @QuarkusTest}
* class (own {@link EnforceAuthProfile}) because Quarkus restarts the application per distinct
* test profile; {@link RedshiftInterceptorIntegrationTest} runs with enforcement off.
* class (running under {@link S3EnforceAuthProfile}) because Quarkus restarts the application per
* distinct test profile; {@link RedshiftInterceptorIntegrationTest} runs with enforcement off.
*/
@QuarkusTest
@TestProfile(RedshiftInterceptorIamRoleEnforcedIntegrationTest.EnforceAuthProfile.class)
@TestProfile(S3EnforceAuthProfile.class)
class RedshiftInterceptorIamRoleEnforcedIntegrationTest {
private static final String REDSHIFT_TRUST_POLICY = """
@@ -131,11 +131,4 @@ class RedshiftInterceptorIamRoleEnforcedIntegrationTest {
}
}
}
public static final class EnforceAuthProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.s3.enforce-auth", "true");
}
}
}
@@ -1,10 +1,10 @@
package io.github.hectorvent.floci.services.s3;
import io.github.hectorvent.floci.services.iam.IamService;
import io.github.hectorvent.floci.testing.S3EnforceAuthProfile;
import io.github.hectorvent.floci.testutil.S3RequestSigner;
import io.restassured.specification.RequestSpecification;
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.MethodOrderer;
@@ -35,7 +35,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.not;
@QuarkusTest
@TestProfile(S3AuthEnforcementIntegrationTest.S3AuthProfile.class)
@TestProfile(S3EnforceAuthProfile.class)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class S3AuthEnforcementIntegrationTest {
@@ -2305,11 +2305,4 @@ class S3AuthEnforcementIntegrationTest {
</SelectObjectContentRequest>
""";
}
public static final class S3AuthProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.s3.enforce-auth", "true");
}
}
}
@@ -1,14 +1,13 @@
package io.github.hectorvent.floci.services.s3;
import io.github.hectorvent.floci.testing.S3IamEnforcementProfile;
import io.github.hectorvent.floci.testutil.S3RequestSigner;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import io.restassured.response.ExtractableResponse;
import io.restassured.response.Response;
import org.junit.jupiter.api.Test;
import java.util.Map;
import java.util.UUID;
import static io.restassured.RestAssured.given;
@@ -17,7 +16,7 @@ import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@QuarkusTest
@TestProfile(S3BucketPolicyEnforcementIntegrationTest.EnforcementProfile.class)
@TestProfile(S3IamEnforcementProfile.class)
class S3BucketPolicyEnforcementIntegrationTest {
private static final String REGION = "us-east-1";
@@ -31,17 +30,6 @@ class S3BucketPolicyEnforcementIntegrationTest {
}
}
public static final class EnforcementProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of(
"floci.services.s3.enforce-auth", "true",
"floci.services.iam.enforcement-enabled", "true",
"floci.services.s3.global-bucket-namespace", "true"
);
}
}
private static String auth(String accessKeyId, String service) {
return "AWS4-HMAC-SHA256 Credential=" + accessKeyId + "/20260629/" + REGION + "/" + service
+ "/aws4_request, SignedHeaders=host, Signature=abc";
@@ -1,12 +1,11 @@
package io.github.hectorvent.floci.services.s3;
import io.github.hectorvent.floci.testing.S3IamEnforcementProfile;
import io.github.hectorvent.floci.testutil.S3RequestSigner;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import org.junit.jupiter.api.Test;
import java.util.Map;
import java.util.UUID;
import static io.restassured.RestAssured.given;
@@ -20,7 +19,7 @@ import static org.hamcrest.Matchers.containsString;
* any object it could not otherwise read, as long as it could guess the bucket/key.
*/
@QuarkusTest
@TestProfile(S3CopyObjectSourcePermissionIntegrationTest.IamEnforcementProfile.class)
@TestProfile(S3IamEnforcementProfile.class)
class S3CopyObjectSourcePermissionIntegrationTest {
/**
@@ -521,14 +520,4 @@ class S3CopyObjectSourcePermissionIntegrationTest {
return "AWS4-HMAC-SHA256 Credential=" + accessKeyId + "/20260629/" + REGION + "/" + service
+ "/aws4_request, SignedHeaders=host, Signature=abc";
}
public static final class IamEnforcementProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of(
"floci.services.iam.enforcement-enabled", "true",
"floci.services.s3.enforce-auth", "true",
"floci.services.s3.global-bucket-namespace", "true");
}
}
}
@@ -1,5 +1,6 @@
package io.github.hectorvent.floci.services.s3;
import io.github.hectorvent.floci.testing.S3EnforceAuthProfile;
import io.github.hectorvent.floci.testutil.S3RequestSigner;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;
@@ -47,7 +48,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
* header must be set by hand).
*/
@QuarkusTest
@TestProfile(S3AuthEnforcementIntegrationTest.S3AuthProfile.class)
@TestProfile(S3EnforceAuthProfile.class)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class S3LeadingSlashKeyAuthEnforcementIntegrationTest {
@@ -1,5 +1,6 @@
package io.github.hectorvent.floci.services.s3;
import io.github.hectorvent.floci.testing.S3EnforceAuthProfile;
import io.github.hectorvent.floci.testutil.S3RequestSigner;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;
@@ -32,7 +33,7 @@ import static org.hamcrest.Matchers.not;
* query fallback, and that a tag parameter added after signing is rejected.
*/
@QuarkusTest
@TestProfile(S3AuthEnforcementIntegrationTest.S3AuthProfile.class)
@TestProfile(S3EnforceAuthProfile.class)
class S3PresignedTaggingSigV4EnforcementIntegrationTest {
private static final String BUCKET = "presigned-tagging-sigv4-bucket";
@@ -0,0 +1,17 @@
package io.github.hectorvent.floci.testing;
import io.quarkus.test.junit.QuarkusTestProfile;
import java.util.Map;
/**
* Sets an explicit {@code floci.hostname}, so a test can assert on the host a service advertises
* rather than on the default.
*/
public class ConfiguredHostnameProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.hostname", "floci");
}
}
@@ -0,0 +1,18 @@
package io.github.hectorvent.floci.testing;
import io.quarkus.test.junit.QuarkusTestProfile;
import java.util.Map;
/**
* Turns S3 request-signature enforcement 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.
*/
public class S3EnforceAuthProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.s3.enforce-auth", "true");
}
}
@@ -0,0 +1,20 @@
package io.github.hectorvent.floci.testing;
import io.quarkus.test.junit.QuarkusTestProfile;
import java.util.Map;
/**
* S3 auth enforcement, IAM enforcement and the global bucket namespace together, for the classes
* that need all three. {@link S3EnforceAuthProfile} covers the narrower case.
*/
public class S3IamEnforcementProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of(
"floci.services.s3.enforce-auth", "true",
"floci.services.iam.enforcement-enabled", "true",
"floci.services.s3.global-bucket-namespace", "true");
}
}
@@ -0,0 +1,23 @@
package io.github.hectorvent.floci.testing;
import io.quarkus.test.junit.QuarkusTestProfile;
import java.util.Map;
/**
* Wires the full sync path for the billing report emitters: emit-mode=synchronous plus a fixed
* Floci HTTP port, so the DuckDB sidecar can reach Floci S3 over the network. Quarkus builds the
* application once per distinct profile class, so the classes that need this share one profile
* rather than each declaring an identical nested copy.
*/
public class SynchronousBillingEmissionProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of(
"quarkus.http.test-port", "4566",
"floci.base-url", "http://localhost:4566",
"floci.services.cur.emit-mode", "synchronous",
"floci.services.bcm-data-exports.emit-mode", "synchronous");
}
}