You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by hu...@apache.org on 2019/05/22 23:41:38 UTC

[helix] 13/14: Fix node swap test.

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

hulee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git

commit 7f4044ffedc8a57ee4c635daf747352f1fcddc37
Author: Jiajun Wang <jj...@linkedin.com>
AuthorDate: Tue Nov 13 16:59:18 2018 -0800

    Fix node swap test.
    
    Add sleep to stablize the test. Several cluster operations require controller reaction before checking.
    
    RB=1484466
    G=helix-reviewers
    A=hrzhang
    
    Signed-off-by: Hunter Lee <hu...@linkedin.com>
---
 .../rebalancer/CrushRebalancers/TestNodeSwap.java   | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/helix-core/src/test/java/org/apache/helix/integration/rebalancer/CrushRebalancers/TestNodeSwap.java b/helix-core/src/test/java/org/apache/helix/integration/rebalancer/CrushRebalancers/TestNodeSwap.java
index 7275481..3d20f0a 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/rebalancer/CrushRebalancers/TestNodeSwap.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/rebalancer/CrushRebalancers/TestNodeSwap.java
@@ -28,6 +28,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.helix.ConfigAccessor;
+import org.apache.helix.TestHelper;
 import org.apache.helix.common.ZkTestBase;
 import org.apache.helix.controller.rebalancer.strategy.CrushEdRebalanceStrategy;
 import org.apache.helix.controller.rebalancer.strategy.CrushRebalanceStrategy;
@@ -39,7 +40,6 @@ import org.apache.helix.model.ClusterConfig;
 import org.apache.helix.model.ExternalView;
 import org.apache.helix.model.IdealState;
 import org.apache.helix.model.InstanceConfig;
-import org.apache.helix.model.Partition;
 import org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier;
 import org.apache.helix.tools.ClusterVerifiers.StrictMatchExternalViewVerifier;
 import org.testng.Assert;
@@ -143,7 +143,7 @@ public class TestNodeSwap extends ZkTestBase {
       _gSetupTool.rebalanceStorageCluster(CLUSTER_NAME, db, _replica);
       _allDBs.add(db);
     }
-    Thread.sleep(300);
+    Thread.sleep(1000);
 
     HelixClusterVerifier _clusterVerifier =
         new StrictMatchExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR)
@@ -151,7 +151,6 @@ public class TestNodeSwap extends ZkTestBase {
     Assert.assertTrue(_clusterVerifier.verify(5000));
 
     Map<String, ExternalView> record = new HashMap<>();
-
     for (String db : _allDBs) {
       record.put(db,
           _gSetupTool.getClusterManagementTool().getResourceExternalView(CLUSTER_NAME, db));
@@ -163,14 +162,17 @@ public class TestNodeSwap extends ZkTestBase {
     // 1. disable and remove an old node
     MockParticipantManager oldParticipant = _participants.get(0);
     String oldParticipantName = oldParticipant.getInstanceName();
-    oldParticipant.syncStop();
-    InstanceConfig instanceConfig =
+
+    final InstanceConfig instanceConfig =
         _gSetupTool.getClusterManagementTool().getInstanceConfig(CLUSTER_NAME, oldParticipantName);
     // disable the node first
     instanceConfig.setInstanceEnabled(false);
     _gSetupTool.getClusterManagementTool().setInstanceConfig(CLUSTER_NAME, oldParticipantName, instanceConfig);
     Assert.assertTrue(_clusterVerifier.verify(10000));
+
     // then remove it from topology
+    oldParticipant.syncStop();
+    Thread.sleep(2000);
     _gSetupTool.getClusterManagementTool().dropInstance(CLUSTER_NAME, instanceConfig);
 
     // 2. create new participant with same topology
@@ -186,8 +188,11 @@ public class TestNodeSwap extends ZkTestBase {
         new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, newParticipantName);
     participant.syncStart();
     _participants.add(0, participant);
-    Thread.sleep(300);
+    Thread.sleep(2000);
 
+    _clusterVerifier =
+        new StrictMatchExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR)
+            .setResources(_allDBs).build();
     Assert.assertTrue(_clusterVerifier.verify(5000));
 
     for (String db : _allDBs) {
@@ -203,9 +208,7 @@ public class TestNodeSwap extends ZkTestBase {
           if (instance.equals(newParticipantName)) {
             topoName = oldParticipantName;
           }
-          if (!stateMap.get(instance).equals(oldStateMap.get(topoName))) {
-            Assert.fail("test");
-          }
+          Assert.assertEquals(stateMap.get(instance), oldStateMap.get(topoName));
         }
       }
     }