xcangCRM commented on a change in pull request #1417: HBASE-24102 : Remove decommissioned RS from target servers while unlo… URL: https://github.com/apache/hbase/pull/1417#discussion_r402621102
########## File path: hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionMover.java ########## @@ -238,4 +245,139 @@ public void testTargetServerDeadWhenLoading() throws Exception { assertFalse(rm.load()); } } + + @Test + public void testDecomServerExclusionWithAck() throws Exception { + MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); + HRegionServer excludeServer = cluster.getRegionServer(1); + List<HRegion> regions = excludeServer.getRegions(); + int regionsExcludeServer = excludeServer.getNumberOfOnlineRegions(); + TEST_UTIL.getAdmin().decommissionRegionServers( + Collections.singletonList(excludeServer.getServerName()), false); + + waitForServerDecom(excludeServer); + + HRegionServer regionServer = cluster.getRegionServer(0); + String rsName = regionServer.getServerName().getHostname(); + int port = regionServer.getServerName().getPort(); + String hostname = rsName + ":" + Integer.toString(port); + RegionMoverBuilder rmBuilder = new RegionMoverBuilder(hostname, TEST_UTIL.getConfiguration()) + .ack(true); + + int targetServerRegions = cluster.getRegionServer(2).getRegions().size(); + int sourceServerRegions = regionServer.getRegions().size(); + + try (RegionMover regionMover = rmBuilder.build()) { + Assert.assertTrue(regionMover.unload()); + LOG.info("Unloading {}", hostname); + assertEquals(0, regionServer.getNumberOfOnlineRegions()); + assertEquals(regionsExcludeServer, cluster.getRegionServer(1).getNumberOfOnlineRegions()); + LOG.info("Before:" + regionsExcludeServer + " After:" + + cluster.getRegionServer(1).getNumberOfOnlineRegions()); + List<HRegion> regionList = cluster.getRegionServer(1).getRegions(); + int index = 0; + for (HRegion hRegion : regionList) { + Assert.assertEquals(hRegion, regions.get(index++)); + } + Assert.assertEquals(targetServerRegions + sourceServerRegions, + cluster.getRegionServer(2).getNumberOfOnlineRegions()); + Assert.assertTrue(regionMover.load()); + } + + TEST_UTIL.getAdmin().recommissionRegionServer(excludeServer.getServerName(), + Collections.emptyList()); + } + + private void waitForServerDecom(HRegionServer excludeServer) throws IOException { + + TEST_UTIL.getAdmin().decommissionRegionServers( + Collections.singletonList(excludeServer.getServerName()), false); + + TEST_UTIL.waitFor(3000, () -> { + try { + List<ServerName> decomServers = TEST_UTIL.getAdmin().listDecommissionedRegionServers(); + return decomServers.size() == 1 + && decomServers.get(0).equals(excludeServer.getServerName()); + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + Review comment: extra space line ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services