This is an automated email from the ASF dual-hosted git repository.
xucang pushed a commit to branch branch-1
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-1 by this push:
new d16058e HBASE-22051 Expect values are hard-coded in the verifications
of TestRSGroupsBasics
d16058e is described below
commit d16058e54a8af225e90bd08038340b8cbcef1f67
Author: Xiang LI <[email protected]>
AuthorDate: Thu Mar 21 00:00:55 2019 +0800
HBASE-22051 Expect values are hard-coded in the verifications of
TestRSGroupsBasics
Signed-off-by: Xu Cang <[email protected]>
---
.../hadoop/hbase/rsgroup/TestRSGroupsBasics.java | 42 +++++++++++++---------
1 file changed, 25 insertions(+), 17 deletions(-)
diff --git
a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBasics.java
b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBasics.java
index 1690b29..f1ca558 100644
---
a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBasics.java
+++
b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBasics.java
@@ -80,10 +80,10 @@ public class TestRSGroupsBasics extends TestRSGroupsBase {
@Test
public void testBasicStartUp() throws IOException {
RSGroupInfo defaultInfo =
rsGroupAdmin.getRSGroupInfo(RSGroupInfo.DEFAULT_GROUP);
- assertEquals(4, defaultInfo.getServers().size());
- // Assignment of root and meta regions.
+ assertEquals(NUM_SLAVES_BASE, defaultInfo.getServers().size());
+ // Assignment of meta, namespace and rsgroup regions.
int count =
master.getAssignmentManager().getRegionStates().getRegionAssignments().size();
- //3 meta,namespace, group
+ // 3 (meta, namespace and rsgroup)
assertEquals(3, count);
}
@@ -176,23 +176,28 @@ public class TestRSGroupsBasics extends TestRSGroupsBase {
@Test
public void testClearDeadServers() throws Exception {
- final RSGroupInfo newGroup = addGroup(rsGroupAdmin,
"testClearDeadServers", 3);
+ // move region servers from default group to new group
+ final int serverCountToMoveToNewGroup = 3;
+ final RSGroupInfo newGroup =
+ addGroup(rsGroupAdmin, "testClearDeadServers",
serverCountToMoveToNewGroup);
- ServerName targetServer = ServerName.parseServerName(
+ // stop 1 region server in new group
+ ServerName serverToStop = ServerName.parseServerName(
newGroup.getServers().iterator().next().toString());
- AdminProtos.AdminService.BlockingInterface targetRS =
- ((ClusterConnection) admin.getConnection()).getAdmin(targetServer);
+ AdminProtos.AdminService.BlockingInterface regionServerToStop =
+ ((ClusterConnection) admin.getConnection()).getAdmin(serverToStop);
try {
- targetServer = ProtobufUtil.toServerName(targetRS.getServerInfo(null,
+ serverToStop =
ProtobufUtil.toServerName(regionServerToStop.getServerInfo(null,
GetServerInfoRequest.newBuilder().build()).getServerInfo().getServerName());
//stopping may cause an exception
//due to the connection loss
- targetRS.stopServer(null,
+ regionServerToStop.stopServer(null,
AdminProtos.StopServerRequest.newBuilder().setReason("Die").build());
} catch(Exception e) {
}
+
+ // wait for the stopped region server to show up in dead server list
final HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
- //wait for stopped regionserver to dead server list
TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() {
@Override
public boolean evaluate() throws Exception {
@@ -200,16 +205,19 @@ public class TestRSGroupsBasics extends TestRSGroupsBase {
&& cluster.getClusterStatus().getDeadServerNames().size() > 0;
}
});
-
assertFalse(cluster.getClusterStatus().getServers().contains(targetServer));
-
assertTrue(cluster.getClusterStatus().getDeadServerNames().contains(targetServer));
- assertTrue(newGroup.getServers().contains(targetServer.getAddress()));
- //clear dead servers list
- List<ServerName> notClearedServers =
admin.clearDeadServers(Lists.newArrayList(targetServer));
+ // verify
+
assertFalse(cluster.getClusterStatus().getServers().contains(serverToStop));
+
assertTrue(cluster.getClusterStatus().getDeadServerNames().contains(serverToStop));
+ assertTrue(newGroup.getServers().contains(serverToStop.getAddress()));
+
+ // clear dead servers list
+ List<ServerName> notClearedServers =
admin.clearDeadServers(Lists.newArrayList(serverToStop));
assertEquals(0, notClearedServers.size());
+ // verify if the stopped region server gets cleared and removed from the
group
Set<Address> newGroupServers =
rsGroupAdmin.getRSGroupInfo(newGroup.getName()).getServers();
- assertFalse(newGroupServers.contains(targetServer.getAddress()));
- assertEquals(2, newGroupServers.size());
+ assertFalse(newGroupServers.contains(serverToStop.getAddress()));
+ assertEquals(serverCountToMoveToNewGroup - 1 /* 1 stopped */,
newGroupServers.size());
}
}
\ No newline at end of file