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

hanishakoneru pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git


The following commit(s) were added to refs/heads/master by this push:
     new ff56358  RATIS-1087. Add setConfiguration tests with single node 
clusters. (#214)
ff56358 is described below

commit ff5635819e94feff813cfed30519b3bb26a37cf8
Author: Tsz-Wo Nicholas Sze <[email protected]>
AuthorDate: Sat Oct 10 05:21:05 2020 +0800

    RATIS-1087. Add setConfiguration tests with single node clusters. (#214)
---
 .../server/impl/RaftReconfigurationBaseTest.java   | 32 ++++++++++++++++++----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git 
a/ratis-server/src/test/java/org/apache/ratis/server/impl/RaftReconfigurationBaseTest.java
 
b/ratis-server/src/test/java/org/apache/ratis/server/impl/RaftReconfigurationBaseTest.java
index 38bb192..4ff27e4 100644
--- 
a/ratis-server/src/test/java/org/apache/ratis/server/impl/RaftReconfigurationBaseTest.java
+++ 
b/ratis-server/src/test/java/org/apache/ratis/server/impl/RaftReconfigurationBaseTest.java
@@ -300,12 +300,26 @@ public abstract class RaftReconfigurationBaseTest<CLUSTER 
extends MiniRaftCluste
   }
 
   @Test
+  public void testBootstrapReconfWithSingleNodeAddOne() throws Exception {
+    // originally 1 peer, add 1 more
+    runWithNewCluster(1, cluster -> runTestBootstrapReconf(1, false, cluster));
+  }
+
+  @Test
+  public void testBootstrapReconfWithSingleNodeAddTwo() throws Exception {
+    // originally 1 peer, add 2 more
+    runWithNewCluster(1, cluster -> runTestBootstrapReconf(2, false, cluster));
+  }
+
+  @Test
   public void testBootstrapReconf() throws Exception {
-    // originally 3 peers
-    runWithNewCluster(3, this::runTestBootstrapReconf);
+    // originally 3 peers, add 2 more
+    runWithNewCluster(3, cluster -> runTestBootstrapReconf(2, true, cluster));
   }
 
-  void runTestBootstrapReconf(CLUSTER cluster) throws Exception {
+  void runTestBootstrapReconf(int numNewPeer, boolean startNewPeer, CLUSTER 
cluster) throws Exception {
+      LOG.info("Originally {} peer(s), add {} more, startNewPeer={}",
+          cluster.getServers().size(), numNewPeer, startNewPeer);
       RaftTestUtil.waitForLeader(cluster);
       final RaftPeerId leaderId = cluster.getLeader().getId();
       try (final RaftClient client = cluster.createClient(leaderId)) {
@@ -316,7 +330,7 @@ public abstract class RaftReconfigurationBaseTest<CLUSTER 
extends MiniRaftCluste
           Assert.assertTrue(reply.isSuccess());
         }
 
-        PeerChanges c1 = cluster.addNewPeers(2, true);
+        final PeerChanges c1 = cluster.addNewPeers(numNewPeer, startNewPeer);
         LOG.info("Start changing the configuration: {}",
                 asList(c1.allPeersInNewConf));
         final AtomicReference<Boolean> success = new AtomicReference<>();
@@ -331,7 +345,15 @@ public abstract class RaftReconfigurationBaseTest<CLUSTER 
extends MiniRaftCluste
         });
         clientThread.start();
 
-        Thread.sleep(5000);
+        if (!startNewPeer) {
+          final TimeDuration delay = FIVE_SECONDS;
+          LOG.info("delay {} and start new peer(s): {}", delay, c1.newPeers);
+          delay.sleep();
+          for(RaftPeer p : c1.newPeers) {
+            cluster.restartServer(p.getId(), true);
+          }
+        }
+        FIVE_SECONDS.sleep();
         LOG.info(cluster.printServers());
         assertSuccess(success);
 

Reply via email to