HDFS-13550.TestDebugAdmin#testComputeMetaCommand fails on Windows. Contributed by Anbang Hu.

(cherry picked from commit 55d5549087)
This commit is contained in:
Inigo Goiri 2018-05-16 10:08:49 -07:00
parent 2c3f300464
commit e12ddd9394
2 changed files with 20 additions and 12 deletions

View File

@ -97,15 +97,17 @@ public class DebugAdmin extends Configured implements Tool {
VerifyMetaCommand() { VerifyMetaCommand() {
super("verifyMeta", super("verifyMeta",
"verifyMeta -meta <metadata-file> [-block <block-file>]", "verifyMeta -meta <metadata-file> [-block <block-file>]",
" Verify HDFS metadata and block files. If a block file is specified, we\n" + " Verify HDFS metadata and block files. If a block file is specified, we" +
" will verify that the checksums in the metadata file match the block\n" + System.lineSeparator() +
" will verify that the checksums in the metadata file match the block" +
System.lineSeparator() +
" file."); " file.");
} }
int run(List<String> args) throws IOException { int run(List<String> args) throws IOException {
if (args.size() == 0) { if (args.size() == 0) {
System.out.println(usageText); System.out.println(usageText);
System.out.println(helpText + "\n"); System.out.println(helpText + System.lineSeparator());
return 1; return 1;
} }
String blockFile = StringUtils.popOptionWithArgument("-block", args); String blockFile = StringUtils.popOptionWithArgument("-block", args);
@ -212,10 +214,15 @@ public class DebugAdmin extends Configured implements Tool {
super("computeMeta", super("computeMeta",
"computeMeta -block <block-file> -out <output-metadata-file>", "computeMeta -block <block-file> -out <output-metadata-file>",
" Compute HDFS metadata from the specified block file, and save it" " Compute HDFS metadata from the specified block file, and save it"
+ " to\n the specified output metadata file.\n\n" + " to" + System.lineSeparator()
+ "**NOTE: Use at your own risk!\n If the block file is corrupt" + " the specified output metadata file."
+ " and you overwrite it's meta file, \n it will show up" + System.lineSeparator() + System.lineSeparator()
+ " as good in HDFS, but you can't read the data.\n" + "**NOTE: Use at your own risk!" + System.lineSeparator()
+ " If the block file is corrupt"
+ " and you overwrite it's meta file, " + System.lineSeparator()
+ " it will show up"
+ " as good in HDFS, but you can't read the data."
+ System.lineSeparator()
+ " Only use as a last measure, and when you are 100% certain" + " Only use as a last measure, and when you are 100% certain"
+ " the block file is good."); + " the block file is good.");
} }
@ -234,7 +241,7 @@ public class DebugAdmin extends Configured implements Tool {
int run(List<String> args) throws IOException { int run(List<String> args) throws IOException {
if (args.size() == 0) { if (args.size() == 0) {
System.out.println(usageText); System.out.println(usageText);
System.out.println(helpText + "\n"); System.out.println(helpText + System.lineSeparator());
return 1; return 1;
} }
final String name = StringUtils.popOptionWithArgument("-block", args); final String name = StringUtils.popOptionWithArgument("-block", args);
@ -291,7 +298,8 @@ public class DebugAdmin extends Configured implements Tool {
RecoverLeaseCommand() { RecoverLeaseCommand() {
super("recoverLease", super("recoverLease",
"recoverLease -path <path> [-retries <num-retries>]", "recoverLease -path <path> [-retries <num-retries>]",
" Recover the lease on the specified path. The path must reside on an\n" + " Recover the lease on the specified path. The path must reside on an" +
System.lineSeparator() +
" HDFS filesystem. The default number of retries is 1."); " HDFS filesystem. The default number of retries is 1.");
} }
@ -300,7 +308,7 @@ public class DebugAdmin extends Configured implements Tool {
int run(List<String> args) throws IOException { int run(List<String> args) throws IOException {
if (args.size() == 0) { if (args.size() == 0) {
System.out.println(usageText); System.out.println(usageText);
System.out.println(helpText + "\n"); System.out.println(helpText + System.lineSeparator());
return 1; return 1;
} }
String pathStr = StringUtils.popOptionWithArgument("-path", args); String pathStr = StringUtils.popOptionWithArgument("-path", args);
@ -395,7 +403,7 @@ public class DebugAdmin extends Configured implements Tool {
return 0; return 0;
} }
System.out.println(command.usageText); System.out.println(command.usageText);
System.out.println(command.helpText + "\n"); System.out.println(command.helpText + System.lineSeparator());
return 0; return 0;
} }
} }

View File

@ -87,7 +87,7 @@ public class TestDebugAdmin {
IOUtils.closeStream(out); IOUtils.closeStream(out);
} }
return "ret: " + ret + ", " + return "ret: " + ret + ", " +
bytes.toString().replaceAll(System.getProperty("line.separator"), ""); bytes.toString().replaceAll(System.lineSeparator(), "");
} }
@Test(timeout = 60000) @Test(timeout = 60000)