ayushtkn commented on code in PR #5809:
URL: https://github.com/apache/hadoop/pull/5809#discussion_r1261357967
##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDirectoryScanner.java:
##########
@@ -1304,6 +1305,23 @@ public void testLocalReplicaUpdateWithReplica() throws
Exception {
assertEquals(realBlkFile, localReplica.getBlockFile());
}
+ @Test(timeout = 60000)
+ public void testLastDirScannerFinishTimeIsUpdated() throws Exception {
+ Configuration conf = getConfiguration();
+ conf.setLong(DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_INTERVAL_KEY, 3L);
+ cluster = new MiniDFSCluster.Builder(conf).build();
+ try {
+ cluster.waitActive();
+ bpid = cluster.getNamesystem().getBlockPoolId();
+ fds = DataNodeTestUtils.getFSDataset(cluster.getDataNodes().get(0));
+ assertEquals(fds.getLastDirScannerFinishTime(), 0L);
+ Thread.sleep(4000);
+ assertNotEquals(0L, fds.getLastDirScannerFinishTime());
+ } finally {
+ cluster.shutdown();
+ }
+ }
+
Review Comment:
can we rather than doing this sleep thing, have a test like this
```
@Test(timeout = 60000)
public void testLastDirScannerFinishTimeIsUpdated() throws Exception {
Configuration conf = getConfiguration();
cluster = new MiniDFSCluster.Builder(conf).build();
try {
cluster.waitActive();
bpid = cluster.getNamesystem().getBlockPoolId();
final DataNode dn = cluster.getDataNodes().get(0);
fds = DataNodeTestUtils.getFSDataset(dn);
long lastDirScannerFinishTime = fds.getLastDirScannerFinishTime();
dn.getDirectoryScanner().run();
assertNotEquals(lastDirScannerFinishTime,
fds.getLastDirScannerFinishTime());
} finally {
cluster.shutdown();
}
}
```
--
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]