This is an automated email from the ASF dual-hosted git repository.
jt2594838 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new e023d2a8916 Stabilize MQTT JSON integration tests (#19506)
e023d2a8916 is described below
commit e023d2a89167ada5b09087950ba5ca83ef83eefd
Author: Jiang Tian <[email protected]>
AuthorDate: Wed Dec 2 22:08:35 2026 +0800
Stabilize MQTT JSON integration tests (#19506)
---
.../iotdb/db/it/mqtt/IoTDBMQTTServiceJsonIT.java | 23 +++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/mqtt/IoTDBMQTTServiceJsonIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/mqtt/IoTDBMQTTServiceJsonIT.java
index 93527178cd6..e01b1d97f0a 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/mqtt/IoTDBMQTTServiceJsonIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/mqtt/IoTDBMQTTServiceJsonIT.java
@@ -28,6 +28,7 @@ import org.apache.iotdb.itbase.category.ClusterIT;
import org.apache.iotdb.itbase.category.LocalStandaloneIT;
import org.apache.iotdb.itbase.env.BaseEnv;
import org.apache.iotdb.rpc.StatementExecutionException;
+import org.apache.iotdb.service.rpc.thrift.TSConnectionType;
import org.apache.tsfile.read.common.Field;
import org.apache.tsfile.read.common.RowRecord;
@@ -73,8 +74,8 @@ public class IoTDBMQTTServiceJsonIT {
BaseEnv baseEnv = EnvFactory.getEnv();
baseEnv.getConfig().getDataNodeConfig().setEnableMQTTService(true);
baseEnv.getConfig().getDataNodeConfig().setMqttPayloadFormatter(FORMATTER);
- // Serialize CONNECT and PUBLISH callbacks so the session is registered
before each
- // payload's single publish is processed.
+ // Keep the PUBLISH callback behind the rest of the CONNECT callback once
its session is
+ // visible to fetchAllConnections().
baseEnv.getConfig().getDataNodeConfig().setMqttHandlerPoolSize(1);
baseEnv.initClusterEnvironment();
}
@@ -96,10 +97,26 @@ public class IoTDBMQTTServiceJsonIT {
mqtt.setReconnectDelay(1000);
// A delayed disconnect must not remove the next test's broker session.
Keep IDs within the
// 23-character MQTT 3.1 limit.
- mqtt.setClientId("client-" + UUID.randomUUID().toString().substring(0,
16));
+ String clientId = "client-" + UUID.randomUUID().toString().substring(0,
16);
+ mqtt.setClientId(clientId);
connection = mqtt.blockingConnection();
connection.connect();
+ // CONNACK can arrive before the CONNECT interceptor registers the IoTDB
session.
+ try (ISession session =
+
EnvFactory.getEnv().getSessionConnection(List.of(dataNodeWrapper.getIpAndPortString())))
{
+ Awaitility.await("MQTT session " + clientId + " on " +
dataNodeWrapper.getIpAndPortString())
+ .atMost(1, TimeUnit.MINUTES)
+ .pollDelay(0, TimeUnit.MILLISECONDS)
+ .pollInterval(100, TimeUnit.MILLISECONDS)
+ .until(
+ () ->
+
session.fetchAllConnections().getConnectionInfoList().stream()
+ .anyMatch(
+ info ->
+ info.getType() == TSConnectionType.MQTT_BASED
+ && clientId.equals(info.getConnectionId())));
+ }
}
@After