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 2021/04/27 04:47:31 UTC

[GitHub] [helix] jiajunwang opened a new pull request #1716: Fix unstable test TestZkCallbackHandlerLeak.

jiajunwang opened a new pull request #1716:
URL: https://github.com/apache/helix/pull/1716


   ### Issues
   
   - [X] My PR addresses the following Helix issues and references them in the PR description:
   
   (#200 - Link your issue number here: You can write "Fixes #XXX". Please use the proper keyword so that the issue gets closed automatically. See https://docs.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue
   Any of the following keywords can be used: close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved)
   
   ### Description
   
   - [X] Here are some details about my PR, including screenshots of any UI changes:
   
   This PR extends the wait and check section to wait for the expected condition with more tolerance.
   
   ### Tests
   
   - [X] The following tests are written for this issue:
   
   Pure test changes. I have run the test TestZkCallbackHandlerLeak 89 times locally. All passed.
   
   - The following is the result of the "mvn test" command on the appropriate module:
   
   (If CI test fails due to known issue, please specify the issue and test PR locally. Then copy & paste the result of "mvn test" to here.)
   
   ### Documentation (Optional)
   
   - In case of new functionality, my PR adds documentation in the following wiki page:
   
   (Link the GitHub wiki you added)
   
   ### Commits
   
   - My commits all reference appropriate Apache Helix GitHub issues in their subject lines. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Code Quality
   
   - My diff has been formatted using helix-style.xml 
   (helix-style-intellij.xml if IntelliJ IDE is used)
   


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


[GitHub] [helix] jiajunwang commented on a change in pull request #1716: Fix unstable test TestZkCallbackHandlerLeak.

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #1716:
URL: https://github.com/apache/helix/pull/1716#discussion_r621710279



