Return-Path: X-Original-To: apmail-bigtop-commits-archive@www.apache.org Delivered-To: apmail-bigtop-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 72B5C115AF for ; Tue, 8 Jul 2014 22:25:58 +0000 (UTC) Received: (qmail 68906 invoked by uid 500); 8 Jul 2014 22:25:58 -0000 Delivered-To: apmail-bigtop-commits-archive@bigtop.apache.org Received: (qmail 68869 invoked by uid 500); 8 Jul 2014 22:25:58 -0000 Mailing-List: contact commits-help@bigtop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: bigtop-dev@bigtop.apache.org Delivered-To: mailing list commits@bigtop.apache.org Received: (qmail 68860 invoked by uid 99); 8 Jul 2014 22:25:57 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jul 2014 22:25:57 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id AFC569A86DC; Tue, 8 Jul 2014 22:25:57 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jay@apache.org To: commits@bigtop.apache.org Message-Id: <075d391901ef4ecbacac12cbf06f64ab@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: BIGTOP_TODO. TestCLI cleanup Date: Tue, 8 Jul 2014 22:25:57 +0000 (UTC) Repository: bigtop Updated Branches: refs/heads/master f6e11f4da -> e460c974b BIGTOP_TODO. TestCLI cleanup Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/e460c974 Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/e460c974 Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/e460c974 Branch: refs/heads/master Commit: e460c974b677d880d8ce9da5d57c7dfde0cf4a04 Parents: f6e11f4 Author: Martin Bukatovic Authored: Tue May 27 18:25:59 2014 +0200 Committer: Jay Vyas Committed: Tue Jul 8 18:22:03 2014 -0400 ---------------------------------------------------------------------- .../bigtop/itest/hadoop/hdfs/FSCmdExecutor.java | 12 +++++- .../bigtop/itest/hadoop/hdfs/TestCLI.java | 45 +++++++++++++------- 2 files changed, 39 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bigtop/blob/e460c974/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/FSCmdExecutor.java ---------------------------------------------------------------------- diff --git a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/FSCmdExecutor.java b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/FSCmdExecutor.java index 0aba516..04f0d57 100644 --- a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/FSCmdExecutor.java +++ b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/FSCmdExecutor.java @@ -34,11 +34,18 @@ public class FSCmdExecutor extends CommandExecutor { this.shell = shell; } + /** + * Execute given hadoop FsShell command. + */ protected void execute(final String cmd) throws Exception{ String[] args = getCommandAsArgs(cmd, "NAMENODE", this.namenode); ToolRunner.run(shell, args); } + /** + * Prapare given FsShell command for execution by ToolRunner. + * This method also expands all variables used in the command. + */ @Override protected String[] getCommandAsArgs(final String cmd, final String masterKey, final String master) { @@ -49,9 +56,10 @@ public class FSCmdExecutor extends CommandExecutor { args[i] = tokenizer.nextToken(); args[i] = args[i].replaceAll(masterKey, master); 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", TestCLI.TEST_DIR_ABSOLUTE); + new File(CLITestHelper.TEST_CACHE_DATA_DIR). + toURI().toString().replace(' ', '+')); args[i] = args[i].replaceAll("USER_NAME", System.getProperty("user.name")); + args[i] = args[i].replaceAll("TEST_DIR_ABSOLUTE", TestCLI.TEST_DIR_ABSOLUTE); i++; } http://git-wip-us.apache.org/repos/asf/bigtop/blob/e460c974/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestCLI.java ---------------------------------------------------------------------- diff --git a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestCLI.java b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestCLI.java index 1304242..8214209 100644 --- a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestCLI.java +++ b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestCLI.java @@ -41,28 +41,30 @@ import org.apache.commons.lang.StringUtils; */ public class TestCLI extends CLITestHelper { public static final String TEST_DIR_ABSOLUTE = "/tmp/testcli_" + Long.valueOf(System.currentTimeMillis()); - private String nn; - private String sug; - protected String namenode; + private String supergroup; + private String namenode; private static Shell shHDFS = new Shell("/bin/bash"); @Before @Override public void setUp() throws Exception { readTestConfigFile(); + + // Configuration of real Hadoop cluster conf = new HdfsConfiguration(); - conf.setBoolean(CommonConfigurationKeys.HADOOP_SECURITY_AUTHORIZATION, - true); - clitestDataDir = - new File(TEST_CACHE_DATA_DIR).toURI().toString().replace(' ', '+'); - nn = conf.get(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY); - sug = conf.get(DFSConfigKeys.DFS_PERMISSIONS_SUPERUSERGROUP_KEY); - namenode = conf.get(DFSConfigKeys.FS_DEFAULT_NAME_KEY, "file:///"); + supergroup = conf.get(DFSConfigKeys.DFS_PERMISSIONS_SUPERUSERGROUP_KEY); + namenode = conf.get(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY); + + conf.setBoolean(CommonConfigurationKeys.HADOOP_SECURITY_AUTHORIZATION, true); // Many of the tests expect a replication value of 1 in the output conf.setInt("dfs.replication", 1); - String[] createTestcliDirCmds = {"hadoop fs -mkdir -p " + TEST_DIR_ABSOLUTE, - "hadoop fs -chmod 777 " + TEST_DIR_ABSOLUTE}; + clitestDataDir = new File(TEST_CACHE_DATA_DIR).toURI().toString().replace(' ', '+'); + + String[] createTestcliDirCmds = { + "hadoop fs -mkdir -p " + TEST_DIR_ABSOLUTE, + "hadoop fs -chmod 777 " + TEST_DIR_ABSOLUTE + }; shHDFS.exec(createTestcliDirCmds); // Check assumptions which would make some cases fail if not met @@ -99,21 +101,32 @@ public class TestCLI extends CLITestHelper { super.testAll(); } + /** + * Expand commands from the test config file. + * This method is used in displayResults() and compareTestOutput() only, + * so it doesn't have any effect on the test execution itself. + * + * @param cmd + * @return String expanded command + */ @Override protected String expandCommand(final String cmd) { String expCmd = super.expandCommand(cmd); - String testcliDir = TEST_DIR_ABSOLUTE; - expCmd = expCmd.replaceAll("TEST_DIR_ABSOLUTE", testcliDir); - expCmd = expCmd.replaceAll("supergroup", sug); + // note: super.expandCommand() expands CLITEST_DATA and USERNAME + expCmd = expCmd.replaceAll("TEST_DIR_ABSOLUTE", TEST_DIR_ABSOLUTE); + expCmd = expCmd.replaceAll("supergroup", supergroup); expCmd = expCmd.replaceAll("NAMENODE", namenode); expCmd = expCmd.replaceAll("USER_NAME", System.getProperty("user.name")); return expCmd; } + /** + * Execute given hadoop FsShell command (via Toolrunner). + */ @Override protected CommandExecutor.Result execute(CLICommand cmd) throws Exception { if (cmd.getType() instanceof CLICommandFS) { - CommandExecutor cmdExecutor = new FSCmdExecutor(nn, new FsShell(conf)); + CommandExecutor cmdExecutor = new FSCmdExecutor(namenode, new FsShell(conf)); return cmdExecutor.executeCommand(cmd.getCmd()); } else { throw new IllegalArgumentException("Unknown type of test command: " + cmd.getType());