public void restartRegionServer(ServerName serverName) throws IOException {
    List<ServerName> onlineServers = serverManager.getOnlineServersList();
    long startCode = -1;
    for (ServerName s : onlineServers) {
      if (s.getAddress().equals(serverName.getAddress())) {
        startCode = s.getStartcode() + 1;
        break;
      }
    }
    if (startCode == -1) {
      return;
    }
    ServerName sn = ServerName.valueOf(serverName.getAddress().toString(), startCode);
    serverManager.regionServerReport(sn, ServerMetricsBuilder.newBuilder(sn)
      .setLastReportTimestamp(EnvironmentEdgeManager.currentTime()).build());
  }
Call this restart method only after running MockMasterServices#start() The RSs can be
differentiated by the port number, see ServerName in MockMasterServices#start() method above.
Restart of region server will have new startcode in server name
@param serverName Server name to be restarted
hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/MockMasterServices.java