Search in sources :

Example 1 with OzoneManagerProtocolPB

use of org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolPB in project ozone by apache.

the class TestOMFailovers method testAccessContorlExceptionFailovers.

@Test
public void testAccessContorlExceptionFailovers() throws Exception {
    testException = new AccessControlException();
    GenericTestUtils.setLogLevel(OMFailoverProxyProvider.LOG, Level.DEBUG);
    GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer.captureLogs(OMFailoverProxyProvider.LOG);
    MockFailoverProxyProvider failoverProxyProvider = new MockFailoverProxyProvider(conf);
    OzoneManagerProtocolPB proxy = (OzoneManagerProtocolPB) RetryProxy.create(OzoneManagerProtocolPB.class, failoverProxyProvider, failoverProxyProvider.getRetryPolicy(OzoneConfigKeys.OZONE_CLIENT_FAILOVER_MAX_ATTEMPTS_DEFAULT));
    try {
        proxy.submitRequest(null, null);
        Assert.fail("Request should fail with AccessControlException");
    } catch (Exception ex) {
        Assert.assertTrue(ex instanceof ServiceException);
        // Request should try all OMs one be one and fail when the last OM also
        // throws AccessControlException.
        GenericTestUtils.assertExceptionContains("ServiceException of " + "type class org.apache.hadoop.security.AccessControlException for " + "om3", ex);
        Assert.assertTrue(ex.getCause() instanceof AccessControlException);
        Assert.assertTrue(logCapturer.getOutput().contains(getRetryProxyDebugMsg("om1")));
        Assert.assertTrue(logCapturer.getOutput().contains(getRetryProxyDebugMsg("om2")));
        Assert.assertTrue(logCapturer.getOutput().contains(getRetryProxyDebugMsg("om3")));
    }
}
Also used : ServiceException(com.google.protobuf.ServiceException) AccessControlException(org.apache.hadoop.security.AccessControlException) GenericTestUtils(org.apache.ozone.test.GenericTestUtils) OzoneManagerProtocolPB(org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolPB) ServiceException(com.google.protobuf.ServiceException) IOException(java.io.IOException) AccessControlException(org.apache.hadoop.security.AccessControlException) Test(org.junit.Test)

Aggregations

ServiceException (com.google.protobuf.ServiceException)1 IOException (java.io.IOException)1 OzoneManagerProtocolPB (org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolPB)1 AccessControlException (org.apache.hadoop.security.AccessControlException)1 GenericTestUtils (org.apache.ozone.test.GenericTestUtils)1 Test (org.junit.Test)1