bharatviswa504 commented on a change in pull request #1196:
URL: https://github.com/apache/hadoop-ozone/pull/1196#discussion_r454102604
##########
File path:
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/key/TestOMKeyCreateRequest.java
##########
@@ -328,6 +342,73 @@ private OMRequest createKeyRequest(boolean isMultipartKey,
int partNumber) {
.setCmdType(OzoneManagerProtocolProtos.Type.CreateKey)
.setClientId(UUID.randomUUID().toString())
.setCreateKeyRequest(createKeyRequest).build();
+ }
+
+ @Test
+ public void testKeyCreateWithIntermediateDir() throws Exception {
+
+ String keyName = "a/b/c/file1";
+ OMRequest omRequest = createKeyRequest(false, 0, keyName);
+
+ OzoneConfiguration configuration = new OzoneConfiguration();
+ configuration.setBoolean(OZONE_OM_CREATE_INTERMEDIATE_DIRECTORY, true);
+ when(ozoneManager.getConfiguration()).thenReturn(configuration);
+ OMKeyCreateRequest omKeyCreateRequest = new OMKeyCreateRequest(omRequest);
+
+ omRequest = omKeyCreateRequest.preExecute(ozoneManager);
+
+ omKeyCreateRequest = new OMKeyCreateRequest(omRequest);
+
+ // Add volume and bucket entries to DB.
+ addVolumeAndBucketToDB(volumeName, bucketName,
+ omMetadataManager);
+
+ OMClientResponse omClientResponse =
+ omKeyCreateRequest.validateAndUpdateCache(ozoneManager,
+ 100L, ozoneManagerDoubleBufferHelper);
+
+ Assert.assertEquals(omClientResponse.getOMResponse().getStatus(), OK);
+
+ Path keyPath = Paths.get(keyName);
+
+ // Check intermediate paths are created
+ keyPath = keyPath.getParent();
+ while(keyPath != null) {
+ Assert.assertNotNull(omMetadataManager.getKeyTable().get(
Review comment:
Added test
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]