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

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


The following commit(s) were added to refs/heads/master by this push:
     new daacd3d  Stabilize TestInstancesAccessor (#1828)
daacd3d is described below

commit daacd3daceac6a3b02850008ea1ad0c972aa7278
Author: Ali Reza Zamani Zadeh Najari <[email protected]>
AuthorDate: Thu Aug 5 11:35:01 2021 -0700

    Stabilize TestInstancesAccessor (#1828)
    
    TestInstancesAccessor is unstable because the cluster might not be
    stable while the test runs the stoppable check and cluster config and
    instance config can be missing. In this commit, the test waits until the
    cluster config and instance config get created and then proceeds for
    the stoppable checks.
---
 .../helix/rest/server/AbstractTestClass.java       | 28 ++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git 
a/helix-rest/src/test/java/org/apache/helix/rest/server/AbstractTestClass.java 
b/helix-rest/src/test/java/org/apache/helix/rest/server/AbstractTestClass.java
index 0f29a6e..a7cf91c 100644
--- 
a/helix-rest/src/test/java/org/apache/helix/rest/server/AbstractTestClass.java
+++ 
b/helix-rest/src/test/java/org/apache/helix/rest/server/AbstractTestClass.java
@@ -315,7 +315,7 @@ public class AbstractTestClass extends 
JerseyTestNg.ContainerPerClassTest {
     }
   }
 
-  protected void setupHelixResources() {
+  protected void setupHelixResources() throws Exception {
     _clusters = createClusters(4);
     _gSetupTool.addCluster(_superCluster, true);
     _gSetupTool.addCluster(TASK_TEST_CLUSTER, true);
@@ -550,7 +550,7 @@ public class AbstractTestClass extends 
JerseyTestNg.ContainerPerClassTest {
   }
 
   private void preSetupForParallelInstancesStoppableTest(String clusterName,
-      List<String> instances) {
+      List<String> instances) throws Exception {
     _gSetupTool.addCluster(clusterName, true);
     ClusterConfig clusterConfig = 
_configAccessor.getClusterConfig(clusterName);
     clusterConfig.setFaultZoneType("helixZoneId");
@@ -578,6 +578,30 @@ public class AbstractTestClass extends 
JerseyTestNg.ContainerPerClassTest {
     createResources(clusterName, 1);
     _clusterControllerManagers.add(startController(clusterName));
 
+    // Make sure that cluster config exists
+    boolean isClusterConfigExist = TestHelper.verify(() -> {
+      ClusterConfig stoppableClusterConfig;
+      try {
+        stoppableClusterConfig = _configAccessor.getClusterConfig(clusterName);
+      } catch (Exception e) {
+        return false;
+      }
+      return (stoppableClusterConfig != null);
+    }, TestHelper.WAIT_DURATION);
+    Assert.assertTrue(isClusterConfigExist);
+    // Make sure that instance config exists for the instance0 to instance5
+    for (String instance: instances) {
+      boolean isinstanceConfigExist = TestHelper.verify(() -> {
+        InstanceConfig instanceConfig;
+        try {
+          instanceConfig = 
_configAccessor.getInstanceConfig(STOPPABLE_CLUSTER, instance);
+        } catch (Exception e) {
+          return false;
+        }
+        return (instanceConfig != null);
+      }, TestHelper.WAIT_DURATION);
+      Assert.assertTrue(isinstanceConfigExist);
+    }
     _clusters.add(STOPPABLE_CLUSTER);
     _workflowMap.put(STOPPABLE_CLUSTER, createWorkflows(STOPPABLE_CLUSTER, 3));
   }

Reply via email to