Search in sources :

Example 6 with MiniOzoneCluster

use of org.apache.hadoop.ozone.MiniOzoneCluster in project ozone by apache.

the class TestOzoneContainer method testOzoneContainerViaDataNode.

@Test
public void testOzoneContainerViaDataNode() throws Exception {
    MiniOzoneCluster cluster = null;
    try {
        long containerID = ContainerTestHelper.getTestContainerID();
        OzoneConfiguration conf = newOzoneConfiguration();
        // Start ozone container Via Datanode create.
        cluster = MiniOzoneCluster.newBuilder(conf).setNumDatanodes(1).build();
        cluster.waitForClusterToBeReady();
        // This client talks to ozone container via datanode.
        XceiverClientGrpc client = createClientForTesting(cluster);
        runTestOzoneContainerViaDataNode(containerID, client);
    } finally {
        if (cluster != null) {
            cluster.shutdown();
        }
    }
}
Also used : MiniOzoneCluster(org.apache.hadoop.ozone.MiniOzoneCluster) XceiverClientGrpc(org.apache.hadoop.hdds.scm.XceiverClientGrpc) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Test(org.junit.jupiter.api.Test)

Example 7 with MiniOzoneCluster

use of org.apache.hadoop.ozone.MiniOzoneCluster in project ozone by apache.

the class TestOzoneClientFactory method testRemoteException.

@Test
public void testRemoteException() {
    OzoneConfiguration conf = new OzoneConfiguration();
    try {
        MiniOzoneCluster cluster = MiniOzoneCluster.newBuilder(conf).setNumDatanodes(3).setTotalPipelineNumLimit(10).setScmId(scmId).setClusterId(clusterId).build();
        String omPort = cluster.getOzoneManager().getRpcPort();
        UserGroupInformation realUser = UserGroupInformation.createRemoteUser("realUser");
        UserGroupInformation proxyUser = UserGroupInformation.createProxyUser("user", realUser);
        proxyUser.doAs(new PrivilegedExceptionAction<Void>() {

            @Override
            public Void run() throws IOException {
                conf.set("ozone.security.enabled", "true");
                OzoneClient ozoneClient = OzoneClientFactory.getRpcClient("localhost", Integer.parseInt(omPort), conf);
                ozoneClient.getObjectStore().listVolumes("/");
                return null;
            }
        });
        Assert.fail("Should throw exception here");
    } catch (IOException | InterruptedException e) {
        assert e instanceof AccessControlException;
    }
}
Also used : MiniOzoneCluster(org.apache.hadoop.ozone.MiniOzoneCluster) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) AccessControlException(org.apache.hadoop.security.AccessControlException) IOException(java.io.IOException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Test(org.junit.Test)

Aggregations

OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)7 MiniOzoneCluster (org.apache.hadoop.ozone.MiniOzoneCluster)7 XceiverClientGrpc (org.apache.hadoop.hdds.scm.XceiverClientGrpc)5 Test (org.junit.jupiter.api.Test)5 ContainerProtos (org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos)2 IOException (java.io.IOException)1 AccessControlException (org.apache.hadoop.security.AccessControlException)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 Test (org.junit.Test)1