hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iw...@apache.org
Subject incubator-hawq git commit: HAWQ-876. Add the support for initFile option (used by gpdiff.pl finally) in hawq googletest framework.
Date Wed, 29 Jun 2016 02:15:19 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master adf82292c -> 323fb6fd6


HAWQ-876. Add the support for initFile option (used by gpdiff.pl finally) in hawq googletest
framework.

	This patch also removes several annoying warnings.


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

Branch: refs/heads/master
Commit: 323fb6fd6aca838c821eb7280940526d7a8bdd4e
Parents: adf8229
Author: Paul Guo <paulguo@gmail.com>
Authored: Tue Jun 28 18:09:23 2016 +0800
Committer: ivan <iweng@pivotal.io>
Committed: Wed Jun 29 10:13:26 2016 +0800

----------------------------------------------------------------------
 src/test/feature/lib/hawq_config.cpp |  2 +-
 src/test/feature/lib/psql.cpp        | 13 +++++++++----
 src/test/feature/lib/psql.h          |  3 ++-
 src/test/feature/lib/sql_util.cpp    | 27 +++++++++++++++++++++++----
 src/test/feature/lib/sql_util.h      |  3 ++-
 5 files changed, 37 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/323fb6fd/src/test/feature/lib/hawq_config.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/lib/hawq_config.cpp b/src/test/feature/lib/hawq_config.cpp
