use of org.apache.hadoop.ozone.om.helpers.OmBucketInfo in project ozone by apache.
the class TestBucketManagerImpl method testDeleteNonEmptyBucket.
@Test
@Ignore("Bucket Manager does not use cache, Disable it for now.")
public void testDeleteNonEmptyBucket() throws Exception {
thrown.expectMessage("Bucket is not empty");
OmMetadataManagerImpl metaMgr = createSampleVol();
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
OmBucketInfo bucketInfo = OmBucketInfo.newBuilder().setVolumeName("sampleVol").setBucketName("bucketOne").build();
bucketManager.createBucket(bucketInfo);
// Create keys in bucket
metaMgr.getKeyTable(getBucketLayout()).put("/sampleVol/bucketOne/key_one", new OmKeyInfo.Builder().setBucketName("bucketOne").setVolumeName("sampleVol").setKeyName("key_one").setReplicationConfig(StandaloneReplicationConfig.getInstance(ReplicationFactor.ONE)).build());
metaMgr.getKeyTable(getBucketLayout()).put("/sampleVol/bucketOne/key_two", new OmKeyInfo.Builder().setBucketName("bucketOne").setVolumeName("sampleVol").setKeyName("key_two").setReplicationConfig(StandaloneReplicationConfig.getInstance(ReplicationFactor.ONE)).build());
try {
bucketManager.deleteBucket("sampleVol", "bucketOne");
} catch (OMException omEx) {
Assert.assertEquals(ResultCodes.BUCKET_NOT_EMPTY, omEx.getResult());
throw omEx;
}
metaMgr.getStore().close();
}
use of org.apache.hadoop.ozone.om.helpers.OmBucketInfo in project ozone by apache.
the class TestBucketManagerImpl method testCreateBucket.
@Test
@Ignore("Bucket Manager does not use cache, Disable it for now.")
public void testCreateBucket() throws Exception {
OmMetadataManagerImpl metaMgr = createSampleVol();
KeyProviderCryptoExtension kmsProvider = Mockito.mock(KeyProviderCryptoExtension.class);
String testBekName = "key1";
String testCipherName = "AES/CTR/NoPadding";
KeyProvider.Metadata mockMetadata = Mockito.mock(KeyProvider.Metadata.class);
Mockito.when(kmsProvider.getMetadata(testBekName)).thenReturn(mockMetadata);
Mockito.when(mockMetadata.getCipher()).thenReturn(testCipherName);
BucketManager bucketManager = new BucketManagerImpl(metaMgr, kmsProvider);
OmBucketInfo bucketInfo = OmBucketInfo.newBuilder().setVolumeName("sampleVol").setBucketName("bucketOne").setBucketEncryptionKey(new BucketEncryptionKeyInfo.Builder().setKeyName("key1").build()).build();
bucketManager.createBucket(bucketInfo);
Assert.assertNotNull(bucketManager.getBucketInfo("sampleVol", "bucketOne"));
OmBucketInfo bucketInfoRead = bucketManager.getBucketInfo("sampleVol", "bucketOne");
Assert.assertTrue(bucketInfoRead.getEncryptionKeyInfo().getKeyName().equals(bucketInfo.getEncryptionKeyInfo().getKeyName()));
metaMgr.getStore().close();
}
use of org.apache.hadoop.ozone.om.helpers.OmBucketInfo in project ozone by apache.
the class TestBucketManagerImpl method testGetBucketInfo.
@Test
public void testGetBucketInfo() throws Exception {
final String volumeName = "sampleVol";
final String bucketName = "bucketOne";
OmMetadataManagerImpl metaMgr = createSampleVol();
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
// Check exception thrown when volume does not exist
try {
bucketManager.getBucketInfo(volumeName, bucketName);
Assert.fail("Should have thrown OMException");
} catch (OMException omEx) {
Assert.assertEquals("getBucketInfo() should have thrown " + "VOLUME_NOT_FOUND as the parent volume is not created!", ResultCodes.VOLUME_NOT_FOUND, omEx.getResult());
}
OmBucketInfo bucketInfo = OmBucketInfo.newBuilder().setVolumeName(volumeName).setBucketName(bucketName).setStorageType(StorageType.DISK).setIsVersionEnabled(false).build();
// Note: the helper method createBucket() in this scope won't create the
// parent volume DB entry. In order to verify getBucketInfo's behavior, we
// need to create the volume entry in DB manually.
OmVolumeArgs args = OmVolumeArgs.newBuilder().setVolume(volumeName).setAdminName("bilbo").setOwnerName("bilbo").build();
OMRequestTestUtils.addVolumeToOM(metaMgr, args);
// Create bucket
createBucket(metaMgr, bucketInfo);
// Check exception thrown when bucket does not exist
try {
bucketManager.getBucketInfo(volumeName, "bucketNotExist");
Assert.fail("Should have thrown OMException");
} catch (OMException omEx) {
Assert.assertEquals("getBucketInfo() should have thrown " + "BUCKET_NOT_FOUND as the parent volume exists but bucket " + "doesn't!", ResultCodes.BUCKET_NOT_FOUND, omEx.getResult());
}
OmBucketInfo result = bucketManager.getBucketInfo(volumeName, bucketName);
Assert.assertEquals(volumeName, result.getVolumeName());
Assert.assertEquals(bucketName, result.getBucketName());
Assert.assertEquals(StorageType.DISK, result.getStorageType());
Assert.assertFalse(result.getIsVersionEnabled());
metaMgr.getStore().close();
}
use of org.apache.hadoop.ozone.om.helpers.OmBucketInfo in project ozone by apache.
the class TestBucketManagerImpl method testSetBucketPropertyChangeStorageType.
@Test
@Ignore("Bucket Manager does not use cache, Disable it for now.")
public void testSetBucketPropertyChangeStorageType() throws Exception {
OmMetadataManagerImpl metaMgr = createSampleVol();
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
OmBucketInfo bucketInfo = OmBucketInfo.newBuilder().setVolumeName("sampleVol").setBucketName("bucketOne").setStorageType(StorageType.DISK).build();
createBucket(metaMgr, bucketInfo);
OmBucketInfo result = bucketManager.getBucketInfo("sampleVol", "bucketOne");
Assert.assertEquals(StorageType.DISK, result.getStorageType());
OmBucketArgs bucketArgs = OmBucketArgs.newBuilder().setVolumeName("sampleVol").setBucketName("bucketOne").setStorageType(StorageType.SSD).build();
bucketManager.setBucketProperty(bucketArgs);
OmBucketInfo updatedResult = bucketManager.getBucketInfo("sampleVol", "bucketOne");
Assert.assertEquals(StorageType.SSD, updatedResult.getStorageType());
metaMgr.getStore().close();
}
use of org.apache.hadoop.ozone.om.helpers.OmBucketInfo in project ozone by apache.
the class TestBucketManagerImpl method testCreateAlreadyExistingBucket.
@Test
@Ignore("Bucket Manager does not use cache, Disable it for now.")
public void testCreateAlreadyExistingBucket() throws Exception {
thrown.expectMessage("Bucket already exist");
OmMetadataManagerImpl metaMgr = createSampleVol();
try {
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
OmBucketInfo bucketInfo = OmBucketInfo.newBuilder().setVolumeName("sampleVol").setBucketName("bucketOne").build();
bucketManager.createBucket(bucketInfo);
bucketManager.createBucket(bucketInfo);
} catch (OMException omEx) {
Assert.assertEquals(ResultCodes.BUCKET_ALREADY_EXISTS, omEx.getResult());
throw omEx;
} finally {
metaMgr.getStore().close();
}
}
Aggregations