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 2021/06/24 06:34:39 UTC

[GitHub] [pulsar] lhotari commented on a change in pull request #11062: [ Issue 11032 ] Fixed flaky test ZKSessionTest.. #11032

lhotari commented on a change in pull request #11062:
URL: https://github.com/apache/pulsar/pull/11062#discussion_r657664022



##########
File path: pulsar-metadata/src/test/java/org/apache/pulsar/metadata/ZKSessionTest.java
##########
@@ -183,9 +182,10 @@ public void testReacquireLeadershipAfterSessionLost() throws Exception {
         e = sessionEvents.poll(10, TimeUnit.SECONDS);
         assertEquals(e, SessionEvent.SessionReestablished);
 
-        Awaitility.await().untilAsserted(() -> {
-                    assertEquals(le1.getState(), LeaderElectionState.Leading);
-        });
+        // due to zookeeper async notice, we need to wait.
+        Awaitility.await()
+                .until(() -> le1.getState() == LeaderElectionState.Leading);
+        assertEquals(le1.getState(), LeaderElectionState.Leading);

Review comment:
       @mattisonchao It's a good practice to use `untilAsserted` + asserts (instead of `.until`) because of the reason what Enrico explained.




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