Skip to content

Add 3C3D IoTConsensusV2 integration tests#17257

Open
Pengzna wants to merge 4 commits intoapache:masterfrom
Pengzna:iotv2-it
Open

Add 3C3D IoTConsensusV2 integration tests#17257
Pengzna wants to merge 4 commits intoapache:masterfrom
Pengzna:iotv2-it

Conversation

@Pengzna
Copy link
Collaborator

@Pengzna Pengzna commented Mar 4, 2026

Add IT for IoTConsensusV2 on a 3 ConfigNode + 3 DataNode cluster.

Tests:

  1. test3C3DWriteFlushAndQuery: Start 3C3D cluster, write data, flush, and verify data via query.
  2. testReplicaConsistencyAfterLeaderStop: With replication factor 2, stop the leader DataNode and verify the former follower (new leader) serves the same data after failover.

Implementation details:

  1. Config: IoTConsensusV2 batch/stream mode, DataReplicationFactor=2, SchemaReplicationFactor=3.
  2. Uses getConnection(followerNode) to query the specific follower instead of a random available node.
  3. Extends IoTDBRegionOperationReliabilityITFramework for getDataRegionMapWithLeader and cluster setup/teardown.
  4. Uses getString() in verifyDataConsistency for IoTDB JDBC compatibility.

Comment on lines +133 to +134
LOGGER.info("Sleeping 2 seconds to wait replicate ...");
Thread.sleep(1000 * 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very unstable in the test environment; it is better to check the data directory of each node to ensure that two nodes have the associated TsFiles.

Comment on lines +172 to +173
leaderNode.stopForcibly();
Assert.assertFalse("Leader should be stopped", leaderNode.isAlive());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Killing the node may result in losing some unflushed data.
Although you may have called FLUSH previously, the data may not have been synchronized then, so the FLUSH command may not work on the follower.
You should first wait until the unsealed TsFile appears on the follower, and then FLUSH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants