sravani-revuri commented on code in PR #11368:
URL: https://github.com/apache/ozone/pull/11368#discussion_r4196163255
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestBucketManagerImpl.java:
##########
@@ -660,6 +662,60 @@ private static void denySourceRead(OmMetadataReader
metadataReader, String sourc
}).when(metadataReader).checkAcls(any(), any(), any(), any(), any(),
any());
}
+ @Test
+ void testResolveBucketLinkMissingSourceVolume() throws Exception {
+ String targetVolume = volumeName();
+ String missingSourceVolume = volumeName();
+ OmBucketInfo danglingLink = OmBucketInfo.newBuilder()
+ .setVolumeName(targetVolume)
+ .setBucketName("dangling-link")
+ .setSourceVolume(missingSourceVolume)
+ .setSourceBucket("any-bucket")
+ .build();
+ BucketManager bucketManager = mock(BucketManager.class);
+ when(bucketManager.getBucketInfo(targetVolume,
"dangling-link")).thenReturn(danglingLink);
+ when(bucketManager.getBucketInfo(missingSourceVolume, "any-bucket"))
+ .thenThrow(new OMException("Volume doesn't exist",
ResultCodes.VOLUME_NOT_FOUND));
+ OzoneManager omSpy = spy(omTestManagers.getOzoneManager());
+ HddsWhiteboxTestUtils.setInternalState(omSpy, "bucketManager",
bucketManager);
+ when(omSpy.getAclsEnabled()).thenReturn(false);
+
+ OMException omEx = assertThrows(OMException.class,
+ () -> omSpy.resolveBucketLink(Pair.of(targetVolume, "dangling-link")));
+ assertEquals(ResultCodes.BUCKET_NOT_FOUND, omEx.getResult());
+ assertThat(omEx.getMessage()).contains("Cannot follow bucket link");
+ }
+
+ @Test
+ void testListKeysOnLinkWithMissingSourceVolume() throws Exception {
+ String targetVolume = volumeName();
+ String missingSourceVolume = volumeName();
+ OmBucketInfo danglingLink = OmBucketInfo.newBuilder()
+ .setVolumeName(targetVolume)
+ .setBucketName("dangling-link-list")
+ .setSourceVolume(missingSourceVolume)
+ .setSourceBucket("any-bucket")
+ .build();
+ BucketManager bucketManager = mock(BucketManager.class);
+ when(bucketManager.getBucketInfo(targetVolume,
"dangling-link-list")).thenReturn(danglingLink);
+ when(bucketManager.getBucketInfo(missingSourceVolume, "any-bucket"))
+ .thenThrow(new OMException("Volume doesn't exist",
ResultCodes.VOLUME_NOT_FOUND));
+ OzoneManager om = omTestManagers.getOzoneManager();
+ OzoneManager omSpy = spy(om);
+ HddsWhiteboxTestUtils.setInternalState(omSpy, "bucketManager",
bucketManager);
+ when(omSpy.getAclsEnabled()).thenReturn(false);
+ OmMetadataReader metadataReader = (OmMetadataReader)
HddsWhiteboxTestUtils.getInternalState(om,
+ "omMetadataReader");
+ HddsWhiteboxTestUtils.setInternalState(metadataReader, "ozoneManager",
omSpy);
+
+ OMException omEx = assertThrows(OMException.class,
+ () -> omSpy.listKeys(targetVolume, "dangling-link-list", null, null,
100));
+ assertEquals(ResultCodes.BUCKET_NOT_FOUND, omEx.getResult());
+ assertThat(omEx.getMessage()).contains("Cannot follow bucket link");
+ verify(bucketManager).getBucketInfo(eq(targetVolume),
eq("dangling-link-list"));
+ verify(bucketManager).getBucketInfo(eq(missingSourceVolume),
eq("any-bucket"));
+ }
+
Review Comment:
can we add a unit test where the underlying failure is to throw
BUCKET_NOT_FOUND instead of VOLUME_NOT_FOUND. The catch remaps both codes when
visited is non-empty, unit tests only cover the volume-not-found path today.
##########
hadoop-ozone/dist/src/main/smoketest/basic/links.robot:
##########
@@ -94,6 +94,14 @@ Link to non-existent bucket
${result} = Execute And Ignore Error ozone sh key list
${target}/dangling-link
Should Contain ${result}
BUCKET_NOT_FOUND
Review Comment:
nit: can we check the error message "Cannot follow bucket link" here also
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]