From d525ec6a1214f97bda560095f9775ca96d82f030 Mon Sep 17 00:00:00 2001 From: Duo Zhang Date: Fri, 30 Nov 2018 15:26:04 +0800 Subject: [PATCH] HBASE-21534 TestAssignmentManager is flakey --- .../assignment/TestAssignmentManagerBase.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManagerBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManagerBase.java index 7ab37bc4214..7b5c55014ac 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManagerBase.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentManagerBase.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertNotEquals; import java.io.IOException; import java.io.InterruptedIOException; +import java.io.UncheckedIOException; import java.net.SocketTimeoutException; import java.util.Arrays; import java.util.NavigableMap; @@ -38,8 +39,10 @@ import java.util.concurrent.TimeUnit; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.NotServingRegionException; +import org.apache.hadoop.hbase.ServerMetricsBuilder; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.YouAreDeadException; import org.apache.hadoop.hbase.client.RegionInfo; import org.apache.hadoop.hbase.client.RegionInfoBuilder; import org.apache.hadoop.hbase.ipc.ServerNotRunningYetException; @@ -271,7 +274,18 @@ public abstract class TestAssignmentManagerBase { } protected void doCrash(final ServerName serverName) { + this.master.getServerManager().moveFromOnlineToDeadServers(serverName); this.am.submitServerCrash(serverName, false/* No WALs here */); + // add a new server to avoid killing all the region servers which may hang the UTs + int maxPort = this.master.getServerManager().getOnlineServersList().stream() + .mapToInt(ServerName::getPort).max().getAsInt(); + ServerName newSn = ServerName.valueOf("localhost", 100 + maxPort + 1, 1); + try { + this.master.getServerManager().regionServerReport(newSn, ServerMetricsBuilder.of(newSn)); + } catch (YouAreDeadException e) { + // should not happen + throw new UncheckedIOException(e); + } } protected void doRestart(final ServerName serverName) {