Repository: bigtop Updated Branches: refs/heads/master 8d2bc70eb -> e5c16ef25
BIGTOP-1629. Move testDFSCLI from hcfs to hdfs directory Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/e5c16ef2 Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/e5c16ef2 Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/e5c16ef2 Branch: refs/heads/master Commit: e5c16ef25aab91b964e542fa3f32a87b834e7770 Parents: 8d2bc70 Author: Dasha <[email protected]> Authored: Wed Jan 28 16:44:15 2015 -0800 Committer: Dasha <[email protected]> Committed: Wed Jan 28 16:44:15 2015 -0800 ---------------------------------------------------------------------- .../bigtop/itest/hadoop/hcfs/TestDFSCLI.java | 109 ------------------- .../bigtop/itest/hadoop/hdfs/TestDFSCLI.java | 109 +++++++++++++++++++ 2 files changed, 109 insertions(+), 109 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bigtop/blob/e5c16ef2/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hcfs/TestDFSCLI.java ---------------------------------------------------------------------- diff --git a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hcfs/TestDFSCLI.java b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hcfs/TestDFSCLI.java deleted file mode 100644 index 586c0e5..0000000 --- a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hcfs/TestDFSCLI.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.bigtop.itest.hadoop.hcfs; - -import org.apache.bigtop.itest.shell.Shell; -import org.apache.commons.lang.StringUtils; -import org.apache.hadoop.cli.TestHDFSCLI; -import org.apache.hadoop.fs.CommonConfigurationKeys; -import org.apache.hadoop.hdfs.DFSConfigKeys; -import org.apache.hadoop.hdfs.HdfsConfiguration; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; - -import java.io.File; - -public class TestDFSCLI extends TestHDFSCLI { - public static final String TEST_DIR_ABSOLUTE = "/tmp/testcli_" + Long.valueOf(System.currentTimeMillis()); - public static String NAMENODE_TESTDIR_HACK; - private String supergroup; - private static Shell shHDFS = new Shell("/bin/bash"); - - @Before - @Override - public void setUp() throws Exception { - readTestConfigFile(); - - // Configuration of real Hadoop cluster - conf = new HdfsConfiguration(); - supergroup = System.getProperty("hcfs.root.groupname", - conf.get(DFSConfigKeys.DFS_PERMISSIONS_SUPERUSERGROUP_KEY)); - namenode = conf.get(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY); - username = System.getProperty("user.name"); - - 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); - - 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 - Assert.assertEquals("Creation of testcli dir should succeed and return 0" - + " (but it failed with the following error message: " - + StringUtils.join(shHDFS.getErr().toArray(), "\\n") + ")", - 0, shHDFS.getRet()); - // We can't just use conf.setInt(fs.trash.interval", 0) because if trash is - // enabled on the server, client configuration value is ignored. - Assert.assertEquals("HDFS trash should be disabled via fs.trash.interval", - 0, conf.getInt("fs.trash.interval", 0)); - Assert.assertEquals("This test needs to be run under root user of hcfs", - System.getProperty("hcfs.root.username", "hdfs"), username); - } - - @After - @Override - public void tearDown() throws Exception { - super.tearDown(); - - String removeTestcliDirCmd = "hadoop fs -rm -r " + TEST_DIR_ABSOLUTE; - shHDFS.exec(removeTestcliDirCmd); - } - - @Override - protected String getTestFile() { - return "testDFSConf.xml"; - } - - /** - * 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 executed command - * @return String expanded command - */ - @Override - protected String expandCommand(String cmd) { - String expCmd = super.expandCommand(cmd); - // note: super.expandCommand() expands CLITEST_DATA and USERNAME - expCmd = expCmd.replaceAll("NAMENODETEST_DIR_ABSOLUTE", NAMENODE_TESTDIR_HACK); - 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; - } -} http://git-wip-us.apache.org/repos/asf/bigtop/blob/e5c16ef2/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestDFSCLI.java ---------------------------------------------------------------------- diff --git a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestDFSCLI.java b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestDFSCLI.java new file mode 100644 index 0000000..a0848ad --- /dev/null +++ b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestDFSCLI.java @@ -0,0 +1,109 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.bigtop.itest.hadoop.hdfs; + +import org.apache.bigtop.itest.shell.Shell; +import org.apache.commons.lang.StringUtils; +import org.apache.hadoop.cli.TestHDFSCLI; +import org.apache.hadoop.fs.CommonConfigurationKeys; +import org.apache.hadoop.hdfs.DFSConfigKeys; +import org.apache.hadoop.hdfs.HdfsConfiguration; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; + +import java.io.File; + +public class TestDFSCLI extends TestHDFSCLI { + public static final String TEST_DIR_ABSOLUTE = "/tmp/testcli_" + Long.valueOf(System.currentTimeMillis()); + public static String NAMENODE_TESTDIR_HACK; + private String supergroup; + private static Shell shHDFS = new Shell("/bin/bash"); + + @Before + @Override + public void setUp() throws Exception { + readTestConfigFile(); + + // Configuration of real Hadoop cluster + conf = new HdfsConfiguration(); + supergroup = System.getProperty("hcfs.root.groupname", + conf.get(DFSConfigKeys.DFS_PERMISSIONS_SUPERUSERGROUP_KEY)); + namenode = conf.get(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY); + username = System.getProperty("user.name"); + + 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); + + 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 + Assert.assertEquals("Creation of testcli dir should succeed and return 0" + + " (but it failed with the following error message: " + + StringUtils.join(shHDFS.getErr().toArray(), "\\n") + ")", + 0, shHDFS.getRet()); + // We can't just use conf.setInt(fs.trash.interval", 0) because if trash is + // enabled on the server, client configuration value is ignored. + Assert.assertEquals("HDFS trash should be disabled via fs.trash.interval", + 0, conf.getInt("fs.trash.interval", 0)); + Assert.assertEquals("This test needs to be run under root user of hcfs", + System.getProperty("hcfs.root.username", "hdfs"), username); + } + + @After + @Override + public void tearDown() throws Exception { + super.tearDown(); + + String removeTestcliDirCmd = "hadoop fs -rm -r " + TEST_DIR_ABSOLUTE; + shHDFS.exec(removeTestcliDirCmd); + } + + @Override + protected String getTestFile() { + return "testDFSConf.xml"; + } + + /** + * 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 executed command + * @return String expanded command + */ + @Override + protected String expandCommand(String cmd) { + String expCmd = super.expandCommand(cmd); + // note: super.expandCommand() expands CLITEST_DATA and USERNAME + expCmd = expCmd.replaceAll("NAMENODETEST_DIR_ABSOLUTE", NAMENODE_TESTDIR_HACK); + 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; + } +}
