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/09/01 22:06:58 UTC

[GitHub] [helix] kaisun2000 commented on a change in pull request #1295: fix TestRawZkClient unstableness

kaisun2000 commented on a change in pull request #1295:
URL: https://github.com/apache/helix/pull/1295#discussion_r481458782



##########
File path: zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/TestRawZkClient.java
##########
@@ -285,18 +285,24 @@ public void testZkClientMonitor()
     Assert.assertTrue(beanServer.isRegistered(idealStatename));
 
     Assert.assertEquals((long) beanServer.getAttribute(name, "DataChangeEventCounter"), 0);
-    Assert.assertEquals((long) beanServer.getAttribute(name, "StateChangeEventCounter"), 0);
+    Assert.assertEquals((long) beanServer.getAttribute(name, "StateChangeEventCounter"), 1);
     Assert.assertEquals((long) beanServer.getAttribute(name, "ExpiredSessionCounter"), 0);
     Assert.assertEquals((long) beanServer.getAttribute(name, "OutstandingRequestGauge"), 0);
     // account for doAsyncSync()
     Assert.assertEquals((long) beanServer.getAttribute(name, "TotalCallbackCounter"), 1);
 
-    // Test exists
-    Assert.assertEquals((long) beanServer.getAttribute(rootname, "ReadCounter"), 0);
-    Assert.assertEquals((long) beanServer.getAttribute(rootname, "ReadTotalLatencyCounter"), 0);
-    Assert.assertEquals((long) beanServer.getAttribute(rootname, "ReadLatencyGauge.Max"), 0);
-    zkClient.exists(TEST_ROOT);
+    // Note, we need to wait here for the reason that doAsyncSync() blocks only the zkClient event thread. The main
+    // thread of zkClient would issue exits(TEST_ROOT) without blocking. The return of doAsyncSync() would be asyc
+    // to main thread. doAsyncSync() is a source of 1 read and main thread exists(TEST_ROOT) would be another.
+    TestHelper.verify(()->{
+      return ((org.apache.helix.zookeeper.zkclient.ZkClient)zkClient).getSyncStatus();
+    }, TestHelper.WAIT_DURATION);
+
     Assert.assertEquals((long) beanServer.getAttribute(rootname, "ReadCounter"), 1);
+
+    zkClient.exists(TEST_ROOT);

Review comment:
       This is not to assert exists() return true. This is to make sure the next `Assert.assertEquals((long) beanServer.getAttribute(rootname, "ReadCounter"), 2);` would be true. Namely this trigger a read and get recorded by bean.
   
   This is not functionality added by me. It is basically line 298 in previous version.
   
   




----------------------------------------------------------------
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