From 96b742189d25d832e47f95fdd056550629fc6db9 Mon Sep 17 00:00:00 2001 From: Sergey Matvienko Date: Thu, 5 Mar 2026 14:11:33 +0100 Subject: [PATCH] Fix flaky Sparkplug connection test: handle 404 during device await doGet(url, Class) asserts HTTP 200 internally, so when the Sparkplug device hasn't been created yet the method throws AssertionError instead of returning null. Awaitility propagates Error immediately rather than continuing to poll, causing the test to fail after ~3 s instead of retrying for up to 200 s. Add .ignoreExceptions() to both await() calls in connectClientWithCorrectAccessTokenWithNDEATHCreatedDevices and connectClientWithCorrectAccessTokenWithNDEATHWithAliasCreatedDevices so that a transient 404 is treated as "condition not yet met" and polling continues as intended. Co-Authored-By: Claude Sonnet 4.6 --- .../mqtt/sparkplug/AbstractMqttV5ClientSparkplugTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/application/src/test/java/org/thingsboard/server/transport/mqtt/sparkplug/AbstractMqttV5ClientSparkplugTest.java b/application/src/test/java/org/thingsboard/server/transport/mqtt/sparkplug/AbstractMqttV5ClientSparkplugTest.java index 4e4d0debf9..a9bdbb55db 100644 --- a/application/src/test/java/org/thingsboard/server/transport/mqtt/sparkplug/AbstractMqttV5ClientSparkplugTest.java +++ b/application/src/test/java/org/thingsboard/server/transport/mqtt/sparkplug/AbstractMqttV5ClientSparkplugTest.java @@ -191,6 +191,7 @@ public abstract class AbstractMqttV5ClientSparkplugTest extends AbstractMqttInte AtomicReference device = new AtomicReference<>(); await(alias + "find device [" + deviceName + "] after created") .atMost(200, TimeUnit.SECONDS) + .ignoreExceptions() .until(() -> { device.set(doGet("/api/tenant/devices?deviceName=" + deviceName, Device.class)); return device.get() != null; @@ -236,6 +237,7 @@ public abstract class AbstractMqttV5ClientSparkplugTest extends AbstractMqttInte AtomicReference device = new AtomicReference<>(); await(alias + "find device [" + deviceName + "] after created") .atMost(200, TimeUnit.SECONDS) + .ignoreExceptions() .until(() -> { device.set(doGet("/api/tenant/devices?deviceName=" + deviceName, Device.class)); return device.get() != null;