dlmarion commented on code in PR #5864:
URL: https://github.com/apache/accumulo/pull/5864#discussion_r2330848726


##########
test/src/main/java/org/apache/accumulo/test/conf/ResourceGroupConfigIT.java:
##########
@@ -207,4 +233,195 @@ private void checkProperty(InstanceOperations iops, 
ResourceGroupOperations ops,
     System.clearProperty(TServerClient.DEBUG_HOST);
   }
 
+  @Test
+  public void testDefaultResourceGroup() throws Exception {
+    try (var client = Accumulo.newClient().from(getClientProps()).build()) {
+      Set<ResourceGroupId> rgs = client.resourceGroupOperations().list();
+      assertEquals(1, rgs.size());
+      assertEquals(ResourceGroupId.DEFAULT, rgs.iterator().next());
+      client.resourceGroupOperations().create(ResourceGroupId.DEFAULT);
+      assertThrows(AccumuloException.class,
+          () -> 
client.resourceGroupOperations().remove(ResourceGroupId.DEFAULT));
+    }
+  }
+
+  @Test
+  public void testDuplicateCreatesRemovals()
+      throws AccumuloException, AccumuloSecurityException, 
ResourceGroupNotFoundException {
+    final var rgid = ResourceGroupId.of("DUPES");
+    try (var client = Accumulo.newClient().from(getClientProps()).build()) {
+      Set<ResourceGroupId> rgs = client.resourceGroupOperations().list();
+      assertEquals(1, rgs.size());
+      assertEquals(ResourceGroupId.DEFAULT, rgs.iterator().next());
+      client.resourceGroupOperations().create(rgid);
+      Set<ResourceGroupId> rgs2 = new 
HashSet<>(client.resourceGroupOperations().list());
+      assertEquals(2, rgs2.size());
+      assertTrue(rgs2.remove(ResourceGroupId.DEFAULT));
+      assertEquals(rgid, rgs2.iterator().next());
+      client.resourceGroupOperations().create(rgid); // creating again 
succeeds doing nothing
+      client.resourceGroupOperations().remove(rgid);
+      rgs = client.resourceGroupOperations().list();
+      assertEquals(1, rgs.size());
+      assertEquals(ResourceGroupId.DEFAULT, rgs.iterator().next());
+      assertThrows(ResourceGroupNotFoundException.class,
+          () -> client.resourceGroupOperations().remove(rgid));
+    }
+  }
+
+  @Test
+  public void testPermissions() throws Exception {
+
+    ClusterUser testUser = getUser(0);
+
+    String principal = testUser.getPrincipal();
+    AuthenticationToken token = testUser.getToken();
+    PasswordToken passwordToken = null;
+    if (token instanceof PasswordToken) {
+      passwordToken = (PasswordToken) token;
+    }
+
+    ResourceGroupId rgid = ResourceGroupId.of("TEST_GROUP");
+
+    try (var client = Accumulo.newClient().from(getClientProps()).build()) {
+      client.securityOperations().createLocalUser(principal, passwordToken);
+    }
+
+    try (AccumuloClient test_user_client =
+        Accumulo.newClient().from(getClientProps()).as(principal, 
token).build()) {
+      assertThrows(AccumuloSecurityException.class,
+          () -> test_user_client.resourceGroupOperations().create(rgid));
+    }
+
+    try (var client = Accumulo.newClient().from(getClientProps()).build()) {
+      client.resourceGroupOperations().create(rgid);
+    }
+
+    try (AccumuloClient test_user_client =
+        Accumulo.newClient().from(getClientProps()).as(principal, 
token).build()) {
+      assertThrows(AccumuloSecurityException.class,
+          () -> test_user_client.resourceGroupOperations().remove(rgid));
+    }
+
+    try (var client = Accumulo.newClient().from(getClientProps()).build()) {
+      client.securityOperations().grantSystemPermission(principal, 
SystemPermission.SYSTEM);
+    }
+
+    // Regular user with SYSTEM permission should now be able to create/remove
+    try (AccumuloClient test_user_client =
+        Accumulo.newClient().from(getClientProps()).as(principal, 
token).build()) {
+      test_user_client.resourceGroupOperations().remove(rgid);
+      test_user_client.resourceGroupOperations().create(rgid);
+    }
+  }
+
+  @Test
+  public void testMultipleConfigurations() throws Exception {
+
+    final String FIRST = "FIRST";
+    final String SECOND = "SECOND";
+    final String THIRD = "THIRD";
+
+    final ResourceGroupId first = ResourceGroupId.of(FIRST);
+    final ResourceGroupId second = ResourceGroupId.of(SECOND);
+    final ResourceGroupId third = ResourceGroupId.of(THIRD);
+
+    // @formatter:off
+    Map<String,String> firstProps = Map.of(
+        Property.COMPACTION_WARN_TIME.getKey(), "1m",
+        Property.SSERV_WAL_SORT_MAX_CONCURRENT.getKey(), "4",
+        Property.TSERV_ASSIGNMENT_MAXCONCURRENT.getKey(), "10");
+
+    Map<String,String> secondProps = Map.of(
+        Property.SSERV_WAL_SORT_MAX_CONCURRENT.getKey(), "5",
+        Property.TSERV_ASSIGNMENT_MAXCONCURRENT.getKey(), "10");
+
+    Map<String,String> thirdProps = Map.of(
+        Property.COMPACTION_WARN_TIME.getKey(), "1m",
+        Property.SSERV_WAL_SORT_MAX_CONCURRENT.getKey(), "6");
+    // @formatter:off
+
+    try (var client = Accumulo.newClient().from(getClientProps()).build()) {
+
+      // Set the SSERV_WAL_SORT_MAX_CONCURRENT property to 3. The default is 2
+      // and the resource groups will override to 4, 5, and 6. We should never
+      // see 2 or 3 when getting the running configurations from the processes.
+      
client.instanceOperations().setProperty(Property.SSERV_WAL_SORT_MAX_CONCURRENT.getKey(),
 "3");
+

Review Comment:
   Added in 3756f85



-- 
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