smengcl commented on a change in pull request #584: HDDS-3054.
OzoneFileStatus#getModificationTime should return actual directory modification
time when its OmKeyInfo is available
URL: https://github.com/apache/hadoop-ozone/pull/584#discussion_r384707165
##########
File path:
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java
##########
@@ -354,4 +356,45 @@ private OzoneKeyDetails getKey(Path keyPath, boolean
isDirectory)
private void assertKeyNotFoundException(IOException ex) {
GenericTestUtils.assertExceptionContains("KEY_NOT_FOUND", ex);
}
+
+ private void testGetDirectoryModificationTime() throws IOException {
+ Path mdir1 = new Path("/mdir1");
+ Path mdir11 = new Path(mdir1, "mdir11");
+ Path mdir111 = new Path(mdir11, "mdir111");
+ fs.mkdirs(mdir111);
+ rootItemCount++; // mdir1
+
+ // Case 1: Dir key exist on server
+ FileStatus[] fileStatuses = o3fs.listStatus(mdir11);
+ // Above listStatus result should only have one entry: mdir111
+ assertEquals(1, fileStatuses.length);
+ assertEquals(mdir111.toString(),
+ fileStatuses[0].getPath().toUri().getPath());
+ assertTrue(fileStatuses[0].isDirectory());
+ // The dir key is actually created on server,
+ // so modification time should always be the same value.
+ long modificationTime = fileStatuses[0].getModificationTime();
+ // Check modification time in a small loop, it should always be the same
+ for (int i = 0; i < 5; i++) {
+ fileStatuses = o3fs.listStatus(mdir11);
+ assertEquals(modificationTime, fileStatuses[0].getModificationTime());
+ }
+
+ // Case 2: Dir key doesn't exist on server
+ fileStatuses = o3fs.listStatus(mdir1);
+ // Above listStatus result should only have one entry: mdir11
+ assertEquals(1, fileStatuses.length);
+ assertEquals(mdir11.toString(),
+ fileStatuses[0].getPath().toUri().getPath());
+ assertTrue(fileStatuses[0].isDirectory());
+ // Since the dir key doesn't exist on server, the modification time is
+ // set to current time upon every listStatus request.
+ modificationTime = fileStatuses[0].getModificationTime();
+ // Check modification time in a small loop, it should be slightly larger
+ // each time
+ for (int i = 0; i < 5; i++) {
+ fileStatuses = o3fs.listStatus(mdir1);
+ assertTrue(modificationTime <= fileStatuses[0].getModificationTime());
Review comment:
Checkstyle complains the listStatus exceeded 150 LOC and I have to make
space for my change
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]