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 4f1483abc78 Fix customized cluster wrong config IT (#19213)
4f1483abc78 is described below

commit 4f1483abc78a41c491f931e874164b3564c56f8a
Author: Jiang Tian <[email protected]>
AuthorDate: Wed Nov 11 10:58:06 2026 +0800

    Fix customized cluster wrong config IT (#19213)
---
 .../iotdb/db/it/IoTDBCustomizedClusterIT.java      | 49 ++++++++++++++++------
 1 file changed, 37 insertions(+), 12 deletions(-)

diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBCustomizedClusterIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBCustomizedClusterIT.java
index c734b08f24d..7604679b97a 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBCustomizedClusterIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBCustomizedClusterIT.java
@@ -38,15 +38,20 @@ import org.junit.runner.RunWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.sql.*;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Date;
+import java.util.Properties;
 import java.util.concurrent.TimeUnit;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 /** Tests that may not be satisfied with the default cluster settings. */
@@ -294,23 +299,43 @@ public class IoTDBCustomizedClusterIT {
     }
   }
 
+  // Start a valid 1C1D cluster, then give only the DataNode an unsupported 
persisted consensus
+  // protocol and verify that the DataNode exits with ILLEGAL_PARAMETER.
   @Category(DailyIT.class)
   @Test
-  public void testStartWithWrongConfig() throws InterruptedException {
+  public void testStartWithWrongConfig() throws Exception {
     SimpleEnv simpleEnv = new SimpleEnv();
-    simpleEnv
-        .getConfig()
-        .getCommonConfig()
-        
.setDataRegionConsensusProtocolClass("org.apache.iotdb.consensus.iot.IoTConsensusV1");
     try {
       simpleEnv.initClusterEnvironment(1, 1);
-    } catch (AssertionError e) {
-      // ignore
+      DataNodeWrapper dataNodeWrapper = simpleEnv.getDataNodeWrapper(0);
+      Process initialProcess = dataNodeWrapper.getInstance();
+      dataNodeWrapper.stop();
+      assertTrue(
+          "DataNode did not stop before its persisted consensus protocol was 
changed",
+          initialProcess.waitFor(20, TimeUnit.SECONDS));
+
+      File systemPropertiesFile = new File(dataNodeWrapper.getSystemDir(), 
"system.properties");
+      Properties systemProperties = new Properties();
+      try (FileInputStream input = new FileInputStream(systemPropertiesFile)) {
+        systemProperties.load(input);
+      }
+      systemProperties.setProperty(
+          "data_region_consensus_protocol", 
"org.apache.iotdb.consensus.iot.IoTConsensusV1");
+      try (FileOutputStream output = new 
FileOutputStream(systemPropertiesFile)) {
+        systemProperties.store(output, null);
+      }
+
+      dataNodeWrapper.start();
+      Process dataNodeProcess = dataNodeWrapper.getInstance();
+      assertTrue(
+          "DataNode did not exit after rejecting the invalid consensus 
protocol",
+          dataNodeProcess.waitFor(20, TimeUnit.SECONDS));
+      // POSIX systems keep only the low 8 bits of an exit status.
+      assertEquals(
+          TSStatusCode.ILLEGAL_PARAMETER.getStatusCode() & 0xFF,
+          dataNodeProcess.exitValue() & 0xFF);
+    } finally {
+      simpleEnv.cleanClusterEnvironment();
     }
-    simpleEnv.getDataNodeWrapper(0).getInstance().waitFor(20, 
TimeUnit.SECONDS);
-    // POSIX systems keep only the low 8 bits of an exit status.
-    assertEquals(
-        TSStatusCode.ILLEGAL_PARAMETER.getStatusCode() & 0xFF,
-        simpleEnv.getDataNodeWrapper(0).getInstance().exitValue() & 0xFF);
   }
 }

Reply via email to