Updated Branches: refs/heads/trunk 0c3cd62fc -> 52a631f36
SQOOP-731 Move HBase tests to manual tests as they depend on unreleased artifacts (Jarek Jarcec Cecho via Cheolsoo Park) Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/52a631f3 Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/52a631f3 Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/52a631f3 Branch: refs/heads/trunk Commit: 52a631f361dac929021059b6327c152c016b2a89 Parents: 0c3cd62 Author: Cheolsoo Park <[email protected]> Authored: Sat Dec 8 19:59:57 2012 -0800 Committer: Cheolsoo Park <[email protected]> Committed: Sat Dec 8 19:59:57 2012 -0800 ---------------------------------------------------------------------- src/test/com/cloudera/sqoop/AllTests.java | 6 - src/test/com/cloudera/sqoop/ThirdPartyTests.java | 16 ++- .../com/cloudera/sqoop/hbase/HBaseImportTest.java | 115 +++++++++++++++ .../cloudera/sqoop/hbase/HBaseQueryImportTest.java | 67 +++++++++ .../com/cloudera/sqoop/hbase/HBaseUtilTest.java | 44 ++++++ .../com/cloudera/sqoop/hbase/TestHBaseImport.java | 115 --------------- .../cloudera/sqoop/hbase/TestHBaseQueryImport.java | 67 --------- .../com/cloudera/sqoop/hbase/TestHBaseUtil.java | 44 ------ 8 files changed, 241 insertions(+), 233 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/sqoop/blob/52a631f3/src/test/com/cloudera/sqoop/AllTests.java ---------------------------------------------------------------------- diff --git a/src/test/com/cloudera/sqoop/AllTests.java b/src/test/com/cloudera/sqoop/AllTests.java index f6594ff..1dfb0fc 100644 --- a/src/test/com/cloudera/sqoop/AllTests.java +++ b/src/test/com/cloudera/sqoop/AllTests.java @@ -18,9 +18,6 @@ package com.cloudera.sqoop; -import com.cloudera.sqoop.hbase.TestHBaseImport; -import com.cloudera.sqoop.hbase.TestHBaseQueryImport; - import junit.framework.Test; import junit.framework.TestSuite; @@ -36,9 +33,6 @@ public final class AllTests { suite.addTest(SmokeTests.suite()); suite.addTest(ThirdPartyTests.suite()); - suite.addTestSuite(TestHBaseImport.class); - suite.addTestSuite(TestHBaseQueryImport.class); - suite.addTestSuite(TestIncrementalImport.class); return suite; } http://git-wip-us.apache.org/repos/asf/sqoop/blob/52a631f3/src/test/com/cloudera/sqoop/ThirdPartyTests.java ---------------------------------------------------------------------- diff --git a/src/test/com/cloudera/sqoop/ThirdPartyTests.java b/src/test/com/cloudera/sqoop/ThirdPartyTests.java index 949b02d..06f7122 100644 --- a/src/test/com/cloudera/sqoop/ThirdPartyTests.java +++ b/src/test/com/cloudera/sqoop/ThirdPartyTests.java @@ -18,6 +18,9 @@ package com.cloudera.sqoop; +import com.cloudera.sqoop.hbase.HBaseImportTest; +import com.cloudera.sqoop.hbase.HBaseQueryImportTest; +import com.cloudera.sqoop.hbase.HBaseUtilTest; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; @@ -45,18 +48,29 @@ public final class ThirdPartyTests extends TestCase { public static Test suite() { TestSuite suite = new TestSuite("Tests vendor-specific ConnManager " - + "implementations in Sqoop"); + + "implementations in Sqoop and tests with third party dependencies"); + + // MySQL suite.addTestSuite(DirectMySQLTest.class); suite.addTestSuite(DirectMySQLExportTest.class); suite.addTestSuite(JdbcMySQLExportTest.class); suite.addTestSuite(MySQLAuthTest.class); suite.addTestSuite(MySQLCompatTest.class); + + // Oracle suite.addTestSuite(OracleExportTest.class); suite.addTestSuite(OracleManagerTest.class); suite.addTestSuite(OracleCompatTest.class); + + // PostgreSQL suite.addTestSuite(PostgresqlImportTest.class); suite.addTestSuite(PostgresqlExportTest.class); + // Hbase + suite.addTestSuite(HBaseImportTest.class); + suite.addTestSuite(HBaseQueryImportTest.class); + suite.addTestSuite(HBaseUtilTest.class); + return suite; } http://git-wip-us.apache.org/repos/asf/sqoop/blob/52a631f3/src/test/com/cloudera/sqoop/hbase/HBaseImportTest.java ---------------------------------------------------------------------- diff --git a/src/test/com/cloudera/sqoop/hbase/HBaseImportTest.java b/src/test/com/cloudera/sqoop/hbase/HBaseImportTest.java new file mode 100644 index 0000000..bf24608 --- /dev/null +++ b/src/test/com/cloudera/sqoop/hbase/HBaseImportTest.java @@ -0,0 +1,115 @@ +/** + * 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 com.cloudera.sqoop.hbase; + +import java.io.IOException; + +import org.junit.Test; + +/** + * Test imports of tables into HBase. + */ +public class HBaseImportTest extends HBaseTestCase { + + @Test + public void testBasicUsage() throws IOException { + // Create the HBase table in Sqoop as we run the job. + String [] argv = getArgv(true, "BasicUsage", "BasicColFam", true, null); + String [] types = { "INT", "INT" }; + String [] vals = { "0", "1" }; + createTableWithColTypes(types, vals); + runImport(argv); + verifyHBaseCell("BasicUsage", "0", "BasicColFam", getColName(1), "1"); + } + + @Test + public void testMissingTableFails() throws IOException { + // Test that if the table doesn't exist, we fail unless we + // explicitly create the table. + String [] argv = getArgv(true, "MissingTable", "MissingFam", false, null); + String [] types = { "INT", "INT" }; + String [] vals = { "0", "1" }; + createTableWithColTypes(types, vals); + try { + runImport(argv); + fail("Expected IOException"); + } catch (IOException ioe) { + LOG.info("Got exception -- ok; we expected that job to fail."); + } + } + + @Test + public void testOverwriteSucceeds() throws IOException { + // Test that we can create a table and then import immediately + // back on top of it without problem. + String [] argv = getArgv(true, "OverwriteT", "OverwriteF", true, null); + String [] types = { "INT", "INT" }; + String [] vals = { "0", "1" }; + createTableWithColTypes(types, vals); + runImport(argv); + verifyHBaseCell("OverwriteT", "0", "OverwriteF", getColName(1), "1"); + // Run a second time. + runImport(argv); + verifyHBaseCell("OverwriteT", "0", "OverwriteF", getColName(1), "1"); + } + + @Test + public void testStrings() throws IOException { + String [] argv = getArgv(true, "stringT", "stringF", true, null); + String [] types = { "INT", "VARCHAR(32)" }; + String [] vals = { "0", "'abc'" }; + createTableWithColTypes(types, vals); + runImport(argv); + verifyHBaseCell("stringT", "0", "stringF", getColName(1), "abc"); + } + + @Test + public void testNulls() throws IOException { + String [] argv = getArgv(true, "nullT", "nullF", true, null); + String [] types = { "INT", "INT", "INT" }; + String [] vals = { "0", "42", "null" }; + createTableWithColTypes(types, vals); + runImport(argv); + + // This cell should import correctly. + verifyHBaseCell("nullT", "0", "nullF", getColName(1), "42"); + + // This cell should not be placed in the results.. + verifyHBaseCell("nullT", "0", "nullF", getColName(2), null); + } + + @Test + public void testExitFailure() throws IOException { + String [] types = { "INT", "INT", "INT" }; + String [] vals = { "0", "42", "43" }; + createTableWithColTypes(types, vals); + + String [] argv = getArgv(true, "NoHBaseT", "NoHBaseF", true, null); + try { + HBaseUtil.setAlwaysNoHBaseJarMode(true); + runImport(argv); + } catch (IOException e) { + return; + } finally { + HBaseUtil.setAlwaysNoHBaseJarMode(false); + } + + fail("should have gotten exception"); + } +} http://git-wip-us.apache.org/repos/asf/sqoop/blob/52a631f3/src/test/com/cloudera/sqoop/hbase/HBaseQueryImportTest.java ---------------------------------------------------------------------- diff --git a/src/test/com/cloudera/sqoop/hbase/HBaseQueryImportTest.java b/src/test/com/cloudera/sqoop/hbase/HBaseQueryImportTest.java new file mode 100644 index 0000000..28b9026 --- /dev/null +++ b/src/test/com/cloudera/sqoop/hbase/HBaseQueryImportTest.java @@ -0,0 +1,67 @@ +/** + * 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 com.cloudera.sqoop.hbase; + +import java.io.IOException; + +import org.junit.Test; + +/** + * Test import of free-form query into HBase. + */ +public class HBaseQueryImportTest extends HBaseTestCase { + + @Test + public void testImportFromQuery() throws IOException { + String [] types = { "INT", "INT", "INT" }; + String [] vals = { "0", "42", "43" }; + createTableWithColTypes(types, vals); + + String [] argv = getArgv(true, "queryT", "queryF", true, + "SELECT " + getColName(0) + ", " + getColName(1) + " FROM " + + getTableName() + " WHERE $CONDITIONS"); + runImport(argv); + + // This cell should import correctly. + verifyHBaseCell("queryT", "0", "queryF", getColName(1), "42"); + + // This cell should not be placed in the results.. + verifyHBaseCell("queryT", "0", "queryF", getColName(2), null); + } + + @Test + public void testExitFailure() throws IOException { + String [] types = { "INT", "INT", "INT" }; + String [] vals = { "0", "42", "43" }; + createTableWithColTypes(types, vals); + + String [] argv = getArgv(true, "queryT", "queryF", true, + "SELECT " + getColName(0) + ", " + getColName(1) + " FROM " + + getTableName() + " WHERE $CONDITIONS"); + try { + HBaseUtil.setAlwaysNoHBaseJarMode(true); + runImport(argv); + } catch (Exception e) { + return; + } finally { + HBaseUtil.setAlwaysNoHBaseJarMode(false); + } + fail("should have gotten exception"); + } +} http://git-wip-us.apache.org/repos/asf/sqoop/blob/52a631f3/src/test/com/cloudera/sqoop/hbase/HBaseUtilTest.java ---------------------------------------------------------------------- diff --git a/src/test/com/cloudera/sqoop/hbase/HBaseUtilTest.java b/src/test/com/cloudera/sqoop/hbase/HBaseUtilTest.java new file mode 100644 index 0000000..166eef3 --- /dev/null +++ b/src/test/com/cloudera/sqoop/hbase/HBaseUtilTest.java @@ -0,0 +1,44 @@ +/** + * 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 com.cloudera.sqoop.hbase; + +import org.junit.Test; + +import junit.framework.TestCase; + +/** + * This tests to verify that HBase is present (default when running test cases) + * and that when in fake not present mode, the method return false. + */ +public class HBaseUtilTest extends TestCase { + + @Test + public void testHBasePresent() { + assertTrue(HBaseUtil.isHBaseJarPresent()); + } + + @Test + public void testHBaseNotPresent() { + HBaseUtil.setAlwaysNoHBaseJarMode(true); + boolean present = HBaseUtil.isHBaseJarPresent(); + HBaseUtil.setAlwaysNoHBaseJarMode(false); + assertFalse(present); + } + +} http://git-wip-us.apache.org/repos/asf/sqoop/blob/52a631f3/src/test/com/cloudera/sqoop/hbase/TestHBaseImport.java ---------------------------------------------------------------------- diff --git a/src/test/com/cloudera/sqoop/hbase/TestHBaseImport.java b/src/test/com/cloudera/sqoop/hbase/TestHBaseImport.java deleted file mode 100644 index d5e15e8..0000000 --- a/src/test/com/cloudera/sqoop/hbase/TestHBaseImport.java +++ /dev/null @@ -1,115 +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 com.cloudera.sqoop.hbase; - -import java.io.IOException; - -import org.junit.Test; - -/** - * Test imports of tables into HBase. - */ -public class TestHBaseImport extends HBaseTestCase { - - @Test - public void testBasicUsage() throws IOException { - // Create the HBase table in Sqoop as we run the job. - String [] argv = getArgv(true, "BasicUsage", "BasicColFam", true, null); - String [] types = { "INT", "INT" }; - String [] vals = { "0", "1" }; - createTableWithColTypes(types, vals); - runImport(argv); - verifyHBaseCell("BasicUsage", "0", "BasicColFam", getColName(1), "1"); - } - - @Test - public void testMissingTableFails() throws IOException { - // Test that if the table doesn't exist, we fail unless we - // explicitly create the table. - String [] argv = getArgv(true, "MissingTable", "MissingFam", false, null); - String [] types = { "INT", "INT" }; - String [] vals = { "0", "1" }; - createTableWithColTypes(types, vals); - try { - runImport(argv); - fail("Expected IOException"); - } catch (IOException ioe) { - LOG.info("Got exception -- ok; we expected that job to fail."); - } - } - - @Test - public void testOverwriteSucceeds() throws IOException { - // Test that we can create a table and then import immediately - // back on top of it without problem. - String [] argv = getArgv(true, "OverwriteT", "OverwriteF", true, null); - String [] types = { "INT", "INT" }; - String [] vals = { "0", "1" }; - createTableWithColTypes(types, vals); - runImport(argv); - verifyHBaseCell("OverwriteT", "0", "OverwriteF", getColName(1), "1"); - // Run a second time. - runImport(argv); - verifyHBaseCell("OverwriteT", "0", "OverwriteF", getColName(1), "1"); - } - - @Test - public void testStrings() throws IOException { - String [] argv = getArgv(true, "stringT", "stringF", true, null); - String [] types = { "INT", "VARCHAR(32)" }; - String [] vals = { "0", "'abc'" }; - createTableWithColTypes(types, vals); - runImport(argv); - verifyHBaseCell("stringT", "0", "stringF", getColName(1), "abc"); - } - - @Test - public void testNulls() throws IOException { - String [] argv = getArgv(true, "nullT", "nullF", true, null); - String [] types = { "INT", "INT", "INT" }; - String [] vals = { "0", "42", "null" }; - createTableWithColTypes(types, vals); - runImport(argv); - - // This cell should import correctly. - verifyHBaseCell("nullT", "0", "nullF", getColName(1), "42"); - - // This cell should not be placed in the results.. - verifyHBaseCell("nullT", "0", "nullF", getColName(2), null); - } - - @Test - public void testExitFailure() throws IOException { - String [] types = { "INT", "INT", "INT" }; - String [] vals = { "0", "42", "43" }; - createTableWithColTypes(types, vals); - - String [] argv = getArgv(true, "NoHBaseT", "NoHBaseF", true, null); - try { - HBaseUtil.setAlwaysNoHBaseJarMode(true); - runImport(argv); - } catch (IOException e) { - return; - } finally { - HBaseUtil.setAlwaysNoHBaseJarMode(false); - } - - fail("should have gotten exception"); - } -} http://git-wip-us.apache.org/repos/asf/sqoop/blob/52a631f3/src/test/com/cloudera/sqoop/hbase/TestHBaseQueryImport.java ---------------------------------------------------------------------- diff --git a/src/test/com/cloudera/sqoop/hbase/TestHBaseQueryImport.java b/src/test/com/cloudera/sqoop/hbase/TestHBaseQueryImport.java deleted file mode 100644 index 74eff50..0000000 --- a/src/test/com/cloudera/sqoop/hbase/TestHBaseQueryImport.java +++ /dev/null @@ -1,67 +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 com.cloudera.sqoop.hbase; - -import java.io.IOException; - -import org.junit.Test; - -/** - * Test import of free-form query into HBase. - */ -public class TestHBaseQueryImport extends HBaseTestCase { - - @Test - public void testImportFromQuery() throws IOException { - String [] types = { "INT", "INT", "INT" }; - String [] vals = { "0", "42", "43" }; - createTableWithColTypes(types, vals); - - String [] argv = getArgv(true, "queryT", "queryF", true, - "SELECT " + getColName(0) + ", " + getColName(1) + " FROM " - + getTableName() + " WHERE $CONDITIONS"); - runImport(argv); - - // This cell should import correctly. - verifyHBaseCell("queryT", "0", "queryF", getColName(1), "42"); - - // This cell should not be placed in the results.. - verifyHBaseCell("queryT", "0", "queryF", getColName(2), null); - } - - @Test - public void testExitFailure() throws IOException { - String [] types = { "INT", "INT", "INT" }; - String [] vals = { "0", "42", "43" }; - createTableWithColTypes(types, vals); - - String [] argv = getArgv(true, "queryT", "queryF", true, - "SELECT " + getColName(0) + ", " + getColName(1) + " FROM " - + getTableName() + " WHERE $CONDITIONS"); - try { - HBaseUtil.setAlwaysNoHBaseJarMode(true); - runImport(argv); - } catch (Exception e) { - return; - } finally { - HBaseUtil.setAlwaysNoHBaseJarMode(false); - } - fail("should have gotten exception"); - } -} http://git-wip-us.apache.org/repos/asf/sqoop/blob/52a631f3/src/test/com/cloudera/sqoop/hbase/TestHBaseUtil.java ---------------------------------------------------------------------- diff --git a/src/test/com/cloudera/sqoop/hbase/TestHBaseUtil.java b/src/test/com/cloudera/sqoop/hbase/TestHBaseUtil.java deleted file mode 100644 index e019924..0000000 --- a/src/test/com/cloudera/sqoop/hbase/TestHBaseUtil.java +++ /dev/null @@ -1,44 +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 com.cloudera.sqoop.hbase; - -import org.junit.Test; - -import junit.framework.TestCase; - -/** - * This tests to verify that HBase is present (default when running test cases) - * and that when in fake not present mode, the method return false. - */ -public class TestHBaseUtil extends TestCase { - - @Test - public void testHBasePresent() { - assertTrue(HBaseUtil.isHBaseJarPresent()); - } - - @Test - public void testHBaseNotPresent() { - HBaseUtil.setAlwaysNoHBaseJarMode(true); - boolean present = HBaseUtil.isHBaseJarPresent(); - HBaseUtil.setAlwaysNoHBaseJarMode(false); - assertFalse(present); - } - -}
