Search in sources :

Example 1 with TenantOp

use of org.apache.hadoop.ozone.om.TenantOp in project ozone by apache.

the class TestS3GetSecretRequest method setUp.

@Before
public void setUp() throws Exception {
    KerberosName.setRuleMechanism(DEFAULT_MECHANISM);
    KerberosName.setRules("RULE:[2:$1@$0](.*@EXAMPLE.COM)s/@.*//\n" + "RULE:[1:$1@$0](.*@EXAMPLE.COM)s/@.*//\n" + "DEFAULT");
    ugiAlice = UserGroupInformation.createRemoteUser(USER_ALICE);
    Assert.assertEquals("alice", ugiAlice.getShortUserName());
    ozoneManager = mock(OzoneManager.class);
    Call call = spy(new Call(1, 1, null, null, RPC.RpcKind.RPC_BUILTIN, new byte[] { 1, 2, 3 }));
    // Run as alice, so that Server.getRemoteUser() won't return null.
    when(call.getRemoteUser()).thenReturn(ugiAlice);
    Server.getCurCall().set(call);
    omMetrics = OMMetrics.create();
    OzoneConfiguration conf = new OzoneConfiguration();
    conf.set(OMConfigKeys.OZONE_OM_DB_DIRS, folder.newFolder().getAbsolutePath());
    // No need to conf.set(OzoneConfigKeys.OZONE_ADMINISTRATORS, ...) here
    // as we did the trick earlier with mockito.
    omMetadataManager = new OmMetadataManagerImpl(conf);
    when(ozoneManager.getMetrics()).thenReturn(omMetrics);
    when(ozoneManager.getMetadataManager()).thenReturn(omMetadataManager);
    when(ozoneManager.isRatisEnabled()).thenReturn(true);
    auditLogger = mock(AuditLogger.class);
    when(ozoneManager.getAuditLogger()).thenReturn(auditLogger);
    doNothing().when(auditLogger).logWrite(any(AuditMessage.class));
    // Multi-tenant related initializations
    omMultiTenantManager = mock(OMMultiTenantManager.class);
    tenant = mock(Tenant.class);
    when(ozoneManager.getMultiTenantManager()).thenReturn(omMultiTenantManager);
    when(tenant.getTenantAccessPolicies()).thenReturn(new ArrayList<>());
    when(omMultiTenantManager.getAuthorizerLock()).thenReturn(new AuthorizerLockImpl());
    TenantOp authorizerOp = mock(TenantOp.class);
    TenantOp cacheOp = mock(TenantOp.class);
    when(omMultiTenantManager.getAuthorizerOp()).thenReturn(authorizerOp);
    when(omMultiTenantManager.getCacheOp()).thenReturn(cacheOp);
}
Also used : OmMetadataManagerImpl(org.apache.hadoop.ozone.om.OmMetadataManagerImpl) Call(org.apache.hadoop.ipc.Server.Call) AuditMessage(org.apache.hadoop.ozone.audit.AuditMessage) AuditLogger(org.apache.hadoop.ozone.audit.AuditLogger) Tenant(org.apache.hadoop.ozone.om.multitenant.Tenant) OzoneManager(org.apache.hadoop.ozone.om.OzoneManager) OMMultiTenantManager(org.apache.hadoop.ozone.om.OMMultiTenantManager) AuthorizerLockImpl(org.apache.hadoop.ozone.om.multitenant.AuthorizerLockImpl) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) TenantOp(org.apache.hadoop.ozone.om.TenantOp) Before(org.junit.Before)

Aggregations

OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)1 Call (org.apache.hadoop.ipc.Server.Call)1 AuditLogger (org.apache.hadoop.ozone.audit.AuditLogger)1 AuditMessage (org.apache.hadoop.ozone.audit.AuditMessage)1 OMMultiTenantManager (org.apache.hadoop.ozone.om.OMMultiTenantManager)1 OmMetadataManagerImpl (org.apache.hadoop.ozone.om.OmMetadataManagerImpl)1 OzoneManager (org.apache.hadoop.ozone.om.OzoneManager)1 TenantOp (org.apache.hadoop.ozone.om.TenantOp)1 AuthorizerLockImpl (org.apache.hadoop.ozone.om.multitenant.AuthorizerLockImpl)1 Tenant (org.apache.hadoop.ozone.om.multitenant.Tenant)1 Before (org.junit.Before)1