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/28 01:28:34 UTC

[GitHub] [helix] kaisun2000 opened a new pull request #1492: fix TestCleanupExternalView.test

kaisun2000 opened a new pull request #1492:
URL: https://github.com/apache/helix/pull/1492


   
   
   ### Issues
   
   - [x] My PR addresses the following Helix issues and references them in the PR description:
   
   fix #1458 
   
   ### Description
   
   - [x] Here are some details about my PR, including screenshots of any UI changes:
   Flaky test with 10 * 100ms. This may not be enough when there is
   logging or Zk is slow in github. Fix with TestHelper.verify();
   
   ### Tests
   
   - [ ] The following tests are written for this issue:
   
   (List the names of added unit/integration tests)
   
   - [x] The following is the result of the "mvn test" command on the appropriate module:
   
   github run
   ### 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] kaisun2000 commented on pull request #1492: fix TestCleanupExternalView.test

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


   This diff is approved. Please help to merge
   
   >Flaky test with 10 * 100ms. This may not be enough when there is
   logging or Zk is slow in github. Fix with TestHelper.verify();


----------------------------------------------------------------
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 #1492: fix TestCleanupExternalView.test

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



##########
File path: helix-core/src/test/java/org/apache/helix/integration/TestCleanupExternalView.java
##########
@@ -109,18 +109,14 @@ public void test() throws Exception {
     // System.out.println("re-enabling controller");
     admin.enableCluster(clusterName, true);
 
-    ExternalView externalView = null;
-    for (int i = 0; i < 10; i++) {
-      Thread.sleep(100);
-      externalView = accessor.getProperty(keyBuilder.externalView("TestDB0"));
-      // System.out.println("externalView: " + externalView);
-      if (externalView == null) {
-        break;
-      }
-    }
 
-    Assert.assertNull(externalView, "external-view for TestDB0 should be removed, but was: "
-        + externalView);
+    result = TestHelper.verify(() -> {
+      ExternalView externalView = accessor.getProperty(keyBuilder.externalView("TestDB0"));
+      return externalView == null;
+    }, TestHelper.WAIT_DURATION);
+
+    ExternalView ev = accessor.getProperty(keyBuilder.externalView("TestDB0"));

Review comment:
       If it is just for the assert log, then you can do this,
   
   ExternalView externalView = null;
   result = TestHelper.verify(() -> {
     externalView = accessor.getProperty(keyBuilder.externalView("TestDB0"));
     return externalView == null;
   }, TestHelper.WAIT_DURATION);
   Assert.assertTrue(result, "external-view for TestDB0 should be removed, but was: " + externalView);




----------------------------------------------------------------
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] kaisun2000 commented on a change in pull request #1492: fix TestCleanupExternalView.test

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



##########
File path: helix-core/src/test/java/org/apache/helix/integration/TestCleanupExternalView.java
##########
@@ -109,18 +109,14 @@ public void test() throws Exception {
     // System.out.println("re-enabling controller");
     admin.enableCluster(clusterName, true);
 
-    ExternalView externalView = null;
-    for (int i = 0; i < 10; i++) {
-      Thread.sleep(100);
-      externalView = accessor.getProperty(keyBuilder.externalView("TestDB0"));
-      // System.out.println("externalView: " + externalView);
-      if (externalView == null) {
-        break;
-      }
-    }
 
-    Assert.assertNull(externalView, "external-view for TestDB0 should be removed, but was: "
-        + externalView);
+    result = TestHelper.verify(() -> {
+      ExternalView externalView = accessor.getProperty(keyBuilder.externalView("TestDB0"));
+      return externalView == null;
+    }, TestHelper.WAIT_DURATION);
+
+    ExternalView ev = accessor.getProperty(keyBuilder.externalView("TestDB0"));

Review comment:
       This way does not work. Lambda varable captured (externalView here) needs to be final. Changed it to use instance variable then.

##########
File path: helix-core/src/test/java/org/apache/helix/integration/TestCleanupExternalView.java
##########
@@ -42,6 +42,7 @@
  * orphan external-view
  */
 public class TestCleanupExternalView extends ZkUnitTestBase {
+  private ExternalView _externalView = null;

Review comment:
       right. 
   just to make sure this is explicit, namely in normal path this is expected to be null all the time.




----------------------------------------------------------------
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 #1492: fix TestCleanupExternalView.test

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



##########
File path: helix-core/src/test/java/org/apache/helix/integration/TestCleanupExternalView.java
##########
@@ -109,18 +109,14 @@ public void test() throws Exception {
     // System.out.println("re-enabling controller");
     admin.enableCluster(clusterName, true);
 
-    ExternalView externalView = null;
-    for (int i = 0; i < 10; i++) {
-      Thread.sleep(100);
-      externalView = accessor.getProperty(keyBuilder.externalView("TestDB0"));
-      // System.out.println("externalView: " + externalView);
-      if (externalView == null) {
-        break;
-      }
-    }
 
-    Assert.assertNull(externalView, "external-view for TestDB0 should be removed, but was: "
-        + externalView);
+    result = TestHelper.verify(() -> {
+      ExternalView externalView = accessor.getProperty(keyBuilder.externalView("TestDB0"));
+      return externalView == null;
+    }, TestHelper.WAIT_DURATION);
+
+    ExternalView ev = accessor.getProperty(keyBuilder.externalView("TestDB0"));

Review comment:
       It certainly works. But it would be better to have a wrapper class (AtomicReference for example), to contain the result. The wrapper class can be final. Anyway, the goal is to ensure all test cases are independent of each other as far as we can.
   Just a suggestion, the current logic is also fine : )




----------------------------------------------------------------
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 merged pull request #1492: fix TestCleanupExternalView.test

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


   


----------------------------------------------------------------
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] zhangmeng916 commented on a change in pull request #1492: fix TestCleanupExternalView.test

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



##########
File path: helix-core/src/test/java/org/apache/helix/integration/TestCleanupExternalView.java
##########
@@ -42,6 +42,7 @@
  * orphan external-view
  */
 public class TestCleanupExternalView extends ZkUnitTestBase {
+  private ExternalView _externalView = null;

Review comment:
       nit: = null is not needed.




----------------------------------------------------------------
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 #1492: fix TestCleanupExternalView.test

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



##########
File path: helix-core/src/test/java/org/apache/helix/integration/TestCleanupExternalView.java
##########
@@ -109,18 +109,14 @@ public void test() throws Exception {
     // System.out.println("re-enabling controller");
     admin.enableCluster(clusterName, true);
 
-    ExternalView externalView = null;
-    for (int i = 0; i < 10; i++) {
-      Thread.sleep(100);
-      externalView = accessor.getProperty(keyBuilder.externalView("TestDB0"));
-      // System.out.println("externalView: " + externalView);
-      if (externalView == null) {
-        break;
-      }
-    }
 
-    Assert.assertNull(externalView, "external-view for TestDB0 should be removed, but was: "
-        + externalView);
+    result = TestHelper.verify(() -> {
+      ExternalView externalView = accessor.getProperty(keyBuilder.externalView("TestDB0"));
+      return externalView == null;
+    }, TestHelper.WAIT_DURATION);
+
+    ExternalView ev = accessor.getProperty(keyBuilder.externalView("TestDB0"));

Review comment:
       Why get it once more?




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