Skip to content

Commit 7f32d6c

Browse files
nyl3532016niuyulin
authored andcommitted
HBASE-25837 TestRollingRestart is flaky (#3220)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
1 parent 4d9a360 commit 7f32d6c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRollingRestart.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.apache.hadoop.hbase.client.RegionInfo;
3939
import org.apache.hadoop.hbase.client.RegionLocator;
4040
import org.apache.hadoop.hbase.client.Table;
41+
import org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure;
4142
import org.apache.hadoop.hbase.testclassification.LargeTests;
4243
import org.apache.hadoop.hbase.testclassification.MasterTests;
4344
import org.apache.hadoop.hbase.util.Bytes;
@@ -68,6 +69,7 @@ public class TestRollingRestart {
6869

6970
private static final Logger LOG = LoggerFactory.getLogger(TestRollingRestart.class);
7071

72+
private static HBaseTestingUtility TEST_UTIL;
7173
@Rule
7274
public TestName name = new TestName();
7375

@@ -89,7 +91,7 @@ public void testBasicRollingRestart() throws Exception {
8991
Configuration conf = HBaseConfiguration.create();
9092
conf.setBoolean(HConstants.HBASE_SPLIT_WAL_COORDINATED_BY_ZK,
9193
splitWALCoordinatedByZK);
92-
HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(conf);
94+
TEST_UTIL = new HBaseTestingUtility(conf);
9395
StartMiniClusterOption option = StartMiniClusterOption.builder()
9496
.numMasters(NUM_MASTERS).numRegionServers(NUM_RS).numDataNodes(NUM_RS).build();
9597
TEST_UTIL.startMiniCluster(option);
@@ -220,6 +222,16 @@ public void testBasicRollingRestart() throws Exception {
220222
TEST_UTIL.shutdownMiniCluster();
221223
}
222224

225+
/**
226+
* Checks if the SCP of specific dead server has been executed.
227+
* @return true if the SCP of specific serverName has been executed, false if not
228+
*/
229+
private boolean isDeadServerSCPExecuted(ServerName serverName) throws IOException {
230+
return TEST_UTIL.getMiniHBaseCluster().getMaster().getProcedures().stream()
231+
.anyMatch(p -> p instanceof ServerCrashProcedure
232+
&& ((ServerCrashProcedure) p).getServerName().equals(serverName));
233+
}
234+
223235
private void waitForRSShutdownToStartAndFinish(MasterThread activeMaster,
224236
ServerName serverName) throws InterruptedException, IOException {
225237
ServerManager sm = activeMaster.getMaster().getServerManager();
@@ -230,6 +242,9 @@ private void waitForRSShutdownToStartAndFinish(MasterThread activeMaster,
230242
}
231243
log("Server [" + serverName + "] marked as dead, waiting for it to " +
232244
"finish dead processing");
245+
246+
TEST_UTIL.waitFor(60000, () -> isDeadServerSCPExecuted(serverName));
247+
233248
while (sm.areDeadServersInProgress()) {
234249
log("Server [" + serverName + "] still being processed, waiting");
235250
Thread.sleep(100);

0 commit comments

Comments
 (0)