Umeshkumar9414 commented on code in PR #8547:
URL: https://github.com/apache/hbase/pull/8547#discussion_r3780748583


##########
hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionMoverFilterRSGroupServers.java:
##########
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.util;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.net.Address;
+import org.apache.hadoop.hbase.rsgroup.RSGroupInfo;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.testclassification.MiscTests;
+import org.apache.hadoop.hbase.util.RegionMover.RegionMoverBuilder;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Unit tests for {@link RegionMover#filterRSGroupServers}. Spins up a 2-node 
mini cluster so we can
+ * build a real RegionMover instance; the method under test is pure in-memory 
logic.
+ */
+@Tag(MiscTests.TAG)
+@Tag(MediumTests.TAG)
+public class TestRegionMoverFilterRSGroupServers {
+
+  private static final Logger LOG =
+    LoggerFactory.getLogger(TestRegionMoverFilterRSGroupServers.class);
+
+  private static final HBaseTestingUtility TEST_UTIL = new 
HBaseTestingUtility();
+
+  @BeforeAll
+  public static void setUpBeforeClass() throws Exception {
+    TEST_UTIL.startMiniCluster(2);
+  }
+
+  @AfterAll
+  public static void tearDownAfterClass() throws Exception {
+    TEST_UTIL.shutdownMiniCluster();
+  }
+
+  private RegionMover buildMover() throws Exception {
+    ServerName any = TEST_UTIL.getAdmin().getRegionServers().iterator().next();
+    return new RegionMoverBuilder(any.getHostname() + ":" + any.getPort(),
+      TEST_UTIL.getConfiguration()).build();
+  }
+
+  /**
+   * When all online servers are members of the default group (as the 
coprocessor returns), the
+   * filter must return all of them — no server is dropped.
+   */
+  @Test
+  public void testDefaultGroupReturnsAllServers() throws Exception {
+    try (RegionMover rm = buildMover()) {
+      List<ServerName> allServers = new 
ArrayList<>(TEST_UTIL.getAdmin().getRegionServers());
+
+      RSGroupInfo defaultGroup = new RSGroupInfo(RSGroupInfo.DEFAULT_GROUP);
+      for (ServerName sn : allServers) {
+        defaultGroup.addServer(Address.fromParts(sn.getHostname(), 
sn.getPort()));
+      }
+
+      Collection<ServerName> result = rm.filterRSGroupServers(defaultGroup, 
allServers);
+      assertEquals(allServers.size(), result.size());
+      assertTrue(result.containsAll(allServers));
+    }
+  }
+
+  /** A non-default group with one member must return only that member. */
+  @Test
+  public void testNonDefaultGroupFiltersToMembers() throws Exception {

Review Comment:
   added in testNonDefaultGroupFiltersToMembers



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to