HDDS-1147. Fix failing unit tests in TestOzoneManager.

Contributed by Nandakumar.
This commit is contained in:
Anu Engineer 2019-02-23 20:56:24 -08:00
parent fb546d1807
commit c1e5b19212
3 changed files with 8 additions and 9 deletions

View File

@ -292,7 +292,7 @@ public boolean checkVolumeAccess(String volume, OzoneAclInfo userAcl) throws
.setCheckVolumeAccessRequest(req)
.build();
OMResponse omResponse = handleError(submitRequest(omRequest));
OMResponse omResponse = submitRequest(omRequest);
if (omResponse.getStatus() == ACCESS_DENIED) {
return false;

View File

@ -343,7 +343,6 @@ public void testFailedDeleteVolume() throws IOException, OzoneException {
// Create a volume and test Volume access for a different user
@Test
@Ignore("TODO:HDDS-1147")
public void testAccessVolume() throws IOException, OzoneException {
String userName = "user" + RandomStringUtils.randomNumeric(5);
String adminName = "admin" + RandomStringUtils.randomNumeric(5);
@ -674,7 +673,6 @@ public void testDeleteKey() throws Exception {
* @throws OzoneException
*/
@Test
@Ignore("TODO:HDDS-1147")
public void testRenameKey() throws IOException, OzoneException {
String userName = "user" + RandomStringUtils.randomNumeric(5);
String adminName = "admin" + RandomStringUtils.randomNumeric(5);
@ -752,7 +750,8 @@ public void testRenameKey() throws IOException, OzoneException {
testRenameFails++;
omException = e;
}
Assert.assertEquals(ResultCodes.KEY_RENAME_ERROR, omException);
Assert.assertEquals(ResultCodes.KEY_ALREADY_EXISTS,
omException.getResult());
// Rename to empty string should fail
toKeyName = "";
@ -763,7 +762,7 @@ public void testRenameKey() throws IOException, OzoneException {
testRenameFails++;
omException = e;
}
Assert.assertEquals(ResultCodes.KEY_RENAME_ERROR, omException);
Assert.assertEquals(ResultCodes.INVALID_KEY_NAME, omException.getResult());
// Rename from empty string should fail
keyArgs = new KeyArgs("", bucketArgs);
@ -775,7 +774,7 @@ public void testRenameKey() throws IOException, OzoneException {
testRenameFails++;
omException = e;
}
Assert.assertEquals(ResultCodes.KEY_RENAME_ERROR, omException);
Assert.assertEquals(ResultCodes.INVALID_KEY_NAME, omException.getResult());
Assert.assertEquals(numKeyRenames + testRenames,
omMetrics.getNumKeyRenames());
@ -1309,7 +1308,6 @@ public void testOmInitialization() throws IOException {
* @throws IOException
*/
@Test
@Ignore("TODO:HDDS-1147")
public void testOmInitializationFailure() throws Exception {
OzoneConfiguration config = new OzoneConfiguration();
final String path =
@ -1317,6 +1315,7 @@ public void testOmInitializationFailure() throws Exception {
Path metaDirPath = Paths.get(path, "om-meta");
config.set(HddsConfigKeys.OZONE_METADATA_DIRS, metaDirPath.toString());
config.setBoolean(OzoneConfigKeys.OZONE_ENABLED, true);
config.set(OZONE_OM_ADDRESS_KEY, "127.0.0.1:0");
config.set(ScmConfigKeys.OZONE_SCM_CLIENT_ADDRESS_KEY, "127.0.0.1:0");
config.set(ScmConfigKeys.OZONE_SCM_BLOCK_CLIENT_ADDRESS_KEY,
conf.get(ScmConfigKeys.OZONE_SCM_BLOCK_CLIENT_ADDRESS_KEY));
@ -1332,7 +1331,7 @@ public void testOmInitializationFailure() throws Exception {
omStore.setScmId("testScmId");
// writes the version file properties
omStore.initialize();
OzoneManager.createOm(null, conf);
OzoneManager.createOm(null, config);
});
}

View File

@ -634,7 +634,7 @@ public void renameKey(OmKeyArgs args, String toKeyName) throws IOException {
"Rename key failed for volume:{} bucket:{} fromKey:{} toKey:{}. "
+ "Key: {} already exists.", volumeName, bucketName,
fromKeyName, toKeyName, toKeyName);
throw new OMException("Key not found",
throw new OMException("Key already exists",
OMException.ResultCodes.KEY_ALREADY_EXISTS);
}