This is an automated email from the ASF dual-hosted git repository.

caogaofei pushed a commit to branch confignode_restart_fix
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/confignode_restart_fix by this 
push:
     new 00fe5b2c63 Add IoTDBClusterRestartIT (#7622)
00fe5b2c63 is described below

commit 00fe5b2c6359af3320a4796e46c1084017ab577a
Author: YongzaoDan <[email protected]>
AuthorDate: Sat Oct 15 19:53:00 2022 +0800

    Add IoTDBClusterRestartIT (#7622)
---
 .github/workflows/cluster-it.yml                   |  2 +
 .github/workflows/main-unix.yml                    |  2 +
 .github/workflows/main-win.yml                     |  2 +
 .../java/org/apache/iotdb/it/env/AbstractEnv.java  | 12 ++-
 .../org/apache/iotdb/it/env/RemoteServerEnv.java   | 12 ++-
 .../java/org/apache/iotdb/itbase/env/BaseEnv.java  |  6 +-
 .../iotdb/confignode/IoTDBClusterPartitionIT.java  |  2 +-
 .../iotdb/confignode/IoTDBClusterRestartIT.java    | 88 ++++++++++++++++++++++
 .../org/apache/iotdb/db/it/env/StandaloneEnv.java  | 12 ++-
 9 files changed, 133 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/cluster-it.yml b/.github/workflows/cluster-it.yml
index 323bb31829..4f0ad6abdd 100644
--- a/.github/workflows/cluster-it.yml
+++ b/.github/workflows/cluster-it.yml
@@ -9,6 +9,8 @@ on:
   pull_request:
     branches:
       - master
+      # TODO: Don't forget to delete this line after bug fixed~
+      - confignode_restart_fix
     paths-ignore:
       - 'docs/**'
   # allow manually run the action:
diff --git a/.github/workflows/main-unix.yml b/.github/workflows/main-unix.yml
index b18190297e..f5dffab81b 100644
--- a/.github/workflows/main-unix.yml
+++ b/.github/workflows/main-unix.yml
@@ -14,6 +14,8 @@ on:
   pull_request:
     branches:
       - master
+      # TODO: Don't forget to delete this line after bug fixed~
+      - confignode_restart_fix
       - 'rel/*'
       - "new_*"
     paths-ignore:
diff --git a/.github/workflows/main-win.yml b/.github/workflows/main-win.yml
index b591c0b266..720262f4f7 100644
--- a/.github/workflows/main-win.yml
+++ b/.github/workflows/main-win.yml
@@ -14,6 +14,8 @@ on:
   pull_request:
     branches:
       - master
+      # TODO: Don't forget to delete this line after bug fixed~
+      - confignode_restart_fix
       - 'rel/*'
       - "new_*"
     paths-ignore:
diff --git 
a/integration-test/src/main/java/org/apache/iotdb/it/env/AbstractEnv.java 
b/integration-test/src/main/java/org/apache/iotdb/it/env/AbstractEnv.java
index b1dc1bdb30..0f7fc332e6 100644
--- a/integration-test/src/main/java/org/apache/iotdb/it/env/AbstractEnv.java
+++ b/integration-test/src/main/java/org/apache/iotdb/it/env/AbstractEnv.java
@@ -391,7 +391,17 @@ public abstract class AbstractEnv implements BaseEnv {
   }
 
   @Override
-  public void restartDataNode(int index) {
+  public void startConfigNode(int index) {
+    configNodeWrapperList.get(index).start();
+  }
+
+  @Override
+  public void shutdownConfigNode(int index) {
+    configNodeWrapperList.get(index).stop();
+  }
+
+  @Override
+  public void startDataNode(int index) {
     dataNodeWrapperList.get(index).start();
   }
 
diff --git 
a/integration-test/src/main/java/org/apache/iotdb/it/env/RemoteServerEnv.java 
b/integration-test/src/main/java/org/apache/iotdb/it/env/RemoteServerEnv.java
index 7d81391010..d12429237e 100644
--- 
a/integration-test/src/main/java/org/apache/iotdb/it/env/RemoteServerEnv.java
+++ 
b/integration-test/src/main/java/org/apache/iotdb/it/env/RemoteServerEnv.java
@@ -159,7 +159,17 @@ public class RemoteServerEnv implements BaseEnv {
   }
 
   @Override
-  public void restartDataNode(int index) {
+  public void startConfigNode(int index) {
+    getConfigNodeWrapperList().get(index).start();
+  }
+
+  @Override
+  public void shutdownConfigNode(int index) {
+    getConfigNodeWrapperList().get(index).stop();
+  }
+
+  @Override
+  public void startDataNode(int index) {
     getDataNodeWrapperList().get(index).start();
   }
 
diff --git 
a/integration-test/src/main/java/org/apache/iotdb/itbase/env/BaseEnv.java 
b/integration-test/src/main/java/org/apache/iotdb/itbase/env/BaseEnv.java
index 0f022ca5dd..ce31d4aedf 100644
--- a/integration-test/src/main/java/org/apache/iotdb/itbase/env/BaseEnv.java
+++ b/integration-test/src/main/java/org/apache/iotdb/itbase/env/BaseEnv.java
@@ -132,7 +132,11 @@ public interface BaseEnv {
     return session;
   }
 
-  void restartDataNode(int index);
+  void startConfigNode(int index);
+
+  void shutdownConfigNode(int index);
+
+  void startDataNode(int index);
 
   void shutdownDataNode(int index);
 }
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/confignode/IoTDBClusterPartitionIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/confignode/IoTDBClusterPartitionIT.java
index cb73ebeeb0..38828c61cf 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/confignode/IoTDBClusterPartitionIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/confignode/IoTDBClusterPartitionIT.java
@@ -542,7 +542,7 @@ public class IoTDBClusterPartitionIT {
       // since there exists one DataNode is shutdown
       Assert.assertEquals(unknownCnt * 2, runningCnt);
 
-      EnvFactory.getEnv().restartDataNode(testDataNodeId);
+      EnvFactory.getEnv().startDataNode(testDataNodeId);
       // Wait for heartbeat check
       while (true) {
         boolean containUnknown = false;
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/confignode/IoTDBClusterRestartIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/confignode/IoTDBClusterRestartIT.java
new file mode 100644
index 0000000000..c9f3057f5d
--- /dev/null
+++ 
b/integration-test/src/test/java/org/apache/iotdb/confignode/IoTDBClusterRestartIT.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.confignode;
+
+import org.apache.iotdb.it.env.AbstractEnv;
+import org.apache.iotdb.it.env.ConfigFactory;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.util.concurrent.TimeUnit;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({ClusterIT.class})
+public class IoTDBClusterRestartIT {
+
+  protected static String originalConfigNodeConsensusProtocolClass;
+  private static final String ratisConsensusProtocolClass =
+      "org.apache.iotdb.consensus.ratis.RatisConsensus";
+
+  private static final int testConfigNodeNum = 3;
+  private static final int testDataNodeNum = 3;
+
+  @Before
+  public void setUp() throws Exception {
+    originalConfigNodeConsensusProtocolClass =
+        ConfigFactory.getConfig().getConfigNodeConsesusProtocolClass();
+    
ConfigFactory.getConfig().setConfigNodeConsesusProtocolClass(ratisConsensusProtocolClass);
+
+    // Init 3C3D cluster environment
+    EnvFactory.getEnv().initClusterEnvironment(testConfigNodeNum, 
testDataNodeNum);
+  }
+
+  @After
+  public void tearDown() {
+    EnvFactory.getEnv().cleanAfterClass();
+    ConfigFactory.getConfig()
+        
.setConfigNodeConsesusProtocolClass(originalConfigNodeConsensusProtocolClass);
+  }
+
+  @Test
+  public void clusterRestartTest() throws InterruptedException {
+    // Shutdown all cluster nodes
+    for (int i = 0; i < testConfigNodeNum; i++) {
+      EnvFactory.getEnv().shutdownConfigNode(i);
+    }
+    for (int i = 0; i < testDataNodeNum; i++) {
+      EnvFactory.getEnv().shutdownDataNode(i);
+    }
+
+    // Sleep 1s before restart
+    TimeUnit.SECONDS.sleep(1);
+
+    // Restart all cluster nodes
+    for (int i = 0; i < testConfigNodeNum; i++) {
+      EnvFactory.getEnv().startConfigNode(i);
+    }
+    for (int i = 0; i < testDataNodeNum; i++) {
+      EnvFactory.getEnv().startDataNode(i);
+    }
+
+    ((AbstractEnv) EnvFactory.getEnv()).testWorking();
+  }
+
+  // TODO: Add persistence tests in the future
+}
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/env/StandaloneEnv.java 
b/integration-test/src/test/java/org/apache/iotdb/db/it/env/StandaloneEnv.java
index daadfe77b0..990658dddf 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/env/StandaloneEnv.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/env/StandaloneEnv.java
@@ -178,7 +178,17 @@ public class StandaloneEnv implements BaseEnv {
   }
 
   @Override
-  public void restartDataNode(int index) {
+  public void startConfigNode(int index) {
+    // Do nothing
+  }
+
+  @Override
+  public void shutdownConfigNode(int index) {
+    // Do nothing
+  }
+
+  @Override
+  public void startDataNode(int index) {
     // Do nothing
   }
 

Reply via email to