Skip to content

Commit

Permalink
HBASE-25897 TestRetainAssignmentOnRestart is flaky after HBASE-25032 (#…
Browse files Browse the repository at this point in the history
…3281)

Signed-off-by: Xiaolin Ha <[email protected]>
  • Loading branch information
Apache9 committed May 20, 2021
1 parent 3040be1 commit d78c164
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,8 @@ public void abortProcess() {
}
}

private void startProcedureExecutor() throws IOException {
// will be override in UT
protected void startProcedureExecutor() throws IOException {
procedureExecutor.startWorkers();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.List;
import java.util.Map;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.StartMiniClusterOption;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure;
Expand All @@ -52,6 +54,33 @@ public class TestRetainAssignmentOnRestart extends AbstractTestRestartCluster {

private static int NUM_OF_RS = 3;

public static final class HMasterForTest extends HMaster {

public HMasterForTest(Configuration conf) throws IOException {
super(conf);
}

@Override
protected void startProcedureExecutor() throws IOException {
// only start procedure executor when we have all the regionservers ready to take regions
new Thread(() -> {
for (;;) {
if (getServerManager().createDestinationServersList().size() == NUM_OF_RS) {
try {
HMasterForTest.super.startProcedureExecutor();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
}).start();
}
}

@Override
protected boolean splitWALCoordinatedByZk() {
return true;
Expand Down Expand Up @@ -205,7 +234,8 @@ private void setupCluster() throws Exception, IOException, InterruptedException
HConstants.ZK_CONNECTION_REGISTRY_CLASS);
// Enable retain assignment during ServerCrashProcedure
UTIL.getConfiguration().setBoolean(ServerCrashProcedure.MASTER_SCP_RETAIN_ASSIGNMENT, true);
UTIL.startMiniCluster(NUM_OF_RS);
UTIL.startMiniCluster(StartMiniClusterOption.builder().masterClass(HMasterForTest.class)
.numRegionServers(NUM_OF_RS).build());

// Turn off balancer
UTIL.getMiniHBaseCluster().getMaster().getMasterRpcServices().synchronousBalanceSwitch(false);
Expand Down

0 comments on commit d78c164

Please sign in to comment.