hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xunzh...@apache.org
Subject [1/2] incubator-hawq git commit: HAWQ-1140. Parallelize test cases for hawqregister usage2.
Date Wed, 14 Dec 2016 10:57:56 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 6c295d016 -> 81d9de544


HAWQ-1140. Parallelize test cases for hawqregister usage2.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/49367ab9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/49367ab9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/49367ab9

Branch: refs/heads/master
Commit: 49367ab921ad3f32e590eb236cf3cb34bb3501bc
Parents: 6c295d0
Author: Chunling Wang <wangchunling14@126.com>
Authored: Mon Dec 12 16:56:58 2016 +0800
Committer: xunzhang <xunzhangthu@gmail.com>
Committed: Wed Dec 14 18:57:27 2016 +0800

----------------------------------------------------------------------
 .../feature/ManagementTool/test_hawq_register.h | 17 ++++--
 .../test_hawq_register_partition.cpp            | 59 +++++++++++---------
 .../test_hawq_register_rollback.cpp             |  6 +-
 .../test_hawq_register_usage2_case1.cpp         | 25 ++++++---
 .../test_hawq_register_usage2_case2.cpp         | 30 +++++-----
 tools/bin/hawqregister                          |  9 ++-
 6 files changed, 86 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/49367ab9/src/test/feature/ManagementTool/test_hawq_register.h
----------------------------------------------------------------------
diff --git a/src/test/feature/ManagementTool/test_hawq_register.h b/src/test/feature/ManagementTool/test_hawq_register.h
index c5f6658..252ceab 100644
--- a/src/test/feature/ManagementTool/test_hawq_register.h
+++ b/src/test/feature/ManagementTool/test_hawq_register.h
@@ -39,10 +39,17 @@ class TestHawqRegister : public ::testing::Test {
             return "";
         }
 
