diff --git a/src/test/java/io/floci/aws/services/iot/IotMqttLazyStartupIntegrationTest.java b/src/test/java/io/floci/aws/services/iot/IotMqttLazyStartupIntegrationTest.java index f43750c9b2..82e6963661 100644 --- a/src/test/java/io/floci/aws/services/iot/IotMqttLazyStartupIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/iot/IotMqttLazyStartupIntegrationTest.java @@ -1,5 +1,6 @@ package io.floci.aws.services.iot; +import io.floci.aws.testing.ServicesOffSettingsProfile; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; import jakarta.inject.Inject; @@ -16,10 +17,10 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @QuarkusTest -@TestProfile(LazyMqttTestProfile.class) +@TestProfile(ServicesOffSettingsProfile.class) class IotMqttLazyStartupIntegrationTest { - private static final int PORT = LazyMqttTestProfile.PORT; + private static final int PORT = ServicesOffSettingsProfile.MQTT_PORT; @Inject IotMqttBrokerService mqttBrokerService; diff --git a/src/test/java/io/floci/aws/services/iot/IotMqttWebSocketLazyStartIntegrationTest.java b/src/test/java/io/floci/aws/services/iot/IotMqttWebSocketLazyStartIntegrationTest.java index cdd09a83a9..25d316787e 100644 --- a/src/test/java/io/floci/aws/services/iot/IotMqttWebSocketLazyStartIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/iot/IotMqttWebSocketLazyStartIntegrationTest.java @@ -1,5 +1,6 @@ package io.floci.aws.services.iot; +import io.floci.aws.testing.ServicesOffSettingsProfile; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; import jakarta.inject.Inject; @@ -32,10 +33,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * broker, concurrent first ones all get a session, and an upgrade after a stop starts it again. */ @QuarkusTest -@TestProfile(LazyMqttTestProfile.class) +@TestProfile(ServicesOffSettingsProfile.class) class IotMqttWebSocketLazyStartIntegrationTest { - private static final int PORT = LazyMqttTestProfile.PORT; + private static final int PORT = ServicesOffSettingsProfile.MQTT_PORT; @ConfigProperty(name = "quarkus.http.test-port", defaultValue = "0") int testHttpPort; diff --git a/src/test/java/io/floci/aws/services/iot/LazyMqttTestProfile.java b/src/test/java/io/floci/aws/services/iot/LazyMqttTestProfile.java deleted file mode 100644 index 2bb19cb217..0000000000 --- a/src/test/java/io/floci/aws/services/iot/LazyMqttTestProfile.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.floci.aws.services.iot; - -import io.quarkus.test.junit.QuarkusTestProfile; - -import java.util.Map; - -public final class LazyMqttTestProfile implements QuarkusTestProfile { - - static final int PORT = 18838; - - @Override - public Map getConfigOverrides() { - return Map.of( - "floci.services.iot.mqtt.enabled", "true", - "floci.services.iot.mqtt.auto-start", "false", - "floci.services.iot.mqtt.host", "127.0.0.1", - "floci.services.iot.mqtt.port", Integer.toString(PORT)); - } -} diff --git a/src/test/java/io/floci/aws/testing/ServicesOffSettingsProfile.java b/src/test/java/io/floci/aws/testing/ServicesOffSettingsProfile.java index c3d79448dd..109cbee85c 100644 --- a/src/test/java/io/floci/aws/testing/ServicesOffSettingsProfile.java +++ b/src/test/java/io/floci/aws/testing/ServicesOffSettingsProfile.java @@ -25,12 +25,18 @@ import java.util.Map; * {@code floci.services.servicequotas.standard-on-demand-vcpus=2}, refuses a launch that would run * more than two Standard On-Demand vCPUs. {@code Ec2VcpuAdmissionIntegrationTest} relies on * them. + *
  • {@code floci.services.iot.mqtt.port=}{@value #MQTT_PORT} moves the MQTT broker off the + * shipped 1883, which a developer's running Floci may hold. The test config leaves + * {@code auto-start} off, so the broker listens only once something needs it. + * {@code IotMqttLazyStartupIntegrationTest} and {@code IotMqttWebSocketLazyStartIntegrationTest} + * rely on it: they check what starts it, and stop it before and after each test.
  • * * *

    Each is inert for the other classes: none of them calls a service switched off here, files a - * delegation request as the partner account, restores an S3 object or launches an instance. Their - * requests go to IAM, CloudFormation for an IAM role, S3, EC2 and Service Quotas, and to the - * disabled services only from {@code ServiceEnablementIntegrationTest}. It stays apart from + * delegation request as the partner account, restores an S3 object, launches an instance or + * reaches the MQTT broker. Their requests go to IAM, CloudFormation for an IAM role, S3, EC2, + * Service Quotas and IoT, and to the disabled services only from + * {@code ServiceEnablementIntegrationTest}. It stays apart from * {@link ScopedServiceSettingsProfile}, whose classes call DynamoDB, ECS and FIS. * *

    A class joins if it calls none of the services switched off here, if every other setting here @@ -39,6 +45,9 @@ import java.util.Map; */ public class ServicesOffSettingsProfile implements QuarkusTestProfile { + /** The port the MQTT broker listens on once something starts it. */ + public static final int MQTT_PORT = 18838; + @Override public Map getConfigOverrides() { return Map.ofEntries( @@ -56,6 +65,7 @@ public class ServicesOffSettingsProfile implements QuarkusTestProfile { "src/test/resources/partner-permission-boundaries.json"), Map.entry("floci.services.s3.restore-completion-delay-seconds", "60"), Map.entry("floci.services.ec2.enforce-vcpu-quotas", "true"), - Map.entry("floci.services.servicequotas.standard-on-demand-vcpus", "2")); + Map.entry("floci.services.servicequotas.standard-on-demand-vcpus", "2"), + Map.entry("floci.services.iot.mqtt.port", Integer.toString(MQTT_PORT))); } }