smengcl commented on code in PR #5167:
URL: https://github.com/apache/ozone/pull/5167#discussion_r1289542395
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestHSync.java:
##########
@@ -131,6 +146,47 @@ public static void teardown() {
}
}
+ @Test
+ public void testKeyHSyncThenClose() throws IOException {
+ // Check that deletedTable should not have keys with the same block as in
+ // keyTable's when a key is hsync()'ed then close()'d.
+
+ // Set the fs.defaultFS
+ 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 + bucket.getVolumeName()
+ + OZONE_URI_DELIMITER + bucket.getName();
+
+ String data = "random data";
+ final Path file = new Path(dir, "file-hsync-then-close");
+ try (FileSystem fs = FileSystem.get(CONF)) {
+ try (FSDataOutputStream outputStream = fs.create(file, true)) {
+ outputStream.write(data.getBytes(UTF_8), 0, data.length());
+ outputStream.hsync();
+ }
+ }
+
+ OMMetadataManager ommm = cluster.getOzoneManager().getMetadataManager();
+ // deletedTable should not have an entry for file at all in this case
+ try (TableIterator<String,
+ ? extends Table.KeyValue<String, RepeatedOmKeyInfo>>
+ tableIter = ommm.getDeletedTable().iterator()) {
+ while (tableIter.hasNext()) {
+ Table.KeyValue<String, RepeatedOmKeyInfo> kv = tableIter.next();
+ String key = kv.getKey();
+ if (key.startsWith(file.toString())) {
Review Comment:
I can't ensure if any other tests in the same test class doesn't trigger
actual block deletion since they share the same cluster. Thus, I am not
enforcing emptiness on the deletedTable
--
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]