You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/11/20 13:38:01 UTC

[GitHub] [pulsar] 315157973 opened a new pull request #8647: Remove Thread.sleep from test

315157973 opened a new pull request #8647:
URL: https://github.com/apache/pulsar/pull/8647


   In many cases, we don’t need to sleep for that long. Using `Awaitility` can make the test faster


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



[GitHub] [pulsar] lhotari commented on pull request #8647: Remove Thread.sleep from test

Posted by GitBox <gi...@apache.org>.
lhotari commented on pull request #8647:
URL: https://github.com/apache/pulsar/pull/8647#issuecomment-731188605


   Good work!


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



[GitHub] [pulsar] 315157973 commented on pull request #8647: Use Awaitility instead Thread.sleep in InactiveTopicDeleteTest.java

Posted by GitBox <gi...@apache.org>.
315157973 commented on pull request #8647:
URL: https://github.com/apache/pulsar/pull/8647#issuecomment-731512135


   > Thanks @315157973 for the help.
   
   My pleasure :smile:


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



[GitHub] [pulsar] lhotari commented on pull request #8647: Remove Thread.sleep from test

Posted by GitBox <gi...@apache.org>.
lhotari commented on pull request #8647:
URL: https://github.com/apache/pulsar/pull/8647#issuecomment-731192101


   It looks like that in some cases, there could be a benefit of using `untilAsserted` and placing the test assertions in this block. The pattern is useful when there are multiple conditions. It also reduces the need to have duplicate code for the assertions (compared to the case of using `until`).


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



[GitHub] [pulsar] codelipenghui commented on a change in pull request #8647: Remove Thread.sleep from test

Posted by GitBox <gi...@apache.org>.
codelipenghui commented on a change in pull request #8647:
URL: https://github.com/apache/pulsar/pull/8647#discussion_r527757271



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/InactiveTopicDeleteTest.java
##########
@@ -82,12 +84,14 @@ public void testDeleteWhenNoSubscriptions() throws Exception {
         consumer.close();
         producer.close();
 
-        Thread.sleep(2000);
+        Awaitility.await().atMost(2, TimeUnit.SECONDS).until(() -> admin.topics().getList("prop/ns-abc")
+                .contains(topic));
         Assert.assertTrue(admin.topics().getList("prop/ns-abc")
             .contains(topic));

Review comment:
       It can simplify by untiAssert(), Please check all.




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



[GitHub] [pulsar] 315157973 commented on a change in pull request #8647: Use Awaitility instead Thread.sleep in InactiveTopicDeleteTest.java

Posted by GitBox <gi...@apache.org>.
315157973 commented on a change in pull request #8647:
URL: https://github.com/apache/pulsar/pull/8647#discussion_r527809758



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/InactiveTopicDeleteTest.java
##########
@@ -82,12 +84,14 @@ public void testDeleteWhenNoSubscriptions() throws Exception {
         consumer.close();
         producer.close();
 
-        Thread.sleep(2000);
+        Awaitility.await().atMost(2, TimeUnit.SECONDS).until(() -> admin.topics().getList("prop/ns-abc")
+                .contains(topic));
         Assert.assertTrue(admin.topics().getList("prop/ns-abc")
             .contains(topic));

Review comment:
       Thanks lhotari for the reminder




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



[GitHub] [pulsar] jiazhai commented on pull request #8647: Use Awaitility instead Thread.sleep in InactiveTopicDeleteTest.java

Posted by GitBox <gi...@apache.org>.
jiazhai commented on pull request #8647:
URL: https://github.com/apache/pulsar/pull/8647#issuecomment-731493514


   /pulsarbot run-failure-checks


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



[GitHub] [pulsar] codelipenghui commented on a change in pull request #8647: Use Awaitility instead Thread.sleep in InactiveTopicDeleteTest.java

Posted by GitBox <gi...@apache.org>.
codelipenghui commented on a change in pull request #8647:
URL: https://github.com/apache/pulsar/pull/8647#discussion_r527757271



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/InactiveTopicDeleteTest.java
##########
@@ -82,12 +84,14 @@ public void testDeleteWhenNoSubscriptions() throws Exception {
         consumer.close();
         producer.close();
 
-        Thread.sleep(2000);
+        Awaitility.await().atMost(2, TimeUnit.SECONDS).until(() -> admin.topics().getList("prop/ns-abc")
+                .contains(topic));
         Assert.assertTrue(admin.topics().getList("prop/ns-abc")
             .contains(topic));

Review comment:
       It can simplify by untilAssert(), Please check all.




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



[GitHub] [pulsar] codelipenghui merged pull request #8647: Use Awaitility instead Thread.sleep in InactiveTopicDeleteTest.java

Posted by GitBox <gi...@apache.org>.
codelipenghui merged pull request #8647:
URL: https://github.com/apache/pulsar/pull/8647


   


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



[GitHub] [pulsar] codelipenghui commented on a change in pull request #8647: Use Awaitility instead Thread.sleep in InactiveTopicDeleteTest.java

Posted by GitBox <gi...@apache.org>.
codelipenghui commented on a change in pull request #8647:
URL: https://github.com/apache/pulsar/pull/8647#discussion_r528076107



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/InactiveTopicDeleteTest.java
##########
@@ -538,13 +523,8 @@ public void testDeleteWhenNoSubscriptionsWithTopicLevelPolicies() throws Excepti
         admin.topics().setInactiveTopicPolicies(topic2, inactiveTopicPolicies);
 
         //wait for update
-        for (int i = 0; i < 50; i++) {
-            if (admin.topics().getInactiveTopicPolicies(topic2) != null) {
-                break;
-            }
-            Thread.sleep(100);
-        }
-
+        Awaitility.await().atMost(5, TimeUnit.SECONDS).until(()
+                -> admin.topics().getInactiveTopicPolicies(topic2) != null);
         // topic should still exist
         Thread.sleep(2000);

Review comment:
       This one should also can instead by Awaitility




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



[GitHub] [pulsar] 315157973 commented on pull request #8647: Use Awaitility instead Thread.sleep in InactiveTopicDeleteTest.java

Posted by GitBox <gi...@apache.org>.
315157973 commented on pull request #8647:
URL: https://github.com/apache/pulsar/pull/8647#issuecomment-731512148


   /pulsarbot run-failure-checks


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



[GitHub] [pulsar] jiazhai commented on pull request #8647: Use Awaitility instead Thread.sleep in InactiveTopicDeleteTest.java

Posted by GitBox <gi...@apache.org>.
jiazhai commented on pull request #8647:
URL: https://github.com/apache/pulsar/pull/8647#issuecomment-731493771


   Thanks @315157973 for the help. 


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