test(iot): wait for the MQTT ports to close around the failed restart (#4533)

* fix(test): wait for the MQTT listeners to close before blocking the TLS port

* test(iot): wait for the plain port to close after the failed restart
This commit is contained in:
Kenshin Okinaka authored and GitHub committed 2026-09-28 12:09:46 -04:00
1 parent e7e49f9125
commit f40402fa93
1 file changed
+3
@@ -668,11 +668,14 @@ class IotMqttBrokerServiceTest {
void aFailedRestartKeepsRulesOff() throws Exception {
broker.startIfEnabled();
broker.stop();
awaitClosed(plainPort);
awaitClosed(tlsPort);
try (ServerSocket blocker = new ServerSocket()) {
blocker.bind(new InetSocketAddress("127.0.0.1", tlsPort));
assertThrows(IllegalStateException.class, broker::startIfEnabled);
assertFalse(rulesRun(), "a failed restart leaves rules off");
awaitClosed(plainPort);
}
broker.startIfEnabled();