From 68fc4134c4012539355d3122a27d48d6cd65e49b Mon Sep 17 00:00:00 2001 From: Hector Ventura Date: Fri, 26 Jun 2026 01:35:39 -0500 Subject: [PATCH] fix(iot): deflake MQTT lazy-startup test, align 1.5.28 version, make compat runner executable (#1580) * test(iot): wait for broker port release in MQTT lazy-startup test Vert.x MqttServer.close() can resolve before the OS releases the listening socket, so a connect immediately after stop() may still succeed. @BeforeEach now polls until the port refuses connections before each test asserts the broker is not listening, fixing the IotMqttLazyStartupIntegrationTest flake under the full ordered suite that was failing CI on main. * chore(release): set version to 1.5.28 Align pom.xml with the 1.5.28 release commit and CHANGELOG header; it had been left at 1.6.0. * ci: make run-docker-tests.sh executable The compat test runner lacked the execute bit, so ./docker/run-docker-tests.sh failed with permission denied (exit 126). --- docker/run-docker-tests.sh | 0 pom.xml | 2 +- .../IotMqttLazyStartupIntegrationTest.java | 22 ++++++++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) mode change 100644 => 100755 docker/run-docker-tests.sh diff --git a/docker/run-docker-tests.sh b/docker/run-docker-tests.sh old mode 100644 new mode 100755 diff --git a/pom.xml b/pom.xml index 3b8fe6456e..e629132fc6 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.hectorvent floci - 1.6.0 + 1.5.28 jar Floci diff --git a/src/test/java/io/github/hectorvent/floci/services/iot/IotMqttLazyStartupIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/iot/IotMqttLazyStartupIntegrationTest.java index ad639300b4..6d5894bbf4 100644 --- a/src/test/java/io/github/hectorvent/floci/services/iot/IotMqttLazyStartupIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/iot/IotMqttLazyStartupIntegrationTest.java @@ -26,8 +26,28 @@ class IotMqttLazyStartupIntegrationTest { IotMqttBrokerService mqttBrokerService; @BeforeEach - void stopBroker() { + void stopBroker() throws InterruptedException { mqttBrokerService.stop(); + awaitPortClosed(PORT); + } + + /** + * Vert.x's {@code MqttServer.close()} future can resolve a moment before the OS + * releases the listening socket, so a fresh connect immediately after {@link + * IotMqttBrokerService#stop()} may still succeed. Poll until the port actually + * refuses connections before a test asserts the broker is not listening — this + * removes a startup-order race that only surfaced under the full ordered suite. + */ + private static void awaitPortClosed(int port) throws InterruptedException { + long deadline = System.currentTimeMillis() + 5_000; + while (System.currentTimeMillis() < deadline) { + try (Socket socket = new Socket()) { + socket.connect(new InetSocketAddress("127.0.0.1", port), 100); + } catch (Exception refused) { + return; // connection refused — the broker port is closed + } + Thread.sleep(50); // still accepting connections; back off and retry + } } @Test