aalhour commented on code in PR #5681:
URL: https://github.com/apache/hbase/pull/5681#discussion_r1495664151


##########
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerReportForDuty.java:
##########
@@ -241,6 +243,136 @@ public void run() {
     waitForClusterOnline(master);
   }
 
+  /**
+   * Tests that the RegionServer's reportForDuty gets rejected by the master 
when the master is
+   * configured to reject decommissioned hosts and when there is a match for 
the joining
+   * RegionServer in the list of decommissioned servers. Test case for 
HBASE-28342.
+   */
+  @Test
+  public void 
testReportForDutyGetsRejectedByMasterWhenConfiguredToRejectDecommissionedHosts()
+    throws Exception {
+    // Start a master and wait for it to become the active/primary master.
+    // Use a random unique port
+    cluster.getConfiguration().setInt(HConstants.MASTER_PORT, 
HBaseTestingUtil.randomFreePort());
+    
cluster.getConfiguration().setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART,
 1);
+    
cluster.getConfiguration().setInt(ServerManager.WAIT_ON_REGIONSERVERS_MAXTOSTART,
 1);
+
+    // Set the cluster to reject decommissioned hosts
+    
cluster.getConfiguration().setBoolean(HConstants.REJECT_DECOMMISSIONED_HOSTS_KEY,
 true);
+
+    master = cluster.addMaster();
+    rs = cluster.addRegionServer();
+    LOG.debug("Starting master: " + master.getMaster().getServerName());
+    master.start();
+    rs.start();
+    waitForClusterOnline(master);
+
+    assertEquals(0, 
master.getMaster().listDecommissionedRegionServers().size());
+    assertEquals(0, 
master.getMaster().getServerManager().getDrainingServersList().size());
+    assertEquals(1, 
master.getMaster().getServerManager().getOnlineServers().size());
+
+    // Decommission the region server and tries to re-add it
+    List<ServerName> serversToDecommission = new ArrayList<ServerName>();
+    serversToDecommission.add(rs.getRegionServer().getServerName());
+    master.getMaster().decommissionRegionServers(serversToDecommission, true);

Review Comment:
   Nice 👍 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@hbase.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to