Skip to content

Commit b8f71ec

Browse files
committed
HBASE-27193 TestZooKeeper is flaky (#4615)
Signed-off-by: Guanghao Zhang <[email protected]> (cherry picked from commit 2662607)
1 parent 3316b48 commit b8f71ec

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

hbase-server/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,15 @@ public void testRegionAssignmentAfterMasterRecoveryDueToZKExpiry() throws Except
192192
m.getZooKeeper().close();
193193
MockLoadBalancer.retainAssignCalled = false;
194194
final int expectedNumOfListeners = countPermanentListeners(zkw);
195+
// the master could already been aborted by some background tasks but here we call abort
196+
// directly to make sure this will happen
195197
m.abort("Test recovery from zk session expired",
196198
new KeeperException.SessionExpiredException());
197-
assertTrue(m.isStopped()); // Master doesn't recover any more
199+
// it is possible that our abort call above returned earlier because of someone else has
200+
// already called abort, but it is possible that it has not finished the abort call yet so the
201+
// isStopped flag is still false, let's wait for sometime.
202+
TEST_UTIL.waitFor(5000, () -> m.isStopped()); // Master doesn't recover any more
203+
198204
// The recovered master should not call retainAssignment, as it is not a
199205
// clean startup.
200206
assertFalse("Retain assignment should not be called", MockLoadBalancer.retainAssignCalled);

0 commit comments

Comments
 (0)