liuml07 commented on a change in pull request #1435: HBASE-24112 [RSGroup] 
Support renaming rsgroup
URL: https://github.com/apache/hbase/pull/1435#discussion_r405182537
 
 

 ##########
 File path: 
hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin1.java
 ##########
 @@ -468,4 +468,31 @@ public boolean evaluate() throws Exception {
     // Cleanup
     TEST_UTIL.deleteTable(tn1);
   }
+
+  @Test
+  public void testRenameRSGroup() throws Exception {
+    // Add rsgroup, and assign 2 servers and a table to it.
+    RSGroupInfo oldgroup = addGroup("oldgroup", 2);
+    TableName tb = TableName.valueOf("testRename");
+    TEST_UTIL.createTable(tb, "tr");
+    ADMIN.setRSGroup(Sets.newHashSet(tb), oldgroup.getName());
+    Thread.sleep(500);
+    oldgroup = ADMIN.getRSGroup(oldgroup.getName());
+    assertEquals(2, oldgroup.getServers().size());
+    assertEquals(oldgroup.getName(), ADMIN.getRSGroup(tb).getName());
+
+    // Rename rsgroup
+    ADMIN.renameRSGroup(oldgroup.getName(), "newgroup");
+    Set<Address> servers = oldgroup.getServers();
+    RSGroupInfo newgroup = ADMIN.getRSGroup("newgroup");
+    assertEquals(servers.size(), newgroup.getServers().size());
+    int match = 0;
+    for (Address addr : newgroup.getServers()) {
+      if (servers.contains(addr)) {
+        match++;
+      }
+    }
+    assertEquals(servers.size(), match);
 
 Review comment:
   Yes I agree this is useful assertion.
   
   Actually I was wondering if we can add more context to this test as well as 
assertions. For example, we create and assign another table to another rsgroup. 
So the "if" clause checking rsgroup name in `RSGroupInfoManagerImpl.java` will 
get tested. Otherwise this test may still pass even when we remove the "if". By 
the "if" I mean:
   ```
   if (rsgroup.get().equals(oldName)) {
       updateTables.add(table.getValue().getTableName());
     }
   ```

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


With regards,
Apache Git Services

Reply via email to