From 6be8c33789ced604b3fd461ec914bf2bf24ebce6 Mon Sep 17 00:00:00 2001 From: Duo Zhang Date: Fri, 18 Mar 2022 23:09:09 +0800 Subject: [PATCH] HBASE-26858 Refactor TestMasterRegionOnTwoFileSystems to avoid dead loop (#4238) Signed-off-by: Xiaolin Ha (cherry picked from commit 31db8e3b3b8cfbc395200ae55ab7f6c52a6d4c76) --- .../master/region/TestMasterRegionOnTwoFileSystems.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 bf157d61b4b..3665ffdc8f3 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 @@ package org.apache.hadoop.hbase.master.region; 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; @@ -185,7 +186,7 @@ public class TestMasterRegionOnTwoFileSystems { 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(); @@ -193,6 +194,10 @@ public class TestMasterRegionOnTwoFileSystems { if (!newWALFile.equals(currentWALFile)) { break; } + if (i == 10) { + fail("Can not roll wal after " + i + " times"); + } + Thread.sleep(1000); } HFILE_UTIL.waitFor(15000, () -> { try {