Author: cos Date: Tue Oct 11 18:43:13 2011 New Revision: 1182018 URL: http://svn.apache.org/viewvc?rev=1182018&view=rev Log: HADOOP-7730. Allow TestCLI to be run against a cluster. Contributed by Tom White, Konstantin Boudnik.
Modified: hadoop/common/branches/branch-0.22/common/CHANGES.txt hadoop/common/branches/branch-0.22/common/src/test/core/org/apache/hadoop/cli/CLITestHelper.java hadoop/common/branches/branch-0.22/common/src/test/core/org/apache/hadoop/cli/util/CommandExecutor.java Modified: hadoop/common/branches/branch-0.22/common/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.22/common/CHANGES.txt?rev=1182018&r1=1182017&r2=1182018&view=diff ============================================================================== --- hadoop/common/branches/branch-0.22/common/CHANGES.txt (original) +++ hadoop/common/branches/branch-0.22/common/CHANGES.txt Tue Oct 11 18:43:13 2011 @@ -549,6 +549,8 @@ Release 0.22.0 - Unreleased HADOOP-7697. Remove ivy dependency on different version of slf4j in avro. (shv) + HADOOP-7730. Allow TestCLI to be run against a cluster (cos) + Release 0.21.1 - Unreleased IMPROVEMENTS Modified: hadoop/common/branches/branch-0.22/common/src/test/core/org/apache/hadoop/cli/CLITestHelper.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.22/common/src/test/core/org/apache/hadoop/cli/CLITestHelper.java?rev=1182018&r1=1182017&r2=1182018&view=diff ============================================================================== --- hadoop/common/branches/branch-0.22/common/src/test/core/org/apache/hadoop/cli/CLITestHelper.java (original) +++ hadoop/common/branches/branch-0.22/common/src/test/core/org/apache/hadoop/cli/CLITestHelper.java Tue Oct 11 18:43:13 2011 @@ -59,7 +59,9 @@ public class CLITestHelper { public static final String TESTMODE_NOCOMPARE = "nocompare"; public static final String TEST_CACHE_DATA_DIR = System.getProperty("test.cache.data", "build/test/cache"); - + public static final String TEST_DIR_ABSOLUTE = "/tmp/testcli"; + protected static String testDirAbsolute = TEST_DIR_ABSOLUTE; + //By default, run the tests. The other mode is to run the commands and not // compare the output protected String testMode = TESTMODE_TEST; @@ -72,7 +74,7 @@ public class CLITestHelper { protected Configuration conf = null; protected String clitestDataDir = null; protected String username = null; - + /** * Read the test config file - testConfig.xml */ @@ -80,10 +82,16 @@ public class CLITestHelper { String testConfigFile = getTestFile(); if (testsFromConfigFile == null) { boolean success = false; - testConfigFile = TEST_CACHE_DATA_DIR + File.separator + testConfigFile; + String configFile = System.getProperty("test.cli.config"); + if (configFile == null) { + testConfigFile = TEST_CACHE_DATA_DIR + File.separator + testConfigFile; + } else { + testConfigFile = configFile; + } try { SAXParser p = (SAXParserFactory.newInstance()).newSAXParser(); p.parse(testConfigFile, new TestConfigFileParser()); + LOG.info("Using test config file " + testConfigFile); success = true; } catch (Exception e) { LOG.info("File: " + testConfigFile + " not found"); @@ -110,6 +118,8 @@ public class CLITestHelper { clitestDataDir = new File(TEST_CACHE_DATA_DIR). toURI().toString().replace(' ', '+'); + // Many of the tests expect a replication value of 1 in the output + conf.setInt("dfs.replication", 1); } /** @@ -128,7 +138,8 @@ public class CLITestHelper { String expCmd = cmd; expCmd = expCmd.replaceAll("CLITEST_DATA", clitestDataDir); expCmd = expCmd.replaceAll("USERNAME", username); - + expCmd = expCmd.replaceAll("TEST_DIR_ABSOLUTE", testDirAbsolute); + return expCmd; } Modified: hadoop/common/branches/branch-0.22/common/src/test/core/org/apache/hadoop/cli/util/CommandExecutor.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.22/common/src/test/core/org/apache/hadoop/cli/util/CommandExecutor.java?rev=1182018&r1=1182017&r2=1182018&view=diff ============================================================================== --- hadoop/common/branches/branch-0.22/common/src/test/core/org/apache/hadoop/cli/util/CommandExecutor.java (original) +++ hadoop/common/branches/branch-0.22/common/src/test/core/org/apache/hadoop/cli/util/CommandExecutor.java Tue Oct 11 18:43:13 2011 @@ -43,6 +43,8 @@ public abstract class CommandExecutor { args[i] = args[i].replaceAll("CLITEST_DATA", new File(CLITestHelper.TEST_CACHE_DATA_DIR). toURI().toString().replace(' ', '+')); + args[i] = args[i].replaceAll("TEST_DIR_ABSOLUTE", + CLITestHelper.TEST_DIR_ABSOLUTE); args[i] = args[i].replaceAll("USERNAME", System.getProperty("user.name")); i++;