Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-25837 TestRollingRestart is flaky #3220

Merged
merged 1 commit into from
May 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.RegionLocator;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.util.Bytes;
Expand Down Expand Up @@ -68,6 +69,7 @@ public class TestRollingRestart {

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

private static HBaseTestingUtility TEST_UTIL;
@Rule
public TestName name = new TestName();

Expand All @@ -89,7 +91,7 @@ public void testBasicRollingRestart() throws Exception {
Configuration conf = HBaseConfiguration.create();
conf.setBoolean(HConstants.HBASE_SPLIT_WAL_COORDINATED_BY_ZK,
splitWALCoordinatedByZK);
HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(conf);
TEST_UTIL = new HBaseTestingUtility(conf);
StartMiniClusterOption option = StartMiniClusterOption.builder()
.numMasters(NUM_MASTERS).numRegionServers(NUM_RS).numDataNodes(NUM_RS).build();
TEST_UTIL.startMiniCluster(option);
Expand Down Expand Up @@ -220,6 +222,16 @@ public void testBasicRollingRestart() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}

/**
* Checks if the SCP of specific dead server has been executed.
* @return true if the SCP of specific serverName has been executed, false if not
*/
private boolean isDeadServerSCPExecuted(ServerName serverName) throws IOException {
return TEST_UTIL.getMiniHBaseCluster().getMaster().getProcedures().stream()
.anyMatch(p -> p instanceof ServerCrashProcedure
&& ((ServerCrashProcedure) p).getServerName().equals(serverName));
}

private void waitForRSShutdownToStartAndFinish(MasterThread activeMaster,
ServerName serverName) throws InterruptedException, IOException {
ServerManager sm = activeMaster.getMaster().getServerManager();
Expand All @@ -230,6 +242,9 @@ private void waitForRSShutdownToStartAndFinish(MasterThread activeMaster,
}
log("Server [" + serverName + "] marked as dead, waiting for it to " +
"finish dead processing");

TEST_UTIL.waitFor(60000, () -> isDeadServerSCPExecuted(serverName));

while (sm.areDeadServersInProgress()) {
log("Server [" + serverName + "] still being processed, waiting");
Thread.sleep(100);
Expand Down