From e494e1aecf539bc3a292e004dd48e3c846234607 Mon Sep 17 00:00:00 2001 From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com> Date: Fri, 16 Oct 2026 08:55:40 -0400 Subject: [PATCH] test: fold the CloudFormation and IoT one-off profiles into shared ones (#5791) Slice 8 of #4542. Three CloudFormation classes each declared a profile for one setting, and ApiGatewayV2DomainCfnIntegrationTest borrowed the strict one. All four now use CloudFormationSettingsProfile, which carries the three settings: an unsupported resource type fails instead of being stubbed, Lambda code that cannot be read falls back to the stub handler, and a deleted stack is retained for a day. Each only reaches the class that tests it: the other templates declare only types Floci provisions and no Lambda function, and only the race test lists stacks or looks one up by its id after a delete. The two IoT classes that changed a default, the DescribeEndpoint address and strict rule SQL, share IotSettingsProfile. The address only changes what DescribeEndpoint and the AWS-managed domain configurations report, which the rule test never reads, and strict SQL only changes how a topic rule is created, which the endpoint test never does. Why the race test keeps a deleted stack for a day, the test clock advancing on every read, moves from the retired profile's javadoc to the class javadoc. IotTopicRuleSqlStrictIntegrationTest gains a class javadoc saying what strict mode changes. --- .../ApiGatewayV2DomainCfnIntegrationTest.java | 3 +- ...dFormationDeletedStackListingRaceTest.java | 24 ++++------- ...nLambdaStubCodeAllowedIntegrationTest.java | 16 +++---- ...rtedResourceTypeStrictIntegrationTest.java | 16 +++---- ...scribeEndpointOverrideIntegrationTest.java | 19 +++------ .../IotTopicRuleSqlStrictIntegrationTest.java | 21 +++++----- .../CloudFormationSettingsProfile.java | 42 +++++++++++++++++++ .../floci/testing/IotSettingsProfile.java | 35 ++++++++++++++++ 8 files changed, 113 insertions(+), 63 deletions(-) create mode 100644 src/test/java/io/github/hectorvent/floci/testing/CloudFormationSettingsProfile.java create mode 100644 src/test/java/io/github/hectorvent/floci/testing/IotSettingsProfile.java diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayV2DomainCfnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayV2DomainCfnIntegrationTest.java index 7640f99866..0cb82cd035 100644 --- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayV2DomainCfnIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/ApiGatewayV2DomainCfnIntegrationTest.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import com.sun.net.httpserver.HttpServer; import io.github.hectorvent.floci.core.common.XmlParser; +import io.github.hectorvent.floci.testing.CloudFormationSettingsProfile; import io.github.hectorvent.floci.testing.RestAssuredJsonUtils; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; @@ -48,7 +49,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * domain under a key with several levels, which CDK maps with {@code AWS::ApiGatewayV2::ApiMapping}. */ @QuarkusTest -@TestProfile(CloudFormationUnsupportedResourceTypeStrictIntegrationTest.StrictProfile.class) +@TestProfile(CloudFormationSettingsProfile.class) class ApiGatewayV2DomainCfnIntegrationTest { private static final String CFN_AUTH = diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationDeletedStackListingRaceTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationDeletedStackListingRaceTest.java index 13a21e5a03..9f2c80f769 100644 --- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationDeletedStackListingRaceTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationDeletedStackListingRaceTest.java @@ -2,9 +2,9 @@ package io.github.hectorvent.floci.services.cloudformation; import io.github.hectorvent.floci.core.common.RequestScopes; import io.github.hectorvent.floci.services.cloudformation.model.Stack; +import io.github.hectorvent.floci.testing.CloudFormationSettingsProfile; 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 jakarta.inject.Inject; import org.junit.jupiter.api.BeforeAll; @@ -12,7 +12,6 @@ import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -26,24 +25,17 @@ import static org.junit.jupiter.api.Assertions.fail; * A stack being deleted moves from the live map to the retained-deleted one. Handing it over in * the wrong order leaves a window in which it is in neither, and a ListStacks landing there loses * a stack that both exists and is retained. + * + *

{@link CloudFormationSettingsProfile} keeps a deleted stack for a day, long enough that + * retention cannot end this test. The shipped 30 seconds are measured on the test + * {@code MutableClock}, which advances a millisecond on every read, and the pollers below read it + * thousands of times: left at the default they expire the retained record themselves and lose the + * stack for a reason that has nothing to do with the handoff. */ @QuarkusTest -@TestProfile(CloudFormationDeletedStackListingRaceTest.LongRetentionProfile.class) +@TestProfile(CloudFormationSettingsProfile.class) class CloudFormationDeletedStackListingRaceTest { - /** - * Retention long enough that it cannot end this test. The shipped 30 seconds are measured on - * the test {@code MutableClock}, which advances a millisecond on every read, and the pollers - * below read it thousands of times: left at the default they expire the retained record - * themselves and lose the stack for a reason that has nothing to do with the handoff. - */ - public static final class LongRetentionProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of("floci.services.cloudformation.deleted-stack-retention-seconds", "86400"); - } - } - private static final String REGION = "us-east-1"; private static final String ACCOUNT = "000000000000"; /** diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLambdaStubCodeAllowedIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLambdaStubCodeAllowedIntegrationTest.java index 107f823673..3e33a5ef78 100644 --- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLambdaStubCodeAllowedIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLambdaStubCodeAllowedIntegrationTest.java @@ -1,12 +1,10 @@ package io.github.hectorvent.floci.services.cloudformation; +import io.github.hectorvent.floci.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.Test; -import java.util.Map; - import static io.github.hectorvent.floci.services.cloudformation.CloudFormationLambdaMissingS3CodeIntegrationTest.CFN_AUTH; import static io.github.hectorvent.floci.services.cloudformation.CloudFormationLambdaMissingS3CodeIntegrationTest.createStack; import static io.github.hectorvent.floci.services.cloudformation.CloudFormationLambdaMissingS3CodeIntegrationTest.template; @@ -22,18 +20,14 @@ import static org.hamcrest.Matchers.containsString; *

A separate top-level class rather than a nested one, because {@code @TestProfile} applies per * test class and Surefire discovers test classes by file name: a nested class carrying the profile * compiles and passes when targeted directly, but is silently skipped in a full {@code mvn test}. + * + *

The setting comes from {@link CloudFormationSettingsProfile}, which this class shares with the + * other CloudFormation classes that change a default. */ @QuarkusTest -@TestProfile(CloudFormationLambdaStubCodeAllowedIntegrationTest.AllowStubProfile.class) +@TestProfile(CloudFormationSettingsProfile.class) class CloudFormationLambdaStubCodeAllowedIntegrationTest { - public static final class AllowStubProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of("floci.services.cloudformation.allow-stub-lambda-code", "true"); - } - } - @Test void unreadableS3CodeFallsBackToTheStubHandler() { String suffix = Long.toString(System.nanoTime(), 36); diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationUnsupportedResourceTypeStrictIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationUnsupportedResourceTypeStrictIntegrationTest.java index 68fe3da637..c931440c90 100644 --- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationUnsupportedResourceTypeStrictIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationUnsupportedResourceTypeStrictIntegrationTest.java @@ -1,12 +1,10 @@ package io.github.hectorvent.floci.services.cloudformation; +import io.github.hectorvent.floci.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.Test; -import java.util.Map; - import static io.github.hectorvent.floci.services.cloudformation.CloudFormationLambdaMissingS3CodeIntegrationTest.CFN_AUTH; import static io.github.hectorvent.floci.services.cloudformation.CloudFormationLambdaMissingS3CodeIntegrationTest.createStack; import static io.restassured.RestAssured.given; @@ -21,18 +19,14 @@ import static org.hamcrest.Matchers.containsString; *

A separate top-level class rather than a nested one, because {@code @TestProfile} applies per * test class and Surefire discovers test classes by file name: a nested class carrying the profile * compiles and passes when targeted directly, but is silently skipped in a full {@code mvn test}. + * + *

The setting comes from {@link CloudFormationSettingsProfile}, which this class shares with the + * other CloudFormation classes that change a default. */ @QuarkusTest -@TestProfile(CloudFormationUnsupportedResourceTypeStrictIntegrationTest.StrictProfile.class) +@TestProfile(CloudFormationSettingsProfile.class) class CloudFormationUnsupportedResourceTypeStrictIntegrationTest { - public static final class StrictProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of("floci.services.cloudformation.allow-stub-unsupported-resource-types", "false"); - } - } - @Test void strictProfileRollsTheStackBack() { String stackName = "cfn-unsupported-strict-" + Long.toString(System.nanoTime(), 36); diff --git a/src/test/java/io/github/hectorvent/floci/services/iot/IotDescribeEndpointOverrideIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/iot/IotDescribeEndpointOverrideIntegrationTest.java index 8a6ccf1333..9ca4e86b19 100644 --- a/src/test/java/io/github/hectorvent/floci/services/iot/IotDescribeEndpointOverrideIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/iot/IotDescribeEndpointOverrideIntegrationTest.java @@ -1,14 +1,13 @@ package io.github.hectorvent.floci.services.iot; +import io.github.hectorvent.floci.testing.IotSettingsProfile; 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 org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import java.util.Map; - +import static io.github.hectorvent.floci.testing.IotSettingsProfile.ENDPOINT_ADDRESS; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.equalTo; @@ -17,13 +16,14 @@ import static org.hamcrest.Matchers.equalTo; * for every endpoint type, the way AWS returns a bare hostname that devices complete with their * own port. {@link IotIntegrationTest} and {@link IotEndpointHostnameIntegrationTest} keep * guarding the unset case, the host and port of the base URL. + * + *

The address comes from {@link IotSettingsProfile}, which this class shares with the other IoT + * class that changes a default. */ @QuarkusTest -@TestProfile(IotDescribeEndpointOverrideIntegrationTest.Profile.class) +@TestProfile(IotSettingsProfile.class) class IotDescribeEndpointOverrideIntegrationTest { - static final String ENDPOINT_ADDRESS = "iot.example.localhost.floci.io"; - @Test void omittedEndpointTypeReturnsTheConfiguredAddress() { given() @@ -68,11 +68,4 @@ class IotDescribeEndpointOverrideIntegrationTest { .body("domainType", equalTo("AWS_MANAGED")) .body("domainName", equalTo(ENDPOINT_ADDRESS)); } - - public static final class Profile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of("floci.services.iot.endpoint-address", ENDPOINT_ADDRESS); - } - } } diff --git a/src/test/java/io/github/hectorvent/floci/services/iot/IotTopicRuleSqlStrictIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/iot/IotTopicRuleSqlStrictIntegrationTest.java index a1bd8f2607..08a5dbd218 100644 --- a/src/test/java/io/github/hectorvent/floci/services/iot/IotTopicRuleSqlStrictIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/iot/IotTopicRuleSqlStrictIntegrationTest.java @@ -1,18 +1,24 @@ package io.github.hectorvent.floci.services.iot; +import io.github.hectorvent.floci.testing.IotSettingsProfile; 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.containsString; import static org.hamcrest.Matchers.equalTo; +/** + * With {@code floci.services.iot.rule-sql-strict} on, a topic rule whose SQL is outside the subset + * Floci evaluates is rejected with {@code SqlParseException}, while one inside it is still accepted. + * Off, the default, such a rule is stored and fires on every matching topic with the whole payload. + * + *

The setting comes from {@link IotSettingsProfile}, which this class shares with the other IoT + * class that changes a default. + */ @QuarkusTest -@TestProfile(IotTopicRuleSqlStrictIntegrationTest.StrictRuleSqlProfile.class) +@TestProfile(IotSettingsProfile.class) class IotTopicRuleSqlStrictIntegrationTest { @Test @@ -56,11 +62,4 @@ class IotTopicRuleSqlStrictIntegrationTest { } """.formatted(sql); } - - public static final class StrictRuleSqlProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of("floci.services.iot.rule-sql-strict", "true"); - } - } } diff --git a/src/test/java/io/github/hectorvent/floci/testing/CloudFormationSettingsProfile.java b/src/test/java/io/github/hectorvent/floci/testing/CloudFormationSettingsProfile.java new file mode 100644 index 0000000000..afc473e316 --- /dev/null +++ b/src/test/java/io/github/hectorvent/floci/testing/CloudFormationSettingsProfile.java @@ -0,0 +1,42 @@ +package io.github.hectorvent.floci.testing; + +import io.quarkus.test.junit.QuarkusTestProfile; + +import java.util.Map; + +/** + * The CloudFormation settings that differ from the test defaults, for the classes that test them. + * Quarkus builds the application once per distinct profile class, 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. Every type their templates declare has a + * provisioner, so the strict gate never fires for them. Only the stub test declares a Lambda + * function. Retention only changes what ListStacks and DescribeStacks by stack id return after a + * delete, and the other classes look a stack up only by name, which stops answering as soon as the + * stack is deleted. + */ +public class CloudFormationSettingsProfile implements QuarkusTestProfile { + + @Override + public Map getConfigOverrides() { + return Map.of( + "floci.services.cloudformation.allow-stub-unsupported-resource-types", "false", + "floci.services.cloudformation.allow-stub-lambda-code", "true", + "floci.services.cloudformation.deleted-stack-retention-seconds", "86400"); + } +} diff --git a/src/test/java/io/github/hectorvent/floci/testing/IotSettingsProfile.java b/src/test/java/io/github/hectorvent/floci/testing/IotSettingsProfile.java new file mode 100644 index 0000000000..77d36928d2 --- /dev/null +++ b/src/test/java/io/github/hectorvent/floci/testing/IotSettingsProfile.java @@ -0,0 +1,35 @@ +package io.github.hectorvent.floci.testing; + +import io.quarkus.test.junit.QuarkusTestProfile; + +import java.util.Map; + +/** + * The IoT Core settings that differ from the test defaults, for the classes that test them. + * Quarkus builds the application once per distinct profile class, 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 class. The address only changes what DescribeEndpoint + * and the AWS-managed domain configurations report, which the rule test never reads, and strict + * SQL only changes how a topic rule is created, which the endpoint test never does. + */ +public class IotSettingsProfile implements QuarkusTestProfile { + + public static final String ENDPOINT_ADDRESS = "iot.example.localhost.floci.io"; + + @Override + public Map getConfigOverrides() { + return Map.of( + "floci.services.iot.endpoint-address", ENDPOINT_ADDRESS, + "floci.services.iot.rule-sql-strict", "true"); + } +}