sodonnel commented on a change in pull request #3593:
URL: https://github.com/apache/hadoop/pull/3593#discussion_r741306774
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDebugAdmin.java
##########
@@ -166,8 +179,91 @@ public void testComputeMetaCommand() throws Exception {
@Test(timeout = 60000)
public void testRecoverLeaseforFileNotFound() throws Exception {
+ cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
+ cluster.waitActive();
assertTrue(runCmd(new String[] {
"recoverLease", "-path", "/foo", "-retries", "2" }).contains(
"Giving up on recoverLease for /foo after 1 try"));
}
+
+ @Test(timeout = 60000)
+ public void testVerifyECCommand() throws Exception {
+ final ErasureCodingPolicy ecPolicy = SystemErasureCodingPolicies.getByID(
+ SystemErasureCodingPolicies.RS_3_2_POLICY_ID);
+ cluster = DFSTestUtil.setupCluster(conf, 6, 5, 0);
+ cluster.waitActive();
+ DistributedFileSystem fs = cluster.getFileSystem();
+
+ assertEquals("ret: 1, verifyEC -file <file> Verify HDFS erasure coding on
" +
+ "all block groups of the file.", runCmd(new String[]{"verifyEC"}));
+
+ assertEquals("ret: 1, File /bar does not exist.",
+ runCmd(new String[]{"verifyEC", "-file", "/bar"}));
+
+ fs.create(new Path("/bar")).close();
+ assertEquals("ret: 1, File /bar is not erasure coded.",
+ runCmd(new String[]{"verifyEC", "-file", "/bar"}));
+
+
+ final Path ecDir = new Path("/ec");
+ fs.mkdir(ecDir, FsPermission.getDirDefault());
+ fs.enableErasureCodingPolicy(ecPolicy.getName());
+ fs.setErasureCodingPolicy(ecDir, ecPolicy.getName());
+
+ assertEquals("ret: 1, File /ec is not a regular file.",
+ runCmd(new String[]{"verifyEC", "-file", "/ec"}));
+
+ fs.create(new Path(ecDir, "foo"));
+ assertEquals("ret: 1, File /ec/foo is not closed.",
+ runCmd(new String[]{"verifyEC", "-file", "/ec/foo"}));
+
+ final short repl = 1;
+ final long k = 1024;
+ final long m = k * k;
+ final long seed = 0x1234567L;
+ DFSTestUtil.createFile(fs, new Path(ecDir, "foo_65535"), 65535, repl,
seed);
+ assertTrue(runCmd(new String[]{"verifyEC", "-file", "/ec/foo_65535"})
+ .contains("All EC block group status: OK"));
+ DFSTestUtil.createFile(fs, new Path(ecDir, "foo_256k"), 256 * k, repl,
seed);
+ assertTrue(runCmd(new String[]{"verifyEC", "-file", "/ec/foo_256k"})
+ .contains("All EC block group status: OK"));
+ DFSTestUtil.createFile(fs, new Path(ecDir, "foo_1m"), m, repl, seed);
+ assertTrue(runCmd(new String[]{"verifyEC", "-file", "/ec/foo_1m"})
+ .contains("All EC block group status: OK"));
+ DFSTestUtil.createFile(fs, new Path(ecDir, "foo_2m"), 2 * m, repl, seed);
+ assertTrue(runCmd(new String[]{"verifyEC", "-file", "/ec/foo_2m"})
+ .contains("All EC block group status: OK"));
+ DFSTestUtil.createFile(fs, new Path(ecDir, "foo_3m"), 3 * m, repl, seed);
+ assertTrue(runCmd(new String[]{"verifyEC", "-file", "/ec/foo_3m"})
+ .contains("All EC block group status: OK"));
+ DFSTestUtil.createFile(fs, new Path(ecDir, "foo_5m"), 5 * m, repl, seed);
+ assertTrue(runCmd(new String[]{"verifyEC", "-file", "/ec/foo_5m"})
+ .contains("All EC block group status: OK"));
+
Review comment:
Could you add one more test case for a file that has multiple block
groups, so we test the command looping over more than 1 block? You are using EC
3-2, so write a file that is 6MB, with a 1MB block size. That should create 2
block groups, with a length of 3MB each. Each block would then have a single
1MB EC chunk in it.
In `DFSTestUtil` there is a method to pass the blocksize already, so the
test would be almost the same as the ones above:
```
public static void createFile(FileSystem fs, Path fileName, int bufferLen,
long fileLen, long blockSize, short replFactor, long seed)
```
--
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]