-        std::string getTableOid(std::string relname) {
+        std::string getTableOid(std::string relname, std::string nspname) {
+            std::string relnamespace = "2200";
+            const hawq::test::PSQLQueryResult &result_tmp = conn->getQueryResult(
+                hawq::test::stringFormat("SELECT oid from pg_namespace where nspname= \'%s\';",
nspname.c_str()));
+            std::vector<std::vector<std::string>> table = result_tmp.getRows();
+            if (table.size() > 0) {
+                relnamespace = table[0][0];
+            }
             const hawq::test::PSQLQueryResult &result = conn->getQueryResult(
-                hawq::test::stringFormat("SELECT oid from pg_class where relname = \'%s\';",
relname.c_str()));
-            std::vector<std::vector<std::string>> table = result.getRows();
+                hawq::test::stringFormat("SELECT oid from pg_class where relname = \'%s\'
and relnamespace=%s;", relname.c_str(), relnamespace.c_str()));
+            table = result.getRows();
             if (table.size() > 0) {
                 return table[0][0];
             }
@@ -61,8 +68,8 @@ class TestHawqRegister : public ::testing::Test {
             return size;
         }
 
-        void checkPgAOSegValue(std::string relname, std::string value, std::string fmt) {
-            std::string reloid = getTableOid(relname);
+        void checkPgAOSegValue(std::string relname, std::string nspname, std::string value,
std::string fmt) {
+            std::string reloid = getTableOid(relname, nspname);
 
             const hawq::test::PSQLQueryResult &result1 = conn->getQueryResult(
                 hawq::test::stringFormat("SELECT tupcount from pg_aoseg.pg_%s_%s;", fmt.c_str(),
reloid.c_str()));

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/49367ab9/src/test/feature/ManagementTool/test_hawq_register_partition.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/ManagementTool/test_hawq_register_partition.cpp b/src/test/feature/ManagementTool/test_hawq_register_partition.cpp
index 196f2c3..9551eca 100644
--- a/src/test/feature/ManagementTool/test_hawq_register_partition.cpp
+++ b/src/test/feature/ManagementTool/test_hawq_register_partition.cpp
@@ -36,10 +36,10 @@ void TestHawqRegister::runYamlCaseTableExistsPartition(std::string casename,
std
     hawq::test::FileReplace frep;
     std::unordered_map<std::string, std::string> strs_src_dst;
     strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-    strs_src_dst["@TABLE_OID@"]= getTableOid("t");
-    strs_src_dst["@TABLE_OID1@"]= getTableOid("t_1_prt_girls");
-    strs_src_dst["@TABLE_OID2@"]= getTableOid("t_1_prt_boys");
-    strs_src_dst["@TABLE_OID3@"]= getTableOid("t_1_prt_other");
+    strs_src_dst["@TABLE_OID@"]= getTableOid("t", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    strs_src_dst["@TABLE_OID1@"]= getTableOid("t_1_prt_girls", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    strs_src_dst["@TABLE_OID2@"]= getTableOid("t_1_prt_boys", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    strs_src_dst["@TABLE_OID3@"]= getTableOid("t_1_prt_other", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
     hawq::test::HdfsConfig hc;
     string hdfs_prefix;
     hc.getNamenodeHost(hdfs_prefix);
@@ -78,10 +78,10 @@ void TestHawqRegister::runYamlCaseTableNotExistsPartition(std::string
casename,
     hawq::test::FileReplace frep;
     std::unordered_map<std::string, std::string> strs_src_dst;
     strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-    strs_src_dst["@TABLE_OID@"]= getTableOid("t");
-    strs_src_dst["@TABLE_OID1@"]= getTableOid("t_1_prt_girls");
-    strs_src_dst["@TABLE_OID2@"]= getTableOid("t_1_prt_boys");
-    strs_src_dst["@TABLE_OID3@"]= getTableOid("t_1_prt_other");
+    strs_src_dst["@TABLE_OID@"]= getTableOid("t", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    strs_src_dst["@TABLE_OID1@"]= getTableOid("t_1_prt_girls", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    strs_src_dst["@TABLE_OID2@"]= getTableOid("t_1_prt_boys", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    strs_src_dst["@TABLE_OID3@"]= getTableOid("t_1_prt_other", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
     hawq::test::HdfsConfig hc;
     string hdfs_prefix;
     hc.getNamenodeHost(hdfs_prefix);
@@ -90,7 +90,14 @@ void TestHawqRegister::runYamlCaseTableNotExistsPartition(std::string casename,
     EXPECT_EQ(isexpectederror, Command::getCommandStatus(hawq::test::stringFormat("hawq register
-d %s -c %s testhawqregister_%s.nt", HAWQ_DB, t_yml.c_str(), casename.c_str())));
     if (isexpectederror > 0) {
         util.query("select * from t;", 100);
-        util.query("select * from pg_class where relname = 'nt';", 0);
+        std::string relnamespace = "2200";
+        const hawq::test::PSQLQueryResult &result_tmp = conn->getQueryResult(
+            hawq::test::stringFormat("SELECT oid from pg_namespace where nspname= \'testhawqregister_%s\';",
casename.c_str()));
+        std::vector<std::vector<std::string>> table = result_tmp.getRows();
+        if (table.size() > 0) {
+            relnamespace = table[0][0];
+        }
+        util.query(hawq::test::stringFormat("select * from pg_class where relnamespace =
%s and relname = 'nt';", relnamespace.c_str()), 0);
     } else {
         util.query("select * from nt;", checknum);
         util.execute("insert into nt select generate_series(1, 100), 1, 1, 'M', 1;");
@@ -113,9 +120,9 @@ void TestHawqRegister::runYamlCaseForceModePartition(std::string casename,
std::
     util.execute("CREATE TABLE nt (id int, rank int, year int, gender char(1), count int
) DISTRIBUTED BY (id) PARTITION BY LIST (gender) ( PARTITION girls VALUES ('F'), PARTITION
boys VALUES ('M'), DEFAULT PARTITION other );");
     util.execute("insert into nt select generate_series(1, 100), 1, 1, 'F', 1;");
     // get pg_aoseg.pg_xxxseg_xxx table
-    std::string reloid1_1_1 = getTableOid("nt_1_prt_girls");
-    std::string reloid1_2_1 = getTableOid("nt_1_prt_boys");
-    std::string reloid1_3_1 = getTableOid("nt_1_prt_other");
+    std::string reloid1_1_1 = getTableOid("nt_1_prt_girls", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    std::string reloid1_2_1 = getTableOid("nt_1_prt_boys", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    std::string reloid1_3_1 = getTableOid("nt_1_prt_other", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
     string result1_1_1 = util.getQueryResultSetString(hawq::test::stringFormat("select eof,
tupcount, varblockcount, eofuncompressed from pg_aoseg.pg_aoseg_%s order by segno;", reloid1_1_1.c_str()));
     string result1_2_1 = util.getQueryResultSetString(hawq::test::stringFormat("select eof,
tupcount, varblockcount, eofuncompressed from pg_aoseg.pg_aoseg_%s order by segno;", reloid1_2_1.c_str()));
     string result1_3_1 = util.getQueryResultSetString(hawq::test::stringFormat("select eof,
tupcount, varblockcount, eofuncompressed from pg_aoseg.pg_aoseg_%s order by segno;", reloid1_3_1.c_str()));
@@ -126,9 +133,9 @@ void TestHawqRegister::runYamlCaseForceModePartition(std::string casename,
std::
     util.execute("CREATE TABLE t (id int, rank int, year int, gender char(1), count int )
DISTRIBUTED BY (id) PARTITION BY LIST (gender) ( PARTITION girls VALUES ('F'), PARTITION boys
VALUES ('M'), DEFAULT PARTITION other );");
     util.execute(hawq::test::stringFormat("insert into t select generate_series(1, %s), 1,
1, 'F', 1;", std::to_string(rows).c_str()));
     // get pg_aoseg.pg_xxxseg_xxx table
-    std::string reloid1_1_2 = getTableOid("t_1_prt_girls");
-    std::string reloid1_2_2 = getTableOid("t_1_prt_boys");
-    std::string reloid1_3_2 = getTableOid("t_1_prt_other");
+    std::string reloid1_1_2 = getTableOid("t_1_prt_girls", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    std::string reloid1_2_2 = getTableOid("t_1_prt_boys", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    std::string reloid1_3_2 = getTableOid("t_1_prt_other", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
     string result1_1_2 = util.getQueryResultSetString(hawq::test::stringFormat("select eof,
tupcount, varblockcount, eofuncompressed from pg_aoseg.pg_aoseg_%s order by segno;", reloid1_1_2.c_str()));
     string result1_2_2 = util.getQueryResultSetString(hawq::test::stringFormat("select eof,
tupcount, varblockcount, eofuncompressed from pg_aoseg.pg_aoseg_%s order by segno;", reloid1_2_2.c_str()));
     string result1_3_2 = util.getQueryResultSetString(hawq::test::stringFormat("select eof,
tupcount, varblockcount, eofuncompressed from pg_aoseg.pg_aoseg_%s order by segno;", reloid1_3_2.c_str()));
@@ -136,14 +143,14 @@ void TestHawqRegister::runYamlCaseForceModePartition(std::string casename,
std::
     hawq::test::FileReplace frep;
     std::unordered_map<std::string, std::string> strs_src_dst;
     strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-    strs_src_dst["@TABLE_OID_OLD@"]= getTableOid("nt");
-    strs_src_dst["@TABLE_OID_NEW@"]= getTableOid("t");
-    strs_src_dst["@TABLE_OID_OLD1@"]= getTableOid("nt_1_prt_girls");
-    strs_src_dst["@TABLE_OID_OLD2@"]= getTableOid("nt_1_prt_boys");
-    strs_src_dst["@TABLE_OID_OLD3@"]= getTableOid("nt_1_prt_other");
-    strs_src_dst["@TABLE_OID_NEW1@"]= getTableOid("t_1_prt_girls");
-    strs_src_dst["@TABLE_OID_NEW2@"]= getTableOid("t_1_prt_boys");
-    strs_src_dst["@TABLE_OID_NEW3@"]= getTableOid("t_1_prt_other");
+    strs_src_dst["@TABLE_OID_OLD@"]= getTableOid("nt", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    strs_src_dst["@TABLE_OID_NEW@"]= getTableOid("t", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    strs_src_dst["@TABLE_OID_OLD1@"]= getTableOid("nt_1_prt_girls", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    strs_src_dst["@TABLE_OID_OLD2@"]= getTableOid("nt_1_prt_boys", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    strs_src_dst["@TABLE_OID_OLD3@"]= getTableOid("nt_1_prt_other", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    strs_src_dst["@TABLE_OID_NEW1@"]= getTableOid("t_1_prt_girls", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    strs_src_dst["@TABLE_OID_NEW2@"]= getTableOid("t_1_prt_boys", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    strs_src_dst["@TABLE_OID_NEW3@"]= getTableOid("t_1_prt_other", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
     string hdfs_prefix;
     hawq::test::HdfsConfig hc;
     hc.getNamenodeHost(hdfs_prefix);
@@ -154,9 +161,9 @@ void TestHawqRegister::runYamlCaseForceModePartition(std::string casename,
std::
     util.query("select * from nt;", checknum);
 
     // check pg_aoseg.pg_xxxseg_xxx table
-    std::string reloid2_1 = getTableOid("nt_1_prt_girls");
-    std::string reloid2_2 = getTableOid("nt_1_prt_boys");
-    std::string reloid2_3 = getTableOid("nt_1_prt_other");
+    std::string reloid2_1 = getTableOid("nt_1_prt_girls", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    std::string reloid2_2 = getTableOid("nt_1_prt_boys", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    std::string reloid2_3 = getTableOid("nt_1_prt_other", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
     string result2_1 = util.getQueryResultSetString(hawq::test::stringFormat("select eof,
tupcount, varblockcount, eofuncompressed from pg_aoseg.pg_aoseg_%s order by segno;", reloid2_1.c_str()));
     string result2_2 = util.getQueryResultSetString(hawq::test::stringFormat("select eof,
tupcount, varblockcount, eofuncompressed from pg_aoseg.pg_aoseg_%s order by segno;", reloid2_2.c_str()));
     string result2_3 = util.getQueryResultSetString(hawq::test::stringFormat("select eof,
tupcount, varblockcount, eofuncompressed from pg_aoseg.pg_aoseg_%s order by segno;", reloid2_3.c_str()));

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/49367ab9/src/test/feature/ManagementTool/test_hawq_register_rollback.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/ManagementTool/test_hawq_register_rollback.cpp b/src/test/feature/ManagementTool/test_hawq_register_rollback.cpp
index 2f842bc..110ca83 100644
--- a/src/test/feature/ManagementTool/test_hawq_register_rollback.cpp
+++ b/src/test/feature/ManagementTool/test_hawq_register_rollback.cpp
@@ -31,7 +31,7 @@ TEST_F(TestHawqRegister, TestRollbackErrorSchema) {
     hawq::test::FileReplace frep;
     std::unordered_map<std::string, std::string> strs_src_dst;
     strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-    strs_src_dst["@TABLE_OID@"]= getTableOid("t");
+    strs_src_dst["@TABLE_OID@"]= getTableOid("t", "testhawqregister_testrollbackerrorschema");
     string hdfs_prefix;
     hawq::test::HdfsConfig hc;
     hc.getNamenodeHost(hdfs_prefix);
@@ -63,7 +63,7 @@ TEST_F(TestHawqRegister, TestRollbackErrorHDFSFileSize) {
     hawq::test::FileReplace frep;
     std::unordered_map<std::string, std::string> strs_src_dst;
     strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-    strs_src_dst["@TABLE_OID@"]= getTableOid("t");
+    strs_src_dst["@TABLE_OID@"]= getTableOid("t", "testhawqregister_testrollbackerrorhdfsfilesize");
     string hdfs_prefix;
     hawq::test::HdfsConfig hc;
     hc.getNamenodeHost(hdfs_prefix);
@@ -95,7 +95,7 @@ TEST_F(TestHawqRegister, TestRollBackHDFSFilePathContainErrorSymbol) {
     hawq::test::FileReplace frep;
     std::unordered_map<std::string, std::string> strs_src_dst;
     strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-    strs_src_dst["@TABLE_OID@"]= getTableOid("t");
+    strs_src_dst["@TABLE_OID@"]= getTableOid("t", "testhawqregister_testrollbackhdfsfilepathcontainerrorsymbol");
     string hdfs_prefix;
     hawq::test::HdfsConfig hc;
     hc.getNamenodeHost(hdfs_prefix);

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/49367ab9/src/test/feature/ManagementTool/test_hawq_register_usage2_case1.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/ManagementTool/test_hawq_register_usage2_case1.cpp b/src/test/feature/ManagementTool/test_hawq_register_usage2_case1.cpp
index c599f7c..da44cc8 100644
--- a/src/test/feature/ManagementTool/test_hawq_register_usage2_case1.cpp
+++ b/src/test/feature/ManagementTool/test_hawq_register_usage2_case1.cpp
@@ -21,7 +21,7 @@ TEST_F(TestHawqRegister, TestUsage2Case1EmptyTable) {
     EXPECT_EQ(0, Command::getCommandStatus("hawq extract -d " + (string) HAWQ_DB + " -o t9.yml
testhawqregister_testusage2case1emptytable.t9"));
     EXPECT_EQ(0, Command::getCommandStatus("hawq register -d " + (string) HAWQ_DB + " -c
t9.yml testhawqregister_testusage2case1emptytable.nt9"));
     util.query("select * from nt9;", 0);
-    std::string reloid = getTableOid("nt9");
+    std::string reloid = getTableOid("nt9", "testhawqregister_testusage2case1emptytable");
     /* An empty table has no row in pg_aoseg.pg_aoseg_xxx table */
     util.query(hawq::test::stringFormat("select * from pg_aoseg.pg_aoseg_%s;", reloid.c_str()),
0);
     EXPECT_EQ(0, Command::getCommandStatus("rm -rf t9.yml"));
@@ -76,7 +76,7 @@ TEST_F(TestHawqRegister, TestUsage2Case1Expected) {
             util.query(hawq::test::stringFormat("select * from %s;", t.c_str()), 100);
 
             // get pg_aoseg.pg_xxxseg_xxx table
-            std::string reloid1 = getTableOid(t.c_str());
+            std::string reloid1 = getTableOid(t.c_str(), "testhawqregister_testusage2case1expected");
             string result1 = util.getQueryResultSetString(hawq::test::stringFormat("select
* from pg_aoseg.pg_%s_%s order by segno;", fmt_prefix.c_str(), reloid1.c_str()));
 
             EXPECT_EQ(0, Command::getCommandStatus(hawq::test::stringFormat("hawq extract
-d %s -o t_%s.yml testhawqregister_testusage2case1expected.%s", HAWQ_DB, std::to_string(suffix).c_str(),
t.c_str())));
@@ -84,7 +84,7 @@ TEST_F(TestHawqRegister, TestUsage2Case1Expected) {
             util.query(hawq::test::stringFormat("select * from %s;", nt.c_str()), 100);
 
             // check pg_aoseg.pg_xxxseg_xxx table
-            std::string reloid2 = getTableOid(nt.c_str());
+            std::string reloid2 = getTableOid(nt.c_str(), "testhawqregister_testusage2case1expected");
             string result2 = util.getQueryResultSetString(hawq::test::stringFormat("select
* from pg_aoseg.pg_%s_%s order by segno;", fmt_prefix.c_str(), reloid2.c_str()));
             EXPECT_EQ(result1, result2);
 
@@ -121,12 +121,14 @@ void TestHawqRegister::runYamlCaseTableExists(std::string casename,
std::string
     hawq::test::FileReplace frep;
     std::unordered_map<std::string, std::string> strs_src_dst;
     strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-    strs_src_dst["@TABLE_OID@"]= getTableOid("t");
+    strs_src_dst["@TABLE_OID@"]= getTableOid("t", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
     hawq::test::HdfsConfig hc;
     string hdfs_prefix;
     hc.getNamenodeHost(hdfs_prefix);
     strs_src_dst["@PORT@"]= hdfs_prefix;
     frep.replace(t_yml_tpl, t_yml, strs_src_dst);
+    //printf("%s\n", hawq::test::stringFormat("hawq register -d %s -c %s testhawqregister_%s.nt",
HAWQ_DB, t_yml.c_str(), casename.c_str()).c_str());
+    //sleep(60);
     EXPECT_EQ(isexpectederror, Command::getCommandStatus(hawq::test::stringFormat("hawq register
-d %s -c %s testhawqregister_%s.nt", HAWQ_DB, t_yml.c_str(), casename.c_str())));
     if (isexpectederror > 0) {
         util.query("select * from t;", 100);
@@ -154,7 +156,7 @@ void TestHawqRegister::runYamlCaseTableNotExists(std::string casename,
std::stri
     hawq::test::FileReplace frep;
     std::unordered_map<std::string, std::string> strs_src_dst;
     strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-    strs_src_dst["@TABLE_OID@"]= getTableOid("t");
+    strs_src_dst["@TABLE_OID@"]= getTableOid("t", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
     hawq::test::HdfsConfig hc;
     string hdfs_prefix;
     hc.getNamenodeHost(hdfs_prefix);
@@ -163,7 +165,14 @@ void TestHawqRegister::runYamlCaseTableNotExists(std::string casename,
std::stri
     EXPECT_EQ(isexpectederror, Command::getCommandStatus(hawq::test::stringFormat("hawq register
-d %s -c %s testhawqregister_%s.nt", HAWQ_DB, t_yml.c_str(), casename.c_str())));
     if (isexpectederror > 0) {
         util.query("select * from t;", 100);
-        util.query("select * from pg_class where relname = 'nt';", 0);
+        std::string relnamespace = "2200";
+        const hawq::test::PSQLQueryResult &result_tmp = conn->getQueryResult(
+            hawq::test::stringFormat("SELECT oid from pg_namespace where nspname= \'testhawqregister_%s\';",
casename.c_str()));
+        std::vector<std::vector<std::string>> table = result_tmp.getRows();
+        if (table.size() > 0) {
+            relnamespace = table[0][0];
+        }
+        util.query(hawq::test::stringFormat("select * from pg_class where relnamespace =
%s and relname = 'nt';", relnamespace.c_str()), 0);
     } else {
         util.query("select * from nt;", checknum);
     }
@@ -279,7 +288,7 @@ TEST_F(TestHawqRegister, DISABLED_TestUsage2Case1ErrorBlockSize) {
     hawq::test::FileReplace frep;
     std::unordered_map<std::string, std::string> strs_src_dst;
     strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-    strs_src_dst["@TABLE_OID@"]= getTableOid("t");
+    strs_src_dst["@TABLE_OID@"]= getTableOid("t", "testhawqregister_testusage2case1errorblocksize");
     string hdfs_prefix;
     hawq::test::HdfsConfig hc;
     hc.getNamenodeHost(hdfs_prefix);
@@ -340,7 +349,7 @@ TEST_F(TestHawqRegister, TestUsage2Case1FileUnderTableDirectory) {
     hawq::test::FileReplace frep;
     std::unordered_map<std::string, std::string> strs_src_dst;
     strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-    strs_src_dst["@TABLE_OID@"]= getTableOid("t");
+    strs_src_dst["@TABLE_OID@"]= getTableOid("t", "testhawqregister_testusage2case1fileUndertabledirectory");
     hawq::test::HdfsConfig hc;
     string hdfs_prefix;
     hc.getNamenodeHost(hdfs_prefix);

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/49367ab9/src/test/feature/ManagementTool/test_hawq_register_usage2_case2.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/ManagementTool/test_hawq_register_usage2_case2.cpp b/src/test/feature/ManagementTool/test_hawq_register_usage2_case2.cpp
index 14ea48e..16df829 100644
--- a/src/test/feature/ManagementTool/test_hawq_register_usage2_case2.cpp
+++ b/src/test/feature/ManagementTool/test_hawq_register_usage2_case2.cpp
@@ -44,7 +44,7 @@ TEST_F(TestHawqRegister, TestUsage2Case2Expected) {
                 hawq::test::FileReplace frep;
                 std::unordered_map<std::string, std::string> strs_src_dst;
                 strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-                strs_src_dst["@TABLE_OID@"]= getTableOid(t);
+                strs_src_dst["@TABLE_OID@"]= getTableOid(t, "testhawqregister_testusage2case2expected");
                 string hdfs_prefix;
                 hawq::test::HdfsConfig hc;
                 hc.getNamenodeHost(hdfs_prefix);
@@ -59,17 +59,17 @@ TEST_F(TestHawqRegister, TestUsage2Case2Expected) {
                 util.execute(hawq::test::stringFormat("insert into %s select generate_series(1,
50);", t.c_str()));
                 util.query(hawq::test::stringFormat("select * from %s;", t.c_str()), 50);
                 strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-                strs_src_dst["@TABLE_OID_OLD@"]= getTableOid(nt);
-                strs_src_dst["@TABLE_OID_NEW@"]= getTableOid(t);
+                strs_src_dst["@TABLE_OID_OLD@"]= getTableOid(nt, "testhawqregister_testusage2case2expected");
+                strs_src_dst["@TABLE_OID_NEW@"]= getTableOid(t, "testhawqregister_testusage2case2expected");
                 strs_src_dst["@PORT@"]= hdfs_prefix;
                 frep.replace(t_yml_tpl_new, t_yml_new, strs_src_dst);
                 EXPECT_EQ(0, Command::getCommandStatus(hawq::test::stringFormat("hawq register
%s -d %s -c %s testhawqregister_testusage2case2expected.%s", opt.c_str(), HAWQ_DB, t_yml_new.c_str(),
nt.c_str())));
                 util.query(hawq::test::stringFormat("select * from %s;", nt.c_str()), 150);
 
                 if (fmt == "row")
-                   checkPgAOSegValue(nt, "-1", "aoseg");
+                   checkPgAOSegValue(nt, "testhawqregister_testusage2case2expected", "-1",
"aoseg");
                 else 
-                   checkPgAOSegValue(nt, "-1", "paqseg");
+                   checkPgAOSegValue(nt, "testhawqregister_testusage2case2expected", "-1",
"paqseg");
                 
                 EXPECT_EQ(0, Command::getCommandStatus(hawq::test::stringFormat("rm -rf %s",
t_yml.c_str())));
                 EXPECT_EQ(0, Command::getCommandStatus(hawq::test::stringFormat("rm -rf %s",
t_yml_new.c_str())));
@@ -100,8 +100,8 @@ void TestHawqRegister::runYamlCaseForceMode(std::string casename, std::string
ym
     hawq::test::FileReplace frep;
     std::unordered_map<std::string, std::string> strs_src_dst;
     strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-    strs_src_dst["@TABLE_OID_OLD@"]= getTableOid("nt");
-    strs_src_dst["@TABLE_OID_NEW@"]= getTableOid("t");
+    strs_src_dst["@TABLE_OID_OLD@"]= getTableOid("nt", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
+    strs_src_dst["@TABLE_OID_NEW@"]= getTableOid("t", hawq::test::stringFormat("testhawqregister_%s",
casename.c_str()));
     string hdfs_prefix;
     hawq::test::HdfsConfig hc;
     hc.getNamenodeHost(hdfs_prefix);
@@ -143,8 +143,8 @@ TEST_F(TestHawqRegister, TestUsage2Case2Hash2Random) {
     hawq::test::FileReplace frep;
     std::unordered_map<std::string, std::string> strs_src_dst;
     strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-    strs_src_dst["@TABLE_OID_OLD@"]= getTableOid("nt");
-    strs_src_dst["@TABLE_OID_NEW@"]= getTableOid("t");
+    strs_src_dst["@TABLE_OID_OLD@"]= getTableOid("nt", "testhawqregister_testusage2case2hash2random");
+    strs_src_dst["@TABLE_OID_NEW@"]= getTableOid("t", "testhawqregister_testusage2case2hash2random");
     string hdfs_prefix;
     hawq::test::HdfsConfig hc;
     hc.getNamenodeHost(hdfs_prefix);
@@ -178,8 +178,8 @@ TEST_F(TestHawqRegister, TestUsage2Case2Random2Hash) {
     hawq::test::FileReplace frep;
     std::unordered_map<std::string, std::string> strs_src_dst;
     strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-    strs_src_dst["@TABLE_OID_OLD@"]= getTableOid("nt");
-    strs_src_dst["@TABLE_OID_NEW@"]= getTableOid("t");
+    strs_src_dst["@TABLE_OID_OLD@"]= getTableOid("nt", "testhawqregister_testusage2case2random2hash");
+    strs_src_dst["@TABLE_OID_NEW@"]= getTableOid("t", "testhawqregister_testusage2case2random2hash");
     string hdfs_prefix;
     hawq::test::HdfsConfig hc;
     hc.getNamenodeHost(hdfs_prefix);
@@ -208,7 +208,7 @@ TEST_F(TestHawqRegister, TestUsage2Case2TableNotExist) {
     hawq::test::FileReplace frep;
     std::unordered_map<std::string, std::string> strs_src_dst;
     strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-    strs_src_dst["@TABLE_OID_NEW@"]= getTableOid("t");
+    strs_src_dst["@TABLE_OID_NEW@"]= getTableOid("t", "testhawqregister_testusage2case2tablenotexist");
     string hdfs_prefix;
     hawq::test::HdfsConfig hc;
     hc.getNamenodeHost(hdfs_prefix);
@@ -237,7 +237,7 @@ TEST_F(TestHawqRegister, TestUsage2Case2TableExistNoData) {
     hawq::test::FileReplace frep;
     std::unordered_map<std::string, std::string> strs_src_dst;
     strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-    strs_src_dst["@TABLE_OID_NEW@"]= getTableOid("t");
+    strs_src_dst["@TABLE_OID_NEW@"]= getTableOid("t", "testhawqregister_testusage2case2tableexistnodata");
     util.execute("create table nt(i int) with (appendonly=true, orientation=parquet) distributed
by (i);");
     string hdfs_prefix;
     hawq::test::HdfsConfig hc;
@@ -328,8 +328,8 @@ TEST_F(TestHawqRegister, DISABLED_TestUsage2Case2ErrorBlockSize) {
     hawq::test::FileReplace frep;
     std::unordered_map<std::string, std::string> strs_src_dst;
     strs_src_dst["@DATABASE_OID@"]= getDatabaseOid();
-    strs_src_dst["@TABLE_OID_OLD@"]= getTableOid("nt");
-    strs_src_dst["@TABLE_OID_NEW@"]= getTableOid("t");
+    strs_src_dst["@TABLE_OID_OLD@"]= getTableOid("nt", "testhawqregister_testusage2case2errorblocksize");
+    strs_src_dst["@TABLE_OID_NEW@"]= getTableOid("t", "testhawqregister_testusage2case2errorblocksize");
     string hdfs_prefix;
     hawq::test::HdfsConfig hc;
     hc.getNamenodeHost(hdfs_prefix);

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/49367ab9/tools/bin/hawqregister
----------------------------------------------------------------------
diff --git a/tools/bin/hawqregister b/tools/bin/hawqregister
index 7ec14a1..7240c1d 100755
--- a/tools/bin/hawqregister
+++ b/tools/bin/hawqregister
@@ -358,15 +358,15 @@ class GpRegisterAccessor(object):
         return self.exec_query(query)[0]['pg_encoding_to_char']
 
     def get_metadata_for_relfile_insert(self, database, tablename):
-        _, tablename = tablename_handler(tablename)
-        query = "select reltablespace from pg_class where relname = '%s';" % tablename
+        schemaname, tablename = tablename_handler(tablename)
+        query = "select reltablespace from pg_class where relnamespace = '%s' and relname
= '%s';" % (self.get_schema_id(schemaname), tablename)
         tablespace_oid = int(self.exec_query(query)[0]['reltablespace'])
         if tablespace_oid == 0:
             query = "select oid from pg_tablespace where spcname='dfs_default';"
             tablespace_oid = int(self.exec_query(query)[0]['oid'])
         query = "select oid from pg_database where datname='%s';" % database
         database_oid = int(self.exec_query(query)[0]['oid'])
-        query = "select oid, relfilenode, relname, relkind, relstorage, relam from pg_class
where relname='%s';" % tablename
+        query = "select oid, relfilenode, relname, relkind, relstorage, relam from pg_class
where relnamespace = '%s' and relname='%s';" % (self.get_schema_id(schemaname), tablename)
         return [tablespace_oid, database_oid, int(self.exec_query(query)[0]['oid']), int(self.exec_query(query)[0]['relfilenode']),
str(self.exec_query(query)[0]['relname']), str(self.exec_query(query)[0]['relkind']), str(self.exec_query(query)[0]['relstorage']),
int(self.exec_query(query)[0]['relam'])]
 
     def update_catalog(self, query):
@@ -492,6 +492,7 @@ class HawqRegister(object):
                 params = yaml.load(f)
         except yaml.scanner.ScannerError as e:
             print e
+            logger.error('In _option_parser_yml(): %s' % e)
             self.failure_handler.rollback()
             sys.exit(1)
             
@@ -671,6 +672,7 @@ class HawqRegister(object):
 
         (self.seg_name, tmp_ret) = self._get_seg_name()
         if not tmp_ret:
+            logger.error('Failed to get segment name')
             self.failure_handler.rollback()
             sys.exit(1)
         self.firstsegno, self.tabledir = self._get_metadata()
@@ -984,6 +986,7 @@ class HawqRegister(object):
             self.utility_accessor.update_catalog(self.queries)
         except pg.DatabaseError as e:
             print e
+            logger.error('In _modify_metadata(): %s' % e);
             self.failure_handler.rollback()
             sys.exit(1)
 


Mime
View raw message