This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 45aa6c1f1c HDDS-9464. Speed up TestStorageContainerManager (#5449)
45aa6c1f1c is described below
commit 45aa6c1f1c21be86c63f134d94e50a156068603e
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Wed Nov 1 06:29:22 2023 +0100
HDDS-9464. Speed up TestStorageContainerManager (#5449)
---
.../ozone/scm/TestStorageContainerManager.java | 117 ++++++++++-----------
1 file changed, 56 insertions(+), 61 deletions(-)
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestStorageContainerManager.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestStorageContainerManager.java
index d21f1db1cd..6916e8cfb8 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestStorageContainerManager.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestStorageContainerManager.java
@@ -77,7 +77,6 @@ import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.OzoneTestUtils;
import org.apache.hadoop.ozone.container.ContainerTestHelper;
-import org.apache.hadoop.ozone.container.common.SCMTestUtils;
import org.apache.hadoop.ozone.HddsDatanodeService;
import
org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine;
import
org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine;
@@ -138,6 +137,7 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.Predicate;
import java.util.stream.Stream;
import static
org.apache.hadoop.fs.CommonConfigurationKeysPublic.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY;
@@ -193,85 +193,80 @@ public class TestStorageContainerManager {
public void testRpcPermission() throws Exception {
// Test with default configuration
OzoneConfiguration defaultConf = new OzoneConfiguration();
- testRpcPermissionWithConf(defaultConf, "unknownUser", true);
+ testRpcPermissionWithConf(defaultConf, any -> false, "unknownUser");
// Test with ozone.administrators defined in configuration
+ String admins = "adminUser1, adminUser2";
OzoneConfiguration ozoneConf = new OzoneConfiguration();
- ozoneConf.setStrings(OzoneConfigKeys.OZONE_ADMINISTRATORS,
- "adminUser1, adminUser2");
+ ozoneConf.setStrings(OzoneConfigKeys.OZONE_ADMINISTRATORS, admins);
// Non-admin user will get permission denied.
- testRpcPermissionWithConf(ozoneConf, "unknownUser", true);
// Admin user will pass the permission check.
- testRpcPermissionWithConf(ozoneConf, "adminUser2", false);
+ testRpcPermissionWithConf(ozoneConf, admins::contains,
+ "unknownUser", "adminUser2");
}
private void testRpcPermissionWithConf(
- OzoneConfiguration ozoneConf, String fakeRemoteUsername,
- boolean expectPermissionDenied) throws Exception {
+ OzoneConfiguration ozoneConf,
+ Predicate<String> isAdmin,
+ String... usernames) throws Exception {
MiniOzoneCluster cluster = MiniOzoneCluster.newBuilder(ozoneConf).build();
- cluster.waitForClusterToBeReady();
try {
+ cluster.waitForClusterToBeReady();
+ for (String username : usernames) {
+ testRpcPermission(cluster, username,
+ !isAdmin.test(username));
+ }
+ } finally {
+ cluster.shutdown();
+ }
+ }
- SCMClientProtocolServer mockClientServer = Mockito.spy(
- cluster.getStorageContainerManager().getClientProtocolServer());
-
-
mockRemoteUser(UserGroupInformation.createRemoteUser(fakeRemoteUsername));
+ private void testRpcPermission(MiniOzoneCluster cluster,
+ String fakeRemoteUsername, boolean expectPermissionDenied) {
+ SCMClientProtocolServer mockClientServer = Mockito.spy(
+ cluster.getStorageContainerManager().getClientProtocolServer());
- try {
- mockClientServer.deleteContainer(
- ContainerTestHelper.getTestContainerID());
- fail("Operation should fail, expecting an IOException here.");
- } catch (Exception e) {
- if (expectPermissionDenied) {
- verifyPermissionDeniedException(e, fakeRemoteUsername);
- } else {
- // If passes permission check, it should fail with
- // container not exist exception.
- Assert.assertTrue(e instanceof ContainerNotFoundException);
- }
- }
+ mockRemoteUser(UserGroupInformation.createRemoteUser(fakeRemoteUsername));
- try {
- ContainerWithPipeline container2 = mockClientServer
- .allocateContainer(SCMTestUtils.getReplicationType(ozoneConf),
- HddsProtos.ReplicationFactor.ONE, OzoneConsts.OZONE);
- if (expectPermissionDenied) {
- fail("Operation should fail, expecting an IOException here.");
- } else {
- Assert.assertEquals(1, container2.getPipeline().getNodes().size());
- }
- } catch (Exception e) {
+ try {
+ mockClientServer.deleteContainer(
+ ContainerTestHelper.getTestContainerID());
+ fail("Operation should fail, expecting an IOException here.");
+ } catch (Exception e) {
+ if (expectPermissionDenied) {
verifyPermissionDeniedException(e, fakeRemoteUsername);
+ } else {
+ // If passes permission check, it should fail with
+ // container not exist exception.
+ Assert.assertTrue(e instanceof ContainerNotFoundException);
}
+ }
- try {
- ContainerWithPipeline container3 = mockClientServer
- .allocateContainer(SCMTestUtils.getReplicationType(ozoneConf),
- HddsProtos.ReplicationFactor.ONE, OzoneConsts.OZONE);
- if (expectPermissionDenied) {
- fail("Operation should fail, expecting an IOException here.");
- } else {
- Assert.assertEquals(1, container3.getPipeline().getNodes().size());
- }
- } catch (Exception e) {
- verifyPermissionDeniedException(e, fakeRemoteUsername);
+ try {
+ ContainerWithPipeline container2 = mockClientServer.allocateContainer(
+ HddsProtos.ReplicationType.RATIS,
+ HddsProtos.ReplicationFactor.ONE, OzoneConsts.OZONE);
+ if (expectPermissionDenied) {
+ fail("Operation should fail, expecting an IOException here.");
+ } else {
+ Assert.assertEquals(1, container2.getPipeline().getNodes().size());
}
+ } catch (Exception e) {
+ verifyPermissionDeniedException(e, fakeRemoteUsername);
+ }
- try {
- mockClientServer.getContainer(
- ContainerTestHelper.getTestContainerID());
- fail("Operation should fail, expecting an IOException here.");
- } catch (Exception e) {
- if (expectPermissionDenied) {
- verifyPermissionDeniedException(e, fakeRemoteUsername);
- } else {
- // If passes permission check, it should fail with
- // key not exist exception.
- Assert.assertTrue(e instanceof ContainerNotFoundException);
- }
+ try {
+ mockClientServer.getContainer(
+ ContainerTestHelper.getTestContainerID());
+ fail("Operation should fail, expecting an IOException here.");
+ } catch (Exception e) {
+ if (expectPermissionDenied) {
+ verifyPermissionDeniedException(e, fakeRemoteUsername);
+ } else {
+ // If passes permission check, it should fail with
+ // key not exist exception.
+ Assert.assertTrue(e instanceof ContainerNotFoundException);
}
- } finally {
- cluster.shutdown();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]