Skip to content

Commit

Permalink
update ut with fs.exists
Browse files Browse the repository at this point in the history
  • Loading branch information
eddy.cao committed Dec 5, 2023
1 parent 84cd5ee commit d6b7c88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ void printResults() {
class ReplicationStats extends OperationStatsBase {
static final String OP_REPLICATION_NAME = "replication";
static final String OP_REPLICATION_USAGE =
"-op replication [-datanodes T] [-nodesToDecommission N] " +
"-op replication [-datanodes T] [-nodesToDecommission D] " +
"[-nodeReplicationLimit C] [-totalBlocks B] [-blockSize S] "
+ "[-replication R] [-baseDirName D]";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.DFSTestUtil;
import org.apache.hadoop.hdfs.DistributedFileSystem;
import org.apache.hadoop.hdfs.HdfsConfiguration;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.protocol.DirectoryListing;
Expand Down Expand Up @@ -203,40 +205,18 @@ public void testNNThroughputWithBaseDir() throws Exception {
final Configuration benchConf = new HdfsConfiguration();
benchConf.setInt(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, 16);
FileSystem.setDefaultUri(benchConf, cluster.getURI());
DistributedFileSystem fs = cluster.getFileSystem();

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);
Assert.assertTrue(fs.exists(new Path("/nnThroughputBenchmark1")));
Assert.assertFalse(fs.exists(new Path("/nnThroughputBenchmark")));

NNThroughputBenchmark.runBenchmark(benchConf,
new String[] {"-op", "all", "-baseDirName", "/nnThroughputBenchmark1"});
listing = fsNamesystem.getListing("/", HdfsFileStatus.EMPTY_NAME, false);
dirExist1 = false;
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);
Assert.assertTrue(fs.exists(new Path("/nnThroughputBenchmark1")));
Assert.assertFalse(fs.exists(new Path("/nnThroughputBenchmark")));
} finally {
if (cluster != null) {
cluster.shutdown();
Expand Down

0 comments on commit d6b7c88

Please sign in to comment.