ivandika3 commented on PR #7700:
URL: https://github.com/apache/ozone/pull/7700#issuecomment-2601167047
> I started with some test with the following code. But It seem I cannot
delete the directory.
@sokui The parentDir should be "a/b/" with trailing slash. Because there was
no trailing slash your key is "a/b<key_name>", so only "a/" parent directory is
created. Therefore, deleting "a/b" will return KEY_NOT_FOUND
I created the following test, you can adapt it to your test.
```java
@Test
public void testAbortMultipartUploadSuccessWithMissingParentDirectories()
throws Exception {
String parentDir = "parentDirToDelete/";
keyName = parentDir + UUID.randomUUID();
OzoneManager ozoneManager = cluster.getOzoneManager();
String buckKey = ozoneManager.getMetadataManager()
.getBucketKey(volume.getName(), bucket.getName());
OmBucketInfo buckInfo =
ozoneManager.getMetadataManager().getBucketTable().get(buckKey);
BucketLayout bucketLayout = buckInfo.getBucketLayout();
ozClient.getProxy().createDirectory(volumeName, bucketName, parentDir);
String uploadID = initiateMultipartUpload(bucket, keyName, RATIS,
ONE);
Pair<String, String> partNameAndETag = uploadPart(bucket, keyName,
uploadID,
1, "data".getBytes(UTF_8));
OMMetadataManager metadataMgr =
cluster.getOzoneManager().getMetadataManager();
String multipartKey = verifyUploadedPart(uploadID,
partNameAndETag.getKey(),
metadataMgr);
// Delete parent directory
ozClient.getProxy().deleteKey(volumeName, bucketName, parentDir, false);
// Abort multipart upload with missing parent directory
bucket.abortMultipartUpload(keyName, uploadID);
String multipartOpenKey =
metadataMgr.getMultipartKeyFSO(volumeName, bucketName, keyName,
uploadID);
OmKeyInfo omKeyInfo =
metadataMgr.getOpenKeyTable(bucketLayout).get(multipartOpenKey);
OmMultipartKeyInfo omMultipartKeyInfo =
metadataMgr.getMultipartInfoTable().get(multipartKey);
assertNull(omKeyInfo);
assertNull(omMultipartKeyInfo);
}
```
--
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]