jojochuang commented on code in PR #6661:
URL: https://github.com/apache/ozone/pull/6661#discussion_r1596020104
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java:
##########
@@ -819,6 +819,134 @@ public void testAdminCmdListOpenFilesWithDeletedKeys()
}
}
+ @Test
+ public void testAdminCmdListOpenFilesWithOverwrittenKeys()
+ throws Exception {
+
+ OzoneConfiguration conf = cluster.getConf();
+ final String hostPrefix = OZONE_OFS_URI_SCHEME + "://" + omServiceId;
+
+ OzoneConfiguration clientConf = getClientConfForOFS(hostPrefix, conf);
+ clientConf.setBoolean(OZONE_FS_HSYNC_ENABLED, true);
+ FileSystem fs = FileSystem.get(clientConf);
+
+ assertNotEquals(fs.getConf().get(OZONE_FS_HSYNC_ENABLED),
+ "false", OZONE_FS_HSYNC_ENABLED + " is set to false " +
+ "by external force. Must be true to allow hsync to function");
+
+ final String volumeName = "volume-list-del";
+ final String bucketName = "buck1";
+
+ String dir1 = hostPrefix +
+ OM_KEY_PREFIX + volumeName +
+ OM_KEY_PREFIX + bucketName +
+ OM_KEY_PREFIX + "dir1";
+ // Create volume, bucket, dir
+ assertTrue(fs.mkdirs(new Path(dir1)));
+ String keyPrefix = OM_KEY_PREFIX + "key";
+
+ final int numKeys = 5;
+ String[] keys = new String[numKeys];
+
+ for (int i = 0; i < numKeys; i++) {
+ keys[i] = dir1 + keyPrefix + i;
+ }
+
+ String pathToBucket = "/" + volumeName + "/" + bucketName;
+ FSDataOutputStream[] streams = new FSDataOutputStream[numKeys];
+
+ try {
+ // Create multiple keys and hold them open
+ for (int i = 0; i < numKeys; i++) {
+ streams[i] = fs.create(new Path(keys[i]));
+ streams[i].write(1);
+ }
+
+ // Wait for DB flush
+ cluster.getOzoneManager().awaitDoubleBufferFlush();
+
+ // hsync last key
+ streams[numKeys - 1].hsync();
+ // Wait for flush
+ cluster.getOzoneManager().awaitDoubleBufferFlush();
+ final String[] args = new String[] {"om", "lof", "--service-id",
+ omServiceId, "--show-deleted", "--show-overwritten", "-p",
pathToBucket};
+
+ execute(ozoneAdminShell, args);
+ String cmdRes = getStdOut();
+
+ // Verify that key is hsync'ed
+ assertTrue(cmdRes.contains("\tYes\t\tNo\t\tNo"), "key should be hsync'ed
and not deleted, not overwritten");
+
+ execute(ozoneAdminShell, new String[] {"om", "lof", "--service-id",
+ omServiceId, "--show-overwritten", "-p", pathToBucket});
+ cmdRes = getStdOut();
+ // Verify that key is hsync'ed
+ assertTrue(cmdRes.contains("\tYes\t\tNo"), "key should be hsync'ed and
not overwritten");
+
+ // Verify json output
+ String[] args1 = new String[] {"om", "lof", "--service-id", omServiceId,
"--show-deleted", "--show-overwritten",
+ "--json", "-p", pathToBucket};
+ execute(ozoneAdminShell, args1);
+ cmdRes = getStdOut();
+
+ assertTrue(!cmdRes.contains(OzoneConsts.DELETED_HSYNC_KEY),
+ "key should not have deletedHsyncKey metadata");
+ assertTrue(!cmdRes.contains(OzoneConsts.OVERWRITTEN_HSYNC_KEY),
+ "key should not have overwrittenHsyncKey metadata");
+
+ // Suspend open key cleanup service so that key remains in openKeyTable
for verification
+ OpenKeyCleanupService openKeyCleanupService =
+ (OpenKeyCleanupService)
cluster.getOzoneManager().getKeyManager().getOpenKeyCleanupService();
+ openKeyCleanupService.suspend();
+ OzoneFsShell shell = new OzoneFsShell(clientConf);
Review Comment:
dead code.
--
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]