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


##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AutoRecoveryMainTest.java:
##########
@@ -98,19 +96,7 @@ public void testAutoRecoverySessionLoss() throws Exception {
          */
         ZKMetadataClientDriver zkMetadataClientDriver1 = 
startAutoRecoveryMain(main1);
         ZooKeeper zk1 = zkMetadataClientDriver1.getZk();
-
-        // Wait until auditor gets elected
-        for (int i = 0; i < 10; i++) {
-            try {
-                if (main1.auditorElector.getCurrentAuditor() != null) {
-                    break;
-                } else {
-                    Thread.sleep(1000);
-                }
-            } catch (IOException e) {
-                Thread.sleep(1000);
-            }
-        }
+        await().until(() -> main1.auditorElector.getAuditor() != null);

Review Comment:
   Why it's different than before? looks like the `getCurrentAuditor()` is 
different than `getAuditor()`



##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieZKExpireTest.java:
##########
@@ -73,35 +74,26 @@ conf, new TestBookieImpl(conf),
                     NullStatsLogger.INSTANCE, UnpooledByteBufAllocator.DEFAULT,
                     new MockUncleanShutdownDetection());
             server.start();
-
-            int secondsToWait = 5;
-            while (!server.isRunning()) {
-                Thread.sleep(1000);
-                if (secondsToWait-- <= 0) {
-                    fail("Bookie never started");
-                }
-            }
+            BookieServer finalServer = server;
+            await().atMost(5, SECONDS).until(finalServer::isRunning);
             Thread sendthread = null;
             threadCount = Thread.activeCount();
             threads = new Thread[threadCount * 2];
             threadCount = Thread.enumerate(threads);
             for (int i = 0; i < threadCount; i++) {
-                if (threads[i].getName().indexOf("SendThread") != -1
+                if (threads[i].getName().contains("SendThread")
                         && !threadset.contains(threads[i])) {
                     sendthread = threads[i];
                     break;
                 }
             }
             assertNotNull("Send thread not found", sendthread);
-
             sendthread.suspend();
-            Thread.sleep(2 * conf.getZkTimeout());

Review Comment:
   Looks like this is part of the testing. It wants to resume the send thread 
after 2* zkTimeout to test the bookie should still working even if the zk 
session is timeout.



-- 
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-unsubscr...@bookkeeper.apache.org

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

Reply via email to