##########
File path: helix-core/src/test/java/org/apache/helix/integration/TestZkCallbackHandlerLeak.java
##########
@@ -162,33 +154,25 @@ public boolean verify() throws Exception {
     Assert.assertTrue(result);
 
     // check controller zk-watchers
-    result = TestHelper.verify(new TestHelper.Verifier() {
-
-      @Override
-      public boolean verify() throws Exception {
-        Map<String, Set<String>> watchers = ZkTestHelper.getListenersBySession(ZK_ADDR);
-        Set<String> watchPaths = watchers.get("0x" + controller.getSessionId());
-        // System.out.println("controller watch paths after session expiry: " + watchPaths);
-
-        // where n is number of nodes and r is number of resources
-        // one participant is disconnected, and its task current states are removed
-        return watchPaths.size() == (8 + r + (6 + r + taskResourceCount) * (n - 1) + 6 + r);
-      }
+    result = TestHelper.verify(() -> {
+      Map<String, Set<String>> watchers = ZkTestHelper.getListenersBySession(ZK_ADDR);
+      Set<String> watchPaths = watchers.get("0x" + controller.getSessionId());
+      // System.out.println("controller watch paths after session expiry: " + watchPaths);

Review comment:
       Removed

##########
File path: helix-core/src/test/java/org/apache/helix/integration/TestZkCallbackHandlerLeak.java
##########
@@ -494,12 +466,12 @@ public void testCurrentStatePathLeakingByAsycRemoval() throws Exception {
     }
 
     // verify new watcher is installed on the new node
-    boolean result = TestHelper.verify(() -> {
-      return ZkTestHelper.getListenersByZkPath(ZK_ADDR).keySet().contains(jobKey.getPath());
-    }, TestHelper.WAIT_DURATION);
-    Assert.assertTrue(result, "Should get initial clusterConfig callback invoked");
-    rpWatchPaths = ZkTestHelper.getZkWatch(rpManager.getZkClient());
-    Assert.assertTrue(rpWatchPaths.get("dataWatches").contains(jobKey.getPath()));
+    boolean result = TestHelper.verify(
+        () -> ZkTestHelper.getListenersByZkPath(ZK_ADDR).keySet().contains(jobKey.getPath())
+            && ZkTestHelper.getZkWatch(rpManager.getZkClient()).get("dataWatches")
+            .contains(jobKey.getPath()), TestHelper.WAIT_DURATION);
+    Assert.assertTrue(result,
+        "Should get initial clusterConfig callback invoked and add data watchers");
 
     LOG.info("remove job");

Review comment:
       Yeah, I think it is not necessary. But I will leave it for now since it is not related to this PR change.

##########
File path: helix-core/src/test/java/org/apache/helix/integration/TestZkCallbackHandlerLeak.java
##########
@@ -106,33 +106,25 @@ public void testCbHandlerLeakOnParticipantSessionExpiry() throws Exception {
     final MockParticipantManager participantManagerToExpire = participants[1];
 
     // check controller zk-watchers
-    boolean result = TestHelper.verify(new TestHelper.Verifier() {
-
-      @Override
-      public boolean verify() throws Exception {
-        Map<String, Set<String>> watchers = ZkTestHelper.getListenersBySession(ZK_ADDR);
-        // Set<String> watchPaths = watchers.get("0x" + controllerManager.getSessionId());
-        Set<String> watchPaths = watchers.get("0x" + controller.getSessionId());
-        // System.out.println("controller watch paths: " + watchPaths);
+    boolean result = TestHelper.verify(() -> {
+      Map<String, Set<String>> watchers = ZkTestHelper.getListenersBySession(ZK_ADDR);
+      // Set<String> watchPaths = watchers.get("0x" + controllerManager.getSessionId());

Review comment:
       Removed




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


[GitHub] [helix] xyuanlu commented on a change in pull request #1716: Fix unstable test TestZkCallbackHandlerLeak.

Posted by GitBox <gi...@apache.org>.
xyuanlu commented on a change in pull request #1716:
URL: https://github.com/apache/helix/pull/1716#discussion_r621660496



##########
File path: helix-core/src/test/java/org/apache/helix/integration/TestZkCallbackHandlerLeak.java
##########
@@ -106,33 +106,25 @@ public void testCbHandlerLeakOnParticipantSessionExpiry() throws Exception {
     final MockParticipantManager participantManagerToExpire = participants[1];
 
     // check controller zk-watchers
-    boolean result = TestHelper.verify(new TestHelper.Verifier() {
-
-      @Override
-      public boolean verify() throws Exception {
-        Map<String, Set<String>> watchers = ZkTestHelper.getListenersBySession(ZK_ADDR);
-        // Set<String> watchPaths = watchers.get("0x" + controllerManager.getSessionId());
-        Set<String> watchPaths = watchers.get("0x" + controller.getSessionId());
-        // System.out.println("controller watch paths: " + watchPaths);
+    boolean result = TestHelper.verify(() -> {
+      Map<String, Set<String>> watchers = ZkTestHelper.getListenersBySession(ZK_ADDR);
+      // Set<String> watchPaths = watchers.get("0x" + controllerManager.getSessionId());

Review comment:
       Maybe remove this?




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


[GitHub] [helix] jiajunwang commented on pull request #1716: Fix unstable test TestZkCallbackHandlerLeak.

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on pull request #1716:
URL: https://github.com/apache/helix/pull/1716#issuecomment-828038343


   Thanks for the review @narendly and @xyuanlu , I agree with your comments. But I'm not going to refactor the whole test case. This PR is to make the test more stable only.
   Let's restrict the scope of this PR to the currently modified part plus some obvious code style changes.


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


[GitHub] [helix] jiajunwang closed pull request #1716: Fix unstable test TestZkCallbackHandlerLeak.

Posted by GitBox <gi...@apache.org>.
jiajunwang closed pull request #1716:
URL: https://github.com/apache/helix/pull/1716


   


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


[GitHub] [helix] jiajunwang commented on pull request #1716: Fix unstable test TestZkCallbackHandlerLeak.

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on pull request #1716:
URL: https://github.com/apache/helix/pull/1716#issuecomment-828137173


   Test is still not stable with this change. I will try to figure out why and reopen this PR with more fixes.


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


[GitHub] [helix] jiajunwang commented on pull request #1716: Fix unstable test TestZkCallbackHandlerLeak.

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on pull request #1716:
URL: https://github.com/apache/helix/pull/1716#issuecomment-828043144


   > Q: For line 483 and 487, should we also consider using `verify`?
   
   That is a little bit different. To use verifier, we can wait for something to happen. However, it is not a good tool to wait for something that does not happen. I prefer to keep it for now. Verify is just different and we need to change the related test logic.


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


[GitHub] [helix] narendly commented on a change in pull request #1716: Fix unstable test TestZkCallbackHandlerLeak.

Posted by GitBox <gi...@apache.org>.
narendly commented on a change in pull request #1716:
URL: https://github.com/apache/helix/pull/1716#discussion_r621660123



##########
File path: helix-core/src/test/java/org/apache/helix/integration/TestZkCallbackHandlerLeak.java
##########
@@ -162,33 +154,25 @@ public boolean verify() throws Exception {
     Assert.assertTrue(result);
 
     // check controller zk-watchers
-    result = TestHelper.verify(new TestHelper.Verifier() {
-
-      @Override
-      public boolean verify() throws Exception {
-        Map<String, Set<String>> watchers = ZkTestHelper.getListenersBySession(ZK_ADDR);
-        Set<String> watchPaths = watchers.get("0x" + controller.getSessionId());
-        // System.out.println("controller watch paths after session expiry: " + watchPaths);
-
-        // where n is number of nodes and r is number of resources
-        // one participant is disconnected, and its task current states are removed
-        return watchPaths.size() == (8 + r + (6 + r + taskResourceCount) * (n - 1) + 6 + r);
-      }
+    result = TestHelper.verify(() -> {
+      Map<String, Set<String>> watchers = ZkTestHelper.getListenersBySession(ZK_ADDR);
+      Set<String> watchPaths = watchers.get("0x" + controller.getSessionId());
+      // System.out.println("controller watch paths after session expiry: " + watchPaths);

Review comment:
       Do we want to leave this print statement?

##########
File path: helix-core/src/test/java/org/apache/helix/integration/TestZkCallbackHandlerLeak.java
##########
@@ -494,12 +466,12 @@ public void testCurrentStatePathLeakingByAsycRemoval() throws Exception {
     }
 
     // verify new watcher is installed on the new node
-    boolean result = TestHelper.verify(() -> {
-      return ZkTestHelper.getListenersByZkPath(ZK_ADDR).keySet().contains(jobKey.getPath());
-    }, TestHelper.WAIT_DURATION);
-    Assert.assertTrue(result, "Should get initial clusterConfig callback invoked");
-    rpWatchPaths = ZkTestHelper.getZkWatch(rpManager.getZkClient());
-    Assert.assertTrue(rpWatchPaths.get("dataWatches").contains(jobKey.getPath()));
+    boolean result = TestHelper.verify(
+        () -> ZkTestHelper.getListenersByZkPath(ZK_ADDR).keySet().contains(jobKey.getPath())
+            && ZkTestHelper.getZkWatch(rpManager.getZkClient()).get("dataWatches")
+            .contains(jobKey.getPath()), TestHelper.WAIT_DURATION);
+    Assert.assertTrue(result,
+        "Should get initial clusterConfig callback invoked and add data watchers");
 
     LOG.info("remove job");

Review comment:
       Logging is probably not necessary for tests?




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