diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/region/TestMasterRegionOnTwoFileSystems.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/region/TestMasterRegionOnTwoFileSystems.java index 60966e5b7c96..6bf8379cf433 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/region/TestMasterRegionOnTwoFileSystems.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/region/TestMasterRegionOnTwoFileSystems.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -188,7 +189,7 @@ public void testFlushAndCompact() throws Exception { LOG.info("wal archive dir {}", walArchiveDir); AbstractFSWAL wal = (AbstractFSWAL) region.region.getWAL(); Path currentWALFile = wal.getCurrentFileName(); - for (;;) { + for (int i = 0; ; i++) { region.requestRollAll(); region.waitUntilWalRollFinished(); Path newWALFile = wal.getCurrentFileName(); @@ -196,6 +197,10 @@ public void testFlushAndCompact() throws Exception { if (!newWALFile.equals(currentWALFile)) { break; } + if (i == 10) { + fail("Can not roll wal after " + i + " times"); + } + Thread.sleep(1000); } HFILE_UTIL.waitFor(15000, () -> { try {