ayushtkn commented on code in PR #6319:
URL: https://github.com/apache/hadoop/pull/6319#discussion_r1414895365


##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNNThroughputBenchmark.java:
##########
@@ -187,4 +187,60 @@ public void testNNThroughputForBlockReportOp() throws 
Exception {
               "blockReport", "-datanodes", "3", "-reports", "2"});
     }
   }
+
+  /**
+   * This test runs {@link NNThroughputBenchmark} against a mini DFS cluster
+   * with explicit -baseDirName option.
+   */
+  @Test(timeout = 120000)
+  public void testNNThroughputWithBaseDir() throws Exception {
+    final Configuration conf = new HdfsConfiguration();
+    conf.setInt(DFSConfigKeys.DFS_NAMENODE_MIN_BLOCK_SIZE_KEY, 16);
+    MiniDFSCluster cluster = null;
+    try {
+      cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build();
+      cluster.waitActive();
+      final Configuration benchConf = new HdfsConfiguration();
+      benchConf.setInt(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, 16);
+      FileSystem.setDefaultUri(benchConf, cluster.getURI());
+
+      NNThroughputBenchmark.runBenchmark(benchConf,
+          new String[] {"-op", "create", "-keepResults", "-files", "3", 
"-baseDirName",
+              "/nnThroughputBenchmark1", "-close"});
+      FSNamesystem fsNamesystem = cluster.getNamesystem();
+      DirectoryListing listing = fsNamesystem.getListing("/", 
HdfsFileStatus.EMPTY_NAME, false);
+      Boolean dirExist1 = false;
+      Boolean dirExist2 = false;
+      for (HdfsFileStatus f : listing.getPartialListing()) {
+        if (f.getFullName("/").equals("/nnThroughputBenchmark1")) {
+          dirExist1 = true;
+        }
+        if (f.getFullName("/").equals("/nnThroughputBenchmark")) {
+          dirExist2 = true;
+        }
+      }
+      Assert.assertEquals(dirExist1, true);
+      Assert.assertEquals(dirExist2, false);
+
+      NNThroughputBenchmark.runBenchmark(benchConf,
+          new String[] {"-op", "all", "-baseDirName", 
"/nnThroughputBenchmark1"});
+      listing = fsNamesystem.getListing("/", HdfsFileStatus.EMPTY_NAME, false);

Review Comment:
   can't we use fs.exists(path) for such validations rather than listing and 
then checking?



-- 
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]

Reply via email to