index 287ca1b..94182f3 100644
--- a/src/test/feature/lib/hawq_config.cpp
+++ b/src/test/feature/lib/hawq_config.cpp
@@ -151,7 +151,7 @@ bool HawqConfig::isMultinodeMode() {
       psql.getQueryResult("select hostname from gp_segment_configuration");
   std::vector<std::vector<string> > table = result.getRows();
   std::unordered_set<string> hostnameMap;
-  for (int i = 0; i < table.size(); i++) {
+  for (unsigned int i = 0; i < table.size(); i++) {
     string hostname2 = table[i][0];
     if (hostname2 == "localhost") {
       char hostnamestr[256];

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/323fb6fd/src/test/feature/lib/psql.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/lib/psql.cpp b/src/test/feature/lib/psql.cpp
index ecdd925..88531da 100644
--- a/src/test/feature/lib/psql.cpp
+++ b/src/test/feature/lib/psql.cpp
@@ -40,7 +40,7 @@ const string& PSQLQueryResult::getData(int ri, int ci) const {
 }
 
 string PSQLQueryResult::getData(int ri, const string& ck) const {
-  for (int ci = 0; ci < this->_fields.size(); ci++) {
+  for (unsigned int ci = 0; ci < this->_fields.size(); ci++) {
     if (ck == this->_fields[ci]) {
       return this->getData(ri, ci);
     }
@@ -199,12 +199,17 @@ const string PSQL::_getPSQLFileCommand(const string& file) const
{
 
 bool PSQL::checkDiff(const string& expect_file,
                      const string& result_file,
-                     bool save_diff) {
+                     bool save_diff,
+                     const string& init_file) {
   string diff_file = result_file + ".diff";
   string command;
   command.append("gpdiff.pl ")
-      .append(PSQL_BASIC_DIFF_OPTS)
-      .append(" ")
+      .append(PSQL_BASIC_DIFF_OPTS);
+  if (!init_file.empty()) {
+      command.append(" -gpd_init ")
+      .append(init_file);
+  }
+  command.append(" ")
       .append(expect_file)
       .append(" ")
       .append(result_file)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/323fb6fd/src/test/feature/lib/psql.h
----------------------------------------------------------------------
diff --git a/src/test/feature/lib/psql.h b/src/test/feature/lib/psql.h
index 573b1a9..6363592 100644
--- a/src/test/feature/lib/psql.h
+++ b/src/test/feature/lib/psql.h
@@ -66,7 +66,8 @@ class PSQL {
 
   static bool checkDiff(const std::string& expect_file,
                         const std::string& result_file,
-                        bool save_diff = true);
+                        bool save_diff = true,
+                        const std::string& init_file = "");
 
   void resetOutput();
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/323fb6fd/src/test/feature/lib/sql_util.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/lib/sql_util.cpp b/src/test/feature/lib/sql_util.cpp
index 9537f0c..ea0c805 100644
--- a/src/test/feature/lib/sql_util.cpp
+++ b/src/test/feature/lib/sql_util.cpp
@@ -86,7 +86,10 @@ void SQLUtility::query(const string &sql, const string &expectStr)
{
 }
 
 void SQLUtility::execSQLFile(const string &sqlFile,
-                             const string &ansFile) {
+                             const string &ansFile,
+                             const string &initFile) {
+  FilePath fp;
+
   // do precheck for sqlFile & ansFile
   if (hawq::test::startsWith(sqlFile, "/") ||
       hawq::test::startsWith(ansFile, "/"))
@@ -95,7 +98,7 @@ void SQLUtility::execSQLFile(const string &sqlFile,
   string ansFileAbsPath = testRootPath + "/" + ansFile;
   if (!std::ifstream(ansFileAbsPath))
     ASSERT_TRUE(false) << ansFileAbsPath << " doesn't exist";
-  FilePath fp = splitFilePath(ansFileAbsPath);
+  fp = splitFilePath(ansFileAbsPath);
   // double check to avoid empty fileBaseName
   if (fp.fileBaseName.empty())
     ASSERT_TRUE(false) << ansFileAbsPath << " is invalid";
@@ -108,8 +111,24 @@ void SQLUtility::execSQLFile(const string &sqlFile,
   conn->setOutputFile(outFileAbsPath);
   EXPECT_EQ(0, conn->runSQLFile(newSqlFile).getLastStatus());
   conn->resetOutput();
-  EXPECT_FALSE(conn->checkDiff(ansFileAbsPath, outFileAbsPath, true));
-  if (conn->checkDiff(ansFileAbsPath, outFileAbsPath, true) == false) {
+
+  // initFile if any
+  string initFileAbsPath;
+  if (!initFile.empty()) {
+    initFileAbsPath = testRootPath + "/" + initFile;
+    if (!std::ifstream(initFileAbsPath))
+      ASSERT_TRUE(false) << initFileAbsPath << " doesn't exist";
+    fp = splitFilePath(initFileAbsPath);
+    // double check to avoid empty fileBaseName
+    if (fp.fileBaseName.empty())
+      ASSERT_TRUE(false) << initFileAbsPath << " is invalid";
+  } else {
+    initFileAbsPath = "";
+  }
+
+  bool is_sql_ans_diff = conn->checkDiff(ansFileAbsPath, outFileAbsPath, true, initFileAbsPath);
+  EXPECT_FALSE(is_sql_ans_diff);
+  if (is_sql_ans_diff == false) {
     // no diff, continue to delete the generated sql file
     if (remove(newSqlFile.c_str()))
       ASSERT_TRUE(false) << "Error deleting file " << newSqlFile;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/323fb6fd/src/test/feature/lib/sql_util.h
----------------------------------------------------------------------
diff --git a/src/test/feature/lib/sql_util.h b/src/test/feature/lib/sql_util.h
index 13ad2ec..768dfc9 100644
--- a/src/test/feature/lib/sql_util.h
+++ b/src/test/feature/lib/sql_util.h
@@ -53,8 +53,9 @@ class SQLUtility {
   // Execute sql file and diff with ans file
   // @param sqlFile The given sqlFile which is relative path to test root dir
   // @param ansFile The given ansFile which is relative path to test root dir
+  // @param initFile The given initFile (used by gpdiff.pl) which is relative path to test
root dir
   // @return void
-  void execSQLFile(const std::string &sqlFile, const std::string &ansFile);
+  void execSQLFile(const std::string &sqlFile, const std::string &ansFile, const
std::string &initFile = "");
 
   // Get PSQL connection: do not suggest to use
   // @return PSQL raw pointer


Mime
View raw message