From c1e5b1921235316780dc439293b5fa1d3718ba3a Mon Sep 17 00:00:00 2001 From: Anu Engineer Date: Sat, 23 Feb 2019 20:56:24 -0800 Subject: [PATCH] HDDS-1147. Fix failing unit tests in TestOzoneManager. Contributed by Nandakumar. --- .../OzoneManagerProtocolClientSideTranslatorPB.java | 2 +- .../apache/hadoop/ozone/om/TestOzoneManager.java | 13 ++++++------- .../org/apache/hadoop/ozone/om/KeyManagerImpl.java | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java index 9e5be36b83..70d3d603d8 100644 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java +++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java @@ -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; diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManager.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManager.java index 446c855caf..03843bbc25 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManager.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManager.java @@ -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); }); } diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java index c6ee7a7bdb..25b335372e 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java @@ -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); }