Browse Source

HDFS-10571. TestDiskBalancerCommand#testPlanNode failed with IllegalArgumentException. Contributed by Xiaobing Zhou.

Anu Engineer 8 years ago
parent
commit
b2584bee45

+ 14 - 3
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/command/TestDiskBalancerCommand.java

@@ -280,7 +280,7 @@ public class TestDiskBalancerCommand {
     final String cmdLine = String
     final String cmdLine = String
         .format(
         .format(
             "hdfs diskbalancer %s", planArg);
             "hdfs diskbalancer %s", planArg);
-    runCommand(cmdLine);
+    runCommand(cmdLine, cluster);
   }
   }
 
 
   /* Test that illegal arguments are handled correctly*/
   /* Test that illegal arguments are handled correctly*/
@@ -335,12 +335,12 @@ public class TestDiskBalancerCommand {
     runCommand(cmdLine);
     runCommand(cmdLine);
   }
   }
 
 
-  private List<String> runCommand(final String cmdLine) throws Exception {
+  private List<String> runCommandInternal(final String cmdLine) throws
+      Exception {
     String[] cmds = StringUtils.split(cmdLine, ' ');
     String[] cmds = StringUtils.split(cmdLine, ' ');
     org.apache.hadoop.hdfs.tools.DiskBalancer db =
     org.apache.hadoop.hdfs.tools.DiskBalancer db =
         new org.apache.hadoop.hdfs.tools.DiskBalancer(conf);
         new org.apache.hadoop.hdfs.tools.DiskBalancer(conf);
 
 
-    FileSystem.setDefaultUri(conf, clusterJson);
     ByteArrayOutputStream bufOut = new ByteArrayOutputStream();
     ByteArrayOutputStream bufOut = new ByteArrayOutputStream();
     PrintStream out = new PrintStream(bufOut);
     PrintStream out = new PrintStream(bufOut);
     db.run(cmds, out);
     db.run(cmds, out);
@@ -353,6 +353,17 @@ public class TestDiskBalancerCommand {
     return outputs;
     return outputs;
   }
   }
 
 
+  private List<String> runCommand(final String cmdLine) throws Exception {
+    FileSystem.setDefaultUri(conf, clusterJson);
+    return runCommandInternal(cmdLine);
+  }
+
+  private List<String> runCommand(final String cmdLine,
+                                  MiniDFSCluster miniCluster) throws Exception {
+    FileSystem.setDefaultUri(conf, miniCluster.getURI());
+    return runCommandInternal(cmdLine);
+  }
+
   /**
   /**
    * Making sure that we can query the node without having done a submit.
    * Making sure that we can query the node without having done a submit.
    * @throws Exception
    * @throws Exception