You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2022/07/07 15:23:12 UTC

[GitHub] [bookkeeper] hangc0276 commented on a diff in pull request #3392: Useing Awaitility for asynchroneous testing.

hangc0276 commented on code in PR #3392:
URL: https://github.com/apache/bookkeeper/pull/3392#discussion_r916003323


##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieZKExpireTest.java:
##########
@@ -95,11 +97,11 @@ conf, new TestBookieImpl(conf),
             assertNotNull("Send thread not found", sendthread);
 
             sendthread.suspend();
-            Thread.sleep(2 * conf.getZkTimeout());
+            await().atMost(2L * conf.getZkTimeout(), TimeUnit.MILLISECONDS).await();
             sendthread.resume();
 
             // allow watcher thread to run
-            Thread.sleep(3000);
+            await().atMost(3, TimeUnit.SECONDS).await();

Review Comment:
   +1



##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AutoRecoveryMainTest.java:
##########
@@ -49,11 +52,9 @@ public void testStartup() throws Exception {
         AutoRecoveryMain main = new AutoRecoveryMain(confByIndex(0));
         try {
             main.start();
-            Thread.sleep(500);
-            assertTrue("AuditorElector should be running",
-                    main.auditorElector.isRunning());
-            assertTrue("Replication worker should be running",
-                    main.replicationWorker.isRunning());
+            await().atMost(1, SECONDS).untilAsserted(() ->

Review Comment:
   Remove the atMost logic and use the default most await time?



##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AutoRecoveryMainTest.java:
##########
@@ -66,12 +67,9 @@ public void testStartup() throws Exception {
     public void testShutdown() throws Exception {
         AutoRecoveryMain main = new AutoRecoveryMain(confByIndex(0));
         main.start();
-        Thread.sleep(500);
-        assertTrue("AuditorElector should be running",
-                main.auditorElector.isRunning());
-        assertTrue("Replication worker should be running",
-                main.replicationWorker.isRunning());
-
+        await().atMost(1, SECONDS).untilAsserted(()->

Review Comment:
   The same above



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

To unsubscribe, e-mail: issues-unsubscribe@bookkeeper.apache.org

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