rakeshadr commented on a change in pull request #2533:
URL: https://github.com/apache/ozone/pull/2533#discussion_r714668160



##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/utils/OzoneManagerRatisUtils.java
##########
@@ -437,4 +473,36 @@ private static ServiceException 
createLeaderNotReadyException(
     return new ServiceException(leaderNotReadyException);
   }
 
+  private static OmBucketInfo getOmBucketInfo(OzoneManager ozoneManager,
+      OmBucketInfo buckInfo, String volName, String buckName) {
+    String buckKey =
+        ozoneManager.getMetadataManager().getBucketKey(volName, buckName);
+    try {
+      buckInfo =
+          ozoneManager.getMetadataManager().getBucketTable().get(buckKey);
+    } catch (IOException e) {
+      e.printStackTrace();
+    }
+    return buckInfo;
+  }
+
+  private static BucketLayout getBucketLayout(OmBucketInfo buckInfo) {
+    if (buckInfo != null) {
+      return buckInfo.getBucketLayout();
+    } else {
+      buckInfo = null;
+      // TODO: Handle bucket validation

Review comment:
       @aryangupta1998 Please refer below unit test case and can use this kinda 
test to verify our code path. Since all the RPC key calls are invoked on 
bucket, a mock based unit test will work.
   ```
     @Test(timeout = 300_000)
     public void testRequestWithNonExistentBucket() throws Exception {
       ozoneManager = Mockito.mock(OzoneManager.class);
       ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS,
           folder.newFolder().getAbsolutePath());
       omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration);
       when(ozoneManager.getMetadataManager()).thenReturn(omMetadataManager);
   
       String volumeName = "vol1";
       String bucketName = "invalidBuck";
       OzoneManagerProtocolProtos.OMRequest omRequest =
           TestOMRequestUtils.createCompleteMPURequest(volumeName, bucketName,
               "mpuKey", "mpuKeyID", new ArrayList<>());
   
       OMClientRequest req = 
OzoneManagerRatisUtils.createClientRequest(omRequest, ozoneManager);
       Assert.assertNotNull(req);
       Assert.assertTrue("Unexpected request on invalid bucket", req instanceof 
S3MultipartUploadCompleteRequest);
     }
   ```




-- 
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]

Reply via email to