mattisonchao commented on a change in pull request #11062: URL: https://github.com/apache/pulsar/pull/11062#discussion_r657927362
########## File path: pulsar-metadata/src/test/java/org/apache/pulsar/metadata/ZKSessionTest.java ########## @@ -156,39 +153,31 @@ public void testReacquireLeadershipAfterSessionLost() throws Exception { @Cleanup LeaderElection<String> le1 = coordinationService.getLeaderElection(String.class, path, leaderElectionEvents::add); - + // --- test manual elect le1.elect("value-1").join(); assertEquals(le1.getState(), LeaderElectionState.Leading); LeaderElectionState les = leaderElectionEvents.poll(5, TimeUnit.SECONDS); assertEquals(les, LeaderElectionState.Leading); - + // --- expire session zks.expireSession(((ZKMetadataStore) store).getZkSessionId()); SessionEvent e = sessionEvents.poll(5, TimeUnit.SECONDS); assertEquals(e, SessionEvent.ConnectionLost); e = sessionEvents.poll(10, TimeUnit.SECONDS); assertEquals(e, SessionEvent.SessionLost); - - Awaitility.await().untilAsserted(() -> { - assertEquals(le1.getState(), LeaderElectionState.Leading); - }); - - les = leaderElectionEvents.poll(); - assertNull(les); - + // --- test le1 can be leader + Awaitility.await() + .untilAsserted(()-> assertEquals(le1.getState(),LeaderElectionState.Leading)); // reacquire leadership e = sessionEvents.poll(10, TimeUnit.SECONDS); assertEquals(e, SessionEvent.Reconnected); e = sessionEvents.poll(10, TimeUnit.SECONDS); assertEquals(e, SessionEvent.SessionReestablished); - - Awaitility.await().untilAsserted(() -> { - assertEquals(le1.getState(), LeaderElectionState.Leading); - }); - les = leaderElectionEvents.poll(); - assertNull(les); - + // ---- after 2000 millis, the le1 is also can be leader. + Thread.sleep(2_000); Review comment: Waiting for 2000 milliseconds to verify that the node can also be the leader. -- 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: us...@infra.apache.org