helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [8/8] helix git commit: Fix TestRoutingTableProviderFromTargetEV by using poll&wait check.
Date Thu, 01 Nov 2018 23:02:22 GMT
Fix TestRoutingTableProviderFromTargetEV by using poll&wait check.

Add a 3 seconds poll&wait for stabling the test.


Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/44d7d2eb
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/44d7d2eb
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/44d7d2eb

Branch: refs/heads/master
Commit: 44d7d2eb8b3da78630ca0d327d88448f8a82672c
Parents: 1507f01
Author: Jiajun Wang <jjwang@linkedin.com>
Authored: Fri Oct 12 11:05:24 2018 -0700
Committer: Junkai Xue <jxue@linkedin.com>
Committed: Thu Nov 1 14:39:05 2018 -0700

----------------------------------------------------------------------
 .../TestRoutingTableProviderFromTargetEV.java   | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/44d7d2eb/helix-core/src/test/java/org/apache/helix/integration/spectator/TestRoutingTableProviderFromTargetEV.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/spectator/TestRoutingTableProviderFromTargetEV.java
b/helix-core/src/test/java/org/apache/helix/integration/spectator/TestRoutingTableProviderFromTargetEV.java
index da6e2f8..6a24986 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/spectator/TestRoutingTableProviderFromTargetEV.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/spectator/TestRoutingTableProviderFromTargetEV.java
@@ -3,12 +3,14 @@ package org.apache.helix.integration.spectator;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+
 import org.apache.helix.ConfigAccessor;
 import org.apache.helix.HelixException;
 import org.apache.helix.HelixManager;
 import org.apache.helix.HelixManagerFactory;
 import org.apache.helix.InstanceType;
 import org.apache.helix.PropertyType;
+import org.apache.helix.TestHelper;
 import org.apache.helix.common.ZkTestBase;
 import org.apache.helix.integration.manager.ClusterControllerManager;
 import org.apache.helix.integration.manager.MockParticipantManager;
@@ -111,7 +113,7 @@ public class TestRoutingTableProviderFromTargetEV extends ZkTestBase {
   }
 
   @Test (dependsOnMethods = "testTargetExternalViewWithoutEnable")
-  public void testExternalViewDiffFromTargetExternalView() throws InterruptedException {
+  public void testExternalViewDiffFromTargetExternalView() throws Exception {
     ClusterConfig clusterConfig = _configAccessor.getClusterConfig(CLUSTER_NAME);
     clusterConfig.enableTargetExternalView(true);
     clusterConfig.setPersistBestPossibleAssignment(true);
@@ -120,7 +122,7 @@ public class TestRoutingTableProviderFromTargetEV extends ZkTestBase {
 
     RoutingTableProvider externalViewProvider =
         new RoutingTableProvider(_manager, PropertyType.EXTERNALVIEW);
-    RoutingTableProvider targetExternalViewProvider =
+    final RoutingTableProvider targetExternalViewProvider =
         new RoutingTableProvider(_manager, PropertyType.TARGETEXTERNALVIEW);
 
     try {
@@ -129,9 +131,17 @@ public class TestRoutingTableProviderFromTargetEV extends ZkTestBase
{
       Set<InstanceConfig> externalViewMasters =
           externalViewProvider.getInstancesForResource(WorkflowGenerator.DEFAULT_TGT_DB,
"MASTER");
       Assert.assertEquals(externalViewMasters.size(), 0);
-      Set<InstanceConfig> targetExternalViewMasters = targetExternalViewProvider
-          .getInstancesForResource(WorkflowGenerator.DEFAULT_TGT_DB, "MASTER");
-      Assert.assertEquals(targetExternalViewMasters.size(), NUM_NODES);
+
+      final Set<InstanceConfig> targetExternalViewMasters = new HashSet<>();
+      Assert.assertTrue(TestHelper.verify(new TestHelper.Verifier() {
+        @Override
+        public boolean verify() {
+          targetExternalViewMasters.clear();
+          targetExternalViewMasters.addAll(targetExternalViewProvider
+              .getInstancesForResource(WorkflowGenerator.DEFAULT_TGT_DB, "MASTER"));
+          return targetExternalViewMasters.size() == NUM_NODES;
+        }
+      }, 3000));
 
       // TargetExternalView MASTERS mapping should exactly match IdealState MASTERS mapping
       Map<String, Map<String, String>> stateMap = _gSetupTool.getClusterManagementTool()


Mime
View raw message