peterxcli commented on code in PR #7792:
URL: https://github.com/apache/ozone/pull/7792#discussion_r1946734979
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestHSync.java:
##########
@@ -583,6 +583,49 @@ public void testHSyncDeletedKey() throws Exception {
}
}
+ static Stream<BucketLayout> bucketLayouts() {
+ return Stream.of(BucketLayout.FILE_SYSTEM_OPTIMIZED, BucketLayout.LEGACY);
+ }
+
+ @ParameterizedTest
+ @MethodSource("bucketLayouts")
+ public void testBatchKeyDeletionWithHSync(BucketLayout bucketLayout) throws
Exception {
+ // Create a bucket with the specified layout
+ OzoneBucket testBucket = TestDataUtil.createVolumeAndBucket(client,
bucketLayout);
+
+ final String rootPath = String.format("%s://%s/",
+ OZONE_OFS_URI_SCHEME, CONF.get(OZONE_OM_ADDRESS_KEY));
+ CONF.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, rootPath);
+
+ final String dir = OZONE_ROOT + testBucket.getVolumeName()
+ + OZONE_URI_DELIMITER + testBucket.getName();
+
+ // Create multiple files, some with hsync
+ final int numFiles = 5;
+ List<String> openKeys = new ArrayList<>();
+
+ try (FileSystem fs = FileSystem.get(CONF)) {
+ for (int i = 0; i < numFiles; i++) {
+ String keyName = "batch-key-" + i;
+ Path file = new Path(dir, keyName);
+ try (FSDataOutputStream os = fs.create(file, true)) {
+ os.write(1);
+ os.hsync();
+ openKeys.add(keyName);
+ }
Review Comment:
@jojochuang Thanks for the reminder.
I update the test to not use `try with resources pattern`, and it failed to
receive the exception from the second hsync operation after the keys are
deleted. I'm still investigating whether the root cause is my incorrect test or
an issue in https://github.com/apache/ozone/pull/6472
```java
@ParameterizedTest
@MethodSource("bucketLayouts")
public void testBatchKeyDeletionWithHSync(BucketLayout bucketLayout) throws
Exception {
// Create a bucket with the specified layout
OzoneBucket testBucket = TestDataUtil.createVolumeAndBucket(client,
bucketLayout);
final String rootPath = String.format("%s://%s/",
OZONE_OFS_URI_SCHEME, CONF.get(OZONE_OM_ADDRESS_KEY));
CONF.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, rootPath);
final String dir = OZONE_ROOT + testBucket.getVolumeName()
+ OZONE_URI_DELIMITER + testBucket.getName();
// Create multiple files, some with hsync
final int numFiles = 5;
List<String> openKeys = new ArrayList<>();
List<FSDataOutputStream> openKeysOS = new ArrayList<>();
try (FileSystem fs = FileSystem.get(CONF)) {
for (int i = 0; i < numFiles; i++) {
String keyName = "batch-key-" + i;
Path file = new Path(dir, keyName);
FSDataOutputStream os = fs.create(file, true);
os.write(1);
os.hsync();
openKeys.add(keyName);
openKeysOS.add(os);
}
client.getObjectStore().getVolume(testBucket.getVolumeName())
.getBucket(testBucket.getName())
.deleteKeys(openKeys);
for (FSDataOutputStream os : openKeysOS) {
// test if the os is not closed at client side
OMException exception = assertThrows(OMException.class,
() -> os.hsync());
assertEquals(OMException.ResultCodes.KEY_NOT_FOUND,
exception.getResult());
// os.close() throws OMException because the key is deleted
exception = assertThrows(OMException.class,
() -> os.close());
assertEquals(OMException.ResultCodes.KEY_NOT_FOUND,
exception.getResult());
}
}
}
--
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]