HAWQ-1012. Update feature tests for hawq register.
Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/7e0c63ad Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/7e0c63ad Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/7e0c63ad Branch: refs/heads/master Commit: 7e0c63adc7b7d117517a64905e20bb23229fb368 Parents: 31c3cde Author: xunzhang <[email protected]> Authored: Wed Aug 24 17:14:37 2016 +0800 Committer: Ruilong Huo <[email protected]> Committed: Thu Aug 25 10:25:09 2016 +0800 ---------------------------------------------------------------------- .../ManagementTool/test_hawq_register.cpp | 24 ++++++++++++++++++++ tools/bin/hawqregister | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/7e0c63ad/src/test/feature/ManagementTool/test_hawq_register.cpp ---------------------------------------------------------------------- diff --git a/src/test/feature/ManagementTool/test_hawq_register.cpp b/src/test/feature/ManagementTool/test_hawq_register.cpp index 00934a9..434f817 100644 --- a/src/test/feature/ManagementTool/test_hawq_register.cpp +++ b/src/test/feature/ManagementTool/test_hawq_register.cpp @@ -2,6 +2,7 @@ #include "lib/command.h" #include "lib/sql_util.h" +#include "lib/string_util.h" #include "gtest/gtest.h" @@ -317,3 +318,26 @@ TEST_F(TestHawqRegister, TestUsage2AOHash2) { util.execute("drop table t8;"); util.execute("drop table nt8;"); } + +TEST_F(TestHawqRegister, TestEmptyTable) { + SQLUtility util; + util.execute("drop table if exists t9;"); + util.execute("create table t9(i int) with (appendonly=true, orientation=row) distributed randomly;"); + EXPECT_EQ(0, Command::getCommandStatus("hawq extract -d " + (string) HAWQ_DB + " -o t9.yml testhawqregister_testemptytable.t9")); + EXPECT_EQ(0, Command::getCommandStatus("hawq register -d " + (string) HAWQ_DB + " -c t9.yml testhawqregister_testemptytable.nt9")); + util.query("select * from nt9;", 0); + EXPECT_EQ(0, Command::getCommandStatus("rm -rf t9.yml")); + util.execute("drop table t9;"); + util.execute("drop table nt9;"); +} + +TEST_F(TestHawqRegister, TestIncorrectYaml) { + SQLUtility util; + string filePath = util.getTestRootPath() + "/ManagementTool/"; + EXPECT_EQ(0, hawq::test::endsWith(Command::getCommandOutput("hawq register -d " + (string) HAWQ_DB + " -c " + filePath + "incorrect1.yml xx"), "attribute does not exist.")); + EXPECT_EQ(0, hawq::test::endsWith(Command::getCommandOutput("hawq register -d " + (string) HAWQ_DB + " -c " + filePath + "incorrect2.yml xx"), "attribute does not exist.")); + EXPECT_EQ(0, hawq::test::endsWith(Command::getCommandOutput("hawq register -d " + (string) HAWQ_DB + " -c " + filePath + "incorrect3.yml xx"), "attribute does not exist.")); + EXPECT_EQ(0, hawq::test::endsWith(Command::getCommandOutput("hawq register -d " + (string) HAWQ_DB + " -c " + filePath + "incorrect4.yml xx"), "attribute does not exist.")); + EXPECT_EQ(0, hawq::test::endsWith(Command::getCommandOutput("hawq register -d " + (string) HAWQ_DB + " -c " + filePath + "incorrect5.yml xx"), "attribute does not exist.")); + EXPECT_EQ(1, Command::getCommandStatus("hawq register -d " + (string) HAWQ_DB + " -c " + filePath + "incorrect6.yml xx")); +} http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/7e0c63ad/tools/bin/hawqregister ---------------------------------------------------------------------- diff --git a/tools/bin/hawqregister b/tools/bin/hawqregister index c2692d8..26284a8 100755 --- a/tools/bin/hawqregister +++ b/tools/bin/hawqregister @@ -359,7 +359,7 @@ if __name__ == '__main__': print 'File(s) to be registered:', files if fileformat == 'Parquet': check_parquet_format(files) - print files + print files move_files_in_hdfs(database, tablename, files, firstsegno, tabledir, True) insert_metadata_into_database(dburl, database, tablename, seg_name, firstsegno, tabledir, sizes) logger.info('Hawq Register Succeed.')
