You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2020/10/07 19:23:50 UTC

[GitHub] [helix] pkuwm commented on a change in pull request #1450: HelixClusterVerifier verify() with default waitTillVerify time -- part two

pkuwm commented on a change in pull request #1450:
URL: https://github.com/apache/helix/pull/1450#discussion_r501250700



##########
File path: helix-core/src/test/java/org/apache/helix/TestHelper.java
##########
@@ -799,7 +799,12 @@ public static boolean verify(Verifier verifier, long timeout) throws Exception {
     long start = System.currentTimeMillis();
     do {
       boolean result = verifier.verify();
-      if (result || (System.currentTimeMillis() - start) > timeout) {
+      boolean isTimedout = (System.currentTimeMillis() - start) > timeout;
+      if (result || isTimedout) {
+        if (isTimedout && !result) {
+          LOG.error("verifier time out, consider try longer timeout, stack trace{}",
+              Arrays.asList(Thread.currentThread().getStackTrace()));

Review comment:
       This stack trace would be printed in one line, right? It'd be difficult to read. How about using 
   
    new Throwable().printStackTrace();

##########
File path: helix-core/src/test/java/org/apache/helix/TestListenerCallback.java
##########
@@ -195,19 +205,27 @@ public void testScopedConfigChangeListener() throws Exception {
 
     listener.reset();
     _manager.addConfigChangeListener(listener, ConfigScopeProperty.CLUSTER);
-    Assert.assertTrue(listener._configChanged, "Should get initial clusterConfig callback invoked");
+    boolean result = TestHelper.verify(()-> {
+      return listener._configChanged;
+    }, TestHelper.WAIT_DURATION);
+    Assert.assertTrue(result,"Should get initial clusterConfig callback invoked");
     Assert.assertEquals(listener._configSize, 1, "Cluster Config size should be 1");
 
     listener.reset();
     _manager.addConfigChangeListener(listener, ConfigScopeProperty.RESOURCE);
+    result = TestHelper.verify(()-> {

Review comment:
       Assert result 

##########
File path: helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestClusterInMaintenanceModeWhenReachingOfflineInstancesLimit.java
##########
@@ -165,17 +171,18 @@ public void testWithOfflineInstancesLimit() throws Exception {
       _participants.get(i).syncStop();
     }
 
-    Thread.sleep(500);
-
-    maintenanceSignal = _dataAccessor.getProperty(_dataAccessor.keyBuilder().maintenance());
-    Assert.assertNull(maintenanceSignal);
+    boolean result = TestHelper.verify(() -> {
+      MaintenanceSignal ms = _dataAccessor.getProperty(_dataAccessor.keyBuilder().maintenance());
+      return ms == null;
+    }, TestHelper.WAIT_DURATION);
+    Assert.assertTrue(result);
 
     _participants.get(i).syncStop();
 
-    Thread.sleep(500);
-    maintenanceSignal = _dataAccessor.getProperty(_dataAccessor.keyBuilder().maintenance());
-    Assert.assertNotNull(maintenanceSignal);
-    Assert.assertNotNull(maintenanceSignal.getReason());
+    result = TestHelper.verify(() -> {

Review comment:
       Assert

##########
File path: helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestClusterInMaintenanceModeWhenReachingMaxPartition.java
##########
@@ -114,10 +115,10 @@ public void testDisableCluster() throws Exception {
       _participants.get(i).syncStop();
     }
 
-    Thread.sleep(1000L);
-    maintenanceSignal = _dataAccessor.getProperty(_dataAccessor.keyBuilder().maintenance());
-    Assert.assertNotNull(maintenanceSignal);
-    Assert.assertNotNull(maintenanceSignal.getReason());
+    boolean result = TestHelper.verify(() -> {

Review comment:
       Assert it

##########
File path: helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestClusterInMaintenanceModeWhenReachingOfflineInstancesLimit.java
##########
@@ -130,18 +130,24 @@ public void testWithDisabledInstancesLimit() throws Exception {
       admin.enableInstance(CLUSTER_NAME, instance, false);
     }
 
-    Thread.sleep(500);
-
-    maintenanceSignal = _dataAccessor.getProperty(_dataAccessor.keyBuilder().maintenance());
-    Assert.assertNull(maintenanceSignal);
+    boolean result = TestHelper.verify(() -> {
+      MaintenanceSignal ms = _dataAccessor.getProperty(_dataAccessor.keyBuilder().maintenance());
+      return ms == null;
+    }, TestHelper.WAIT_DURATION);
+    Assert.assertTrue(result);
 
     String instance = _participants.get(i).getInstanceName();
     admin.enableInstance(CLUSTER_NAME, instance, false);
 
-    Thread.sleep(500);
-    maintenanceSignal = _dataAccessor.getProperty(_dataAccessor.keyBuilder().maintenance());
-    Assert.assertNotNull(maintenanceSignal);
-    Assert.assertNotNull(maintenanceSignal.getReason());
+    ZkHelixClusterVerifier clusterVerifier =
+        new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkClient(_gZkClient)
+            .build();
+    Assert.assertTrue(clusterVerifier.verifyByPolling());
+
+    result = TestHelper.verify(() -> {

Review comment:
       Assert it




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org