hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [1/2] incubator-hawq git commit: HAWQ-768. Refactor c++ code for src/test/feature/lib.
Date Thu, 02 Jun 2016 02:05:22 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 2b33d9310 -> ec098032e


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ec098032/src/test/feature/lib/xml-parser.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/lib/xml-parser.cpp b/src/test/feature/lib/xml-parser.cpp
deleted file mode 100644
index 69fdd44..0000000
--- a/src/test/feature/lib/xml-parser.cpp
+++ /dev/null
@@ -1,267 +0,0 @@
-#include "xml-parser.h"
-
-#include <limits>
-#include <unistd.h>
-
-XmlConfig::XmlConfig(const char *p) :
-    path(p) {
-  parse();
-}
-
-void XmlConfig::parse() {
-  // the result document tree
-  xmlDocPtr doc;
-  LIBXML_TEST_VERSION kv
-  .clear();
-
-  if (access(path.c_str(), R_OK)) {
-    return;
-  }
-
-  // parse the file
-  doc = xmlReadFile(path.c_str(), nullptr, 0);
-  if (doc == nullptr) {
-    return;
-  }
-  try {
-    // printf("ffff3\n");
-    readConfigItems(doc);
-    // printf("ffff4\n");
-    xmlFreeDoc(doc);
-  } catch (...) {
-    xmlFreeDoc(doc);
-    // LOG_ERROR(ERRCODE_INTERNAL_ERROR, "libxml internal error");
-  }
-}
-
-void XmlConfig::readConfigItems(xmlDocPtr doc) {
-  xmlNodePtr root, curNode;
-  root = xmlDocGetRootElement(doc);
-  if (root == nullptr || strcmp((const char *) root->name, "configuration")) {
-    return ;
-  }
-
-  // for each property
-
-  for (curNode = root->children; curNode != nullptr; curNode = curNode->next) {
-    if (curNode->type != XML_ELEMENT_NODE) {
-      continue;
-    }
-
-    if (strcmp((const char *) curNode->name, "property")) {
-      return;
-    }
-
-    readConfigItem(curNode->children);
-  }
-}
-
-void XmlConfig::readConfigItem(xmlNodePtr root) {
-  std::string key, value, scope;
-  xmlNodePtr curNode;
-  bool hasName = false, hasValue = false, hasScope = false;
-  for (curNode = root; curNode != nullptr; curNode = curNode->next) {
-    if (curNode->type != XML_ELEMENT_NODE) {
-      continue;
-    }
-
-    if (!hasName && !strcmp((const char *) curNode->name, "name")) {
-      if (curNode->children != nullptr
-          && XML_TEXT_NODE == curNode->children->type) {
-        key = (const char *) curNode->children->content;
-        hasName = true;
-      }
-    } else if (!hasValue && !strcmp((const char *) curNode->name, "value")) {
-      if (curNode->children != nullptr
-          && XML_TEXT_NODE == curNode->children->type) {
-        value = (const char *) curNode->children->content;
-        hasValue = true;
-      }
-    } else {
-      continue;
-    }
-  }
-
-  if (hasName && hasValue) {
-    kv[key] = value;
-    return;
-  } else if (hasName && hasValue) {
-    return;
-  } else if (hasName && hasScope) {
-    return;
-  } else if (hasName) {
-    return;
-  }
-}
-
-const char *XmlConfig::getString(const char *key) {
-  XmlConfigMapIterator it = kv.find(key);
-
-  if (kv.end() == it) {
-    return "";
-  }
-
-  return it->second.c_str();
-}
-
-const char *XmlConfig::getString(const char *key, const char *def) {
-  XmlConfigMapIterator it = kv.find(key);
-
-  if (kv.end() == it) {
-    return def;
-  } else {
-    return it->second.c_str();
-  }
-}
-
-const char *XmlConfig::getString(const std::string &key) {
-  return getString(key.c_str());
-}
-
-const char *XmlConfig::getString(const std::string &key,
-    const std::string &def) {
-  return getString(key.c_str(), def.c_str());
-}
-
-int64_t XmlConfig::getInt64(const char *key) {
-  int64_t retval;
-  XmlConfigMapIterator it = kv.find(key);
-
-  if (kv.end() == it) {
-    return 0;
-  }
-
-  retval = strToInt64(it->second.c_str());
-
-  return retval;
-}
-
-int64_t XmlConfig::getInt64(const char *key, int64_t def) {
-  int64_t retval;
-  XmlConfigMapIterator it = kv.find(key);
-
-  if (kv.end() == it) {
-    return def;
-  }
-
-  retval = strToInt64(it->second.c_str());
-
-  return retval;
-}
-
-int32_t XmlConfig::getInt32(const char *key) {
-  int32_t retval;
-  XmlConfigMapIterator it = kv.find(key);
-
-  if (kv.end() == it) {
-    return 0;
-  }
-
-  retval = strToInt32(it->second.c_str());
-
-  return retval;
-}
-
-int32_t XmlConfig::getInt32(const char *key, int32_t def) {
-  int32_t retval;
-  XmlConfigMapIterator it = kv.find(key);
-
-  if (kv.end() == it) {
-    return def;
-  }
-
-  retval = strToInt32(it->second.c_str());
-
-  return retval;
-}
-
-double XmlConfig::getDouble(const char *key) {
-  double retval;
-  XmlConfigMapIterator it = kv.find(key);
-
-  if (kv.end() == it) {
-    return 0.0;
-  }
-
-  retval = strToDouble(it->second.c_str());
-
-  return retval;
-}
-
-double XmlConfig::getDouble(const char *key, double def) {
-  double retval;
-  XmlConfigMapIterator it = kv.find(key);
-
-  if (kv.end() == it) {
-    return def;
-  }
-
-  retval = strToDouble(it->second.c_str());
-
-  return retval;
-}
-
-bool XmlConfig::getBool(const char *key) {
-  bool retval;
-  XmlConfigMapIterator it = kv.find(key);
-
-  if (kv.end() == it) {
-      return false;
-  }
-
-  retval = strToBool(it->second.c_str());
-
-  return retval;
-}
-
-bool XmlConfig::getBool(const char *key, bool def) {
-  bool retval;
-  XmlConfigMapIterator it = kv.find(key);
-
-  if (kv.end() == it) {
-    return def;
-  }
-
-  retval = strToBool(it->second.c_str());
-
-  return retval;
-}
-
-int64_t XmlConfig::strToInt64(const char *str) {
-  int64_t retval;
-  char *end = nullptr;
-
-  retval = strtoll(str, &end, 0);
-
-  return retval;
-}
-
-int32_t XmlConfig::strToInt32(const char *str) {
-  int32_t retval;
-  char *end = nullptr;
-  retval = strtoll(str, &end, 0);
-
-  return retval;
-}
-
-bool XmlConfig::strToBool(const char *str) {
-  bool retval = false;
-
-  if (!strcasecmp(str, "true") || !strcmp(str, "1")) {
-    retval = true;
-  } else if (!strcasecmp(str, "false") || !strcmp(str, "0")) {
-    retval = false;
-  } else {
-    return false;
-  }
-
-  return retval;
-}
-
-double XmlConfig::strToDouble(const char *str) {
-  double retval;
-  char *end = nullptr;
-  retval = strtod(str, &end);
-
-  return retval;
-}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ec098032/src/test/feature/lib/xml-parser.h
----------------------------------------------------------------------
diff --git a/src/test/feature/lib/xml-parser.h b/src/test/feature/lib/xml-parser.h
deleted file mode 100644
index 36a2a63..0000000
--- a/src/test/feature/lib/xml-parser.h
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef SRC_TEST_FEATURE_LIB_XML_PARSER_H_
-#define SRC_TEST_FEATURE_LIB_XML_PARSER_H_
-
-
-#include <cstring>
-#include <string>
-#include <unordered_map>
-
-#include "libxml/parser.h"
-
-typedef std::unordered_map<std::string, std::string> XmlConfigMap;
-typedef std::unordered_map<std::string, std::string>::const_iterator
-    XmlConfigMapIterator;
-
-class XmlConfig {
- public:
-  explicit XmlConfig(const char *p);
-
-  // parse the configuration file
-  void parse();
-
-  // @param key The key of the configuration item
-  // @ def The default value
-  // @ return The value of configuration item
-  const char *getString(const char *key);
-
-  const char *getString(const char *key, const char *def);
-
-  const char *getString(const std::string &key);
-
-  const char *getString(const std::string &key, const std::string &def);
-
-  int64_t getInt64(const char *key);
-
-  int64_t getInt64(const char *key, int64_t def);
-
-  int32_t getInt32(const char *key);
-
-  int32_t getInt32(const char *key, int32_t def);
-
-  double getDouble(const char *key);
-
-  double getDouble(const char *key, double def);
-
-  bool getBool(const char *key);
-
-  bool getBool(const char *key, bool def);
-
-  XmlConfigMap *getConfigMap() { return &kv; }
-
- private:
-  std::string path;
-  XmlConfigMap kv;  // key2Value
-
-  void readConfigItems(xmlDocPtr doc);
-  void readConfigItem(xmlNodePtr root);
-  int64_t strToInt64(const char *str);
-  int32_t strToInt32(const char *str);
-  bool strToBool(const char *str);
-  double strToDouble(const char *str);
-};
-
-
-#endif /* SRC_TEST_FEATURE_LIB_XML_PARSER_H_ */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ec098032/src/test/feature/lib/xml_parser.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/lib/xml_parser.cpp b/src/test/feature/lib/xml_parser.cpp
new file mode 100644
index 0000000..bd1edd0
--- /dev/null
+++ b/src/test/feature/lib/xml_parser.cpp
@@ -0,0 +1,234 @@
+#include <unistd.h>
+#include <cstring>
+#include <string>
+#include <limits>
+#include "xml_parser.h"
+
+using std::string;
+
+namespace hawq {
+namespace test {
+
+XmlConfig::XmlConfig(string p) :
+    path(p) {
+  parse();
+}
+
+void XmlConfig::parse() {
+  // the result document tree
+  xmlDocPtr doc;
+  LIBXML_TEST_VERSION kv
+  .clear();
+
+  if (access(path.c_str(), R_OK)) {
+    return;
+  }
+
+  // parse the file
+  doc = xmlReadFile(path.c_str(), nullptr, 0);
+  if (doc == nullptr) {
+    return;
+  }
+  try {
+    readConfigItems(doc);
+    xmlFreeDoc(doc);
+  } catch (...) {
+    xmlFreeDoc(doc);
+  }
+}
+
+void XmlConfig::readConfigItems(xmlDocPtr doc) {
+  xmlNodePtr root, curNode;
+  root = xmlDocGetRootElement(doc);
+  if (root == nullptr || strcmp((const char *) root->name, "configuration")) {
+    return ;
+  }
+  // for each property
+  for (curNode = root->children; curNode != nullptr; curNode = curNode->next) {
+    if (curNode->type != XML_ELEMENT_NODE) {
+      continue;
+    }
+    if (strcmp((const char *) curNode->name, "property")) {
+      return;
+    }
+    readConfigItem(curNode->children);
+  }
+}
+
+void XmlConfig::readConfigItem(xmlNodePtr root) {
+  string key, value, scope;
+  xmlNodePtr curNode;
+  bool hasName = false, hasValue = false, hasScope = false;
+  for (curNode = root; curNode != nullptr; curNode = curNode->next) {
+    if (curNode->type != XML_ELEMENT_NODE) {
+      continue;
+    }
+    if (!hasName && !strcmp((const char *) curNode->name, "name")) {
+      if (curNode->children != nullptr
+          && XML_TEXT_NODE == curNode->children->type) {
+        key = (const char *) curNode->children->content;
+        hasName = true;
+      }
+    } else if (!hasValue && !strcmp((const char *) curNode->name, "value")) {
+      if (curNode->children != nullptr
+          && XML_TEXT_NODE == curNode->children->type) {
+        value = (const char *) curNode->children->content;
+        hasValue = true;
+      }
+    } else {
+      continue;
+    }
+  }
+  if (hasName && hasValue) {
+    kv[key] = value;
+    return;
+  } else if (hasName && hasValue) {
+    return;
+  } else if (hasName && hasScope) {
+    return;
+  } else if (hasName) {
+    return;
+  }
+}
+
+const string XmlConfig::getString(const char *key) {
+  XmlConfigMapIterator it = kv.find(key);
+  if (kv.end() == it) {
+    return "";
+  }
+  return it->second;
+}
+
+const string XmlConfig::getString(const char *key, const char *def) {
+  XmlConfigMapIterator it = kv.find(key);
+  if (kv.end() == it) {
+    return string(def);
+  } else {
+    return it->second;
+  }
+}
+
+const string XmlConfig::getString(const string & key) {
+  return getString(key.c_str());
+}
+
+const string XmlConfig::getString(const string & key,
+                                  const string & def) {
+  return getString(key.c_str(), def.c_str());
+}
+
+int64_t XmlConfig::getInt64(const char *key) {
+  int64_t retval;
+  XmlConfigMapIterator it = kv.find(key);
+  if (kv.end() == it) {
+    return 0;
+  }
+  retval = strToInt64(it->second.c_str());
+  return retval;
+}
+
+int64_t XmlConfig::getInt64(const char *key, int64_t def) {
+  int64_t retval;
+  XmlConfigMapIterator it = kv.find(key);
+  if (kv.end() == it) {
+    return def;
+  }
+  retval = strToInt64(it->second.c_str());
+  return retval;
+}
+
+int32_t XmlConfig::getInt32(const char *key) {
+  int32_t retval;
+  XmlConfigMapIterator it = kv.find(key);
+  if (kv.end() == it) {
+    return 0;
+  }
+  retval = strToInt32(it->second.c_str());
+  return retval;
+}
+
+int32_t XmlConfig::getInt32(const char *key, int32_t def) {
+  int32_t retval;
+  XmlConfigMapIterator it = kv.find(key);
+  if (kv.end() == it) {
+    return def;
+  }
+  retval = strToInt32(it->second.c_str());
+  return retval;
+}
+
+double XmlConfig::getDouble(const char *key) {
+  double retval;
+  XmlConfigMapIterator it = kv.find(key);
+  if (kv.end() == it) {
+    return 0.0;
+  }
+  retval = strToDouble(it->second.c_str());
+  return retval;
+}
+
+double XmlConfig::getDouble(const char *key, double def) {
+  double retval;
+  XmlConfigMapIterator it = kv.find(key);
+  if (kv.end() == it) {
+    return def;
+  }
+  retval = strToDouble(it->second.c_str());
+  return retval;
+}
+
+bool XmlConfig::getBool(const char *key) {
+  bool retval;
+  XmlConfigMapIterator it = kv.find(key);
+  if (kv.end() == it) {
+      return false;
+  }
+  retval = strToBool(it->second.c_str());
+  return retval;
+}
+
+bool XmlConfig::getBool(const char *key, bool def) {
+  bool retval;
+  XmlConfigMapIterator it = kv.find(key);
+  if (kv.end() == it) {
+    return def;
+  }
+  retval = strToBool(it->second.c_str());
+  return retval;
+}
+
+int64_t XmlConfig::strToInt64(const char *str) {
+  int64_t retval;
+  char *end = nullptr;
+  retval = strtoll(str, &end, 0);
+  return retval;
+}
+
+int32_t XmlConfig::strToInt32(const char *str) {
+  int32_t retval;
+  char *end = nullptr;
+  retval = strtoll(str, &end, 0);
+  return retval;
+}
+
+bool XmlConfig::strToBool(const char *str) {
+  bool retval = false;
+  if (!strcasecmp(str, "true") || !strcmp(str, "1")) {
+    retval = true;
+  } else if (!strcasecmp(str, "false") || !strcmp(str, "0")) {
+    retval = false;
+  } else {
+    return false;
+  }
+  return retval;
+}
+
+double XmlConfig::strToDouble(const char *str) {
+  double retval;
+  char *end = nullptr;
+  retval = strtod(str, &end);
+  return retval;
+}
+
+} // namespace test
+} // namespace hawq

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ec098032/src/test/feature/lib/xml_parser.h
----------------------------------------------------------------------
diff --git a/src/test/feature/lib/xml_parser.h b/src/test/feature/lib/xml_parser.h
new file mode 100644
index 0000000..6978218
--- /dev/null
+++ b/src/test/feature/lib/xml_parser.h
@@ -0,0 +1,68 @@
+#ifndef HAWQ_SRC_TEST_FEATURE_LIB_XML_PARSER_H_
+#define HAWQ_SRC_TEST_FEATURE_LIB_XML_PARSER_H_
+
+#include <string>
+#include <unordered_map>
+
+#include "libxml/parser.h"
+
+using XmlConfigMap = std::unordered_map<std::string, std::string>;
+using XmlConfigMapIterator = std::unordered_map<std::string, std::string>::const_iterator;
+
+namespace hawq {
+namespace test {
+
+class XmlConfig {
+
+ public:
+  explicit XmlConfig(std::string);
+  
+  // parse the configuration file
+  void parse();
+
+  // @param key The key of the configuration item
+  // @ def The default value
+  // @ return The value of configuration item
+  const std::string getString(const char*);
+
+  const std::string getString(const char *key, const char *def);
+
+  const std::string getString(const std::string &);
+
+  const std::string getString(const std::string & key, const std::string & def);
+
+  int64_t getInt64(const char *);
+
+  int64_t getInt64(const char *key, int64_t def);
+
+  int32_t getInt32(const char *);
+
+  int32_t getInt32(const char *key, int32_t def);
+
+  double getDouble(const char *);
+
+  double getDouble(const char *key, double def);
+
+  bool getBool(const char *);
+
+  bool getBool(const char *key, bool def);
+
+  XmlConfigMap *getConfigMap() { return &kv; }
+
+ private:
+  void readConfigItems(xmlDocPtr doc);
+  void readConfigItem(xmlNodePtr root);
+  int64_t strToInt64(const char *);
+  int32_t strToInt32(const char *);
+  bool strToBool(const char *);
+  double strToDouble(const char *);
+ 
+ private:
+  std::string path;
+  XmlConfigMap kv;  // key2Value
+}; // class XmlConfig
+
+} // namespace test
+} // namespace hawq
+
+#endif /* SRC_TEST_FEATURE_LIB_XML_PARSER_H_ */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ec098032/src/test/feature/parquet/test-parquet.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/parquet/test-parquet.cpp b/src/test/feature/parquet/test-parquet.cpp
deleted file mode 100644
index 2e65f0d..0000000
--- a/src/test/feature/parquet/test-parquet.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-#include "gtest/gtest.h"
-
-#include "lib/data-gen.h"
-#include "lib/sql-util.h"
-
-class TestParquet : public ::testing::Test {
- public:
-  TestParquet() {}
-  ~TestParquet() {}
-};
-
-TEST_F(TestParquet, TestMultipleType) {
-  SQLUtility util;
-  util.execute("drop table if exists t1");
-  DataGenerator dGen(&util);
-  dGen.genTableWithFullTypes("t1", true, "parquet");
-  util.query(
-      "select * from t1",
-      "2147483647|||00:00:00||ff:89:71:45:ae:01|2000-01-01 "
-      "07:00:00+08||32767|t|192.168.1.255/"
-      "32|<(1,2),3>|[(0,0),(6,6)]|-178000000 "
-      "years|0|-$21,474,836.48|(200,400),(100,200)||<aa>bb</"
-      "aa>||123456789a|2001:db8:85a3:8d3:1319:8a2e:370:7344/"
-      "64|||1|0|(1,2)|4277-12-31|128|\n0|((100,123),(5,10),(7,2),(4,5))|hello "
-      "world||04:45:05.0012+08:40|||bbccddeeff|128||2001:db8:85a3:8d3:1319:"
-      "8a2e:370:7344/128|<(1,2),3>|[(0,0),(6,6)]||1|$0.00|(2,3),(0,1)|hello "
-      "world|<aa>bb</aa>||aaaa|2001:db8:85a3:8d3:1319:8a2e:370:7344/"
-      "64|0||2147483647|-Infinity|(1,2)|4277-12-31|Infinity|\n||abcd|15:01:03||"
-      "|2000-01-01 07:00:00+08|||t|||[(0,0),(6,6)]|-178000000 "
-      "years|0|-$21,474,836.48|(200,400),(100,200)||<aa>bb</"
-      "aa>||123456789a|2001:db8:85a3:8d3:1319:8a2e:370:7344/"
-      "64|||1|0|(1,2)|4277-12-31|128|\n0|((100,123),(5,10),(7,2),(4,5))|hello "
-      "world||04:45:05.0012+08:40|||bbccddeeff|128||2001:db8:85a3:8d3:1319:"
-      "8a2e:370:7344/128|<(1,2),3>||||$0.00||hello "
-      "world|||aaaa|2001:db8:85a3:8d3:1319:8a2e:370:7344/"
-      "64|0||2147483647|-Infinity|(1,2)|4277-12-31|Infinity|\n0|((100,123),(5,"
-      "10),(7,2),(4,5))|hello "
-      "world||04:45:05.0012+08:40|||bbccddeeff|128||2001:db8:85a3:8d3:1319:"
-      "8a2e:370:7344/128|<(1,2),3>||||$0.00||hello "
-      "world|||||0||2147483647|-Infinity|(1,2)|4277-12-31|Infinity|\n0|((100,"
-      "123),(5,10),(7,2),(4,5))|hello "
-      "world||04:45:05.0012+08:40|||bbccddeeff|128||2001:db8:85a3:8d3:1319:"
-      "8a2e:370:7344/128|<(1,2),3>||||||hello world|||||0||34|||||\n");
-}
-
-TEST_F(TestParquet, TestCompression) {
-  SQLUtility util;
-  util.execute("drop table if exists t21");
-  util.execute("drop table if exists t22");
-  DataGenerator dGen(&util);
-  dGen.genTableWithNull("t21", true, "parquet", "gzip", 9);
-  dGen.genTableWithNull("t22", true, "parquet", "snappy");
-  util.query("select * from t21,t22",
-             "15||aa|15||aa|\n15||aa|||WET|\n15||aa||51||\n||WET|15||aa|\n||"
-             "WET|||WET|\n||WET||51||\n|51||15||aa|\n|51||||WET|\n|51|||51||"
-             "\n");
-}
-
-TEST_F(TestParquet, TestSize) {
-  SQLUtility util;
-  // value/record size equal to pagesize/rowgroupsize
-  util.execute("drop table if exists t31");
-  util.execute(
-      "create table t31 (a1 char(10485760), a2 char(10485760), a3 "
-      "char(10485760), a4 char(10485760), a5 char(10485760), a6 "
-      "char(10485760), a7 char(10485760), a8 char(10485760), a9 "
-      "char(10485760), a10 char(10485760)) with(appendonly=true, "
-      "orientation=parquet, pagesize=10485760, rowgroupsize=104857600)");
-  util.execute(
-      "insert into t31 values ( ('a'::char(10485760)), "
-      "('a'::char(10485760)), ('a'::char(10485760)), ('a'::char(10485760)), "
-      "('a'::char(10485760)), ('a'::char(10485760)), ('a'::char(10485760)), "
-      "('a'::char(10485760)), ('a'::char(10485760)), ('a'::char(10485760)) );",
-      false);
-  EXPECT_STREQ("ERROR:  value for column \"a1\" exceeds pagesize 10485760!",
-               util.getPSQL()->getLastResult().substr(0, 56).c_str());
-
-  // single column, one data page contains several values, one rwo group
-  // contains several groups
-  util.execute("drop table if exists t32");
-  util.execute("drop table if exists t33");
-  util.execute(
-      "create table t32 ( a1 text ) with(appendonly=true, "
-      "orientation=parquet)");
-  util.execute("insert into t32 values(repeat('parquet',100))");
-  util.execute("insert into t32 values(repeat('parquet',20))");
-  util.execute("insert into t32 values(repeat('parquet',30))");
-  util.execute(
-      "create table t33 ( a1 text ) with(appendonly=true, orientation=parquet, "
-      "pagesize=1024, rowgroupsize=1025)");
-  util.execute("insert into t33 select * from t32");
-  util.query("select * from t33", 3);
-
-  // large data insert, several column values in one page, several rows in one
-  // rowgroup
-  util.execute("drop table if exists t34");
-  util.execute("drop table if exists t35");
-  util.execute(
-      "create table t34 (a1 char(1048576), a2 char(2048576), a3 "
-      "char(3048576), a4 char(4048576), a5 char(5048576), a6 char(6048576), a7 "
-      "char(7048576), a8 char(8048576), a9 char(9048576), a10 char(9)) "
-      "with(appendonly=true, orientation=parquet, pagesize=10485760, "
-      "rowgroupsize=90874386)");
-  util.execute(
-      "insert into t34 values ( ('a'::char(1048576)), "
-      "('a'::char(2048576)), ('a'::char(3048576)), ('a'::char(4048576)), "
-      "('a'::char(5048576)), ('a'::char(6048576)), ('a'::char(7048576)), "
-      "('a'::char(8048576)), ('a'::char(9048576)), ('a'::char(9)) )");
-  util.execute(
-      "create table t35 (a1 char(1048576), a2 char(2048576), a3 "
-      "char(3048576), a4 char(4048576), a5 char(5048576), a6 char(6048576), a7 "
-      "char(7048576), a8 char(8048576), a9 char(9048576), a10 char(9)) "
-      "with(appendonly=true, orientation=parquet, pagesize=10485760, "
-      "rowgroupsize=17437200)");
-  util.execute("insert into t35 select * from t34");
-  util.query("select * from t35", 1);
-}
-
-TEST_F(TestParquet, TestPartition) {
-  SQLUtility util;
-  util.execute("drop table if exists t4");
-  util.execute(
-      "create table t4 (id SERIAL,a1 int,a2 char(5)) WITH (appendonly=true, "
-      "orientation=parquet,compresstype=gzip,compresslevel=1) distributed "
-      "randomly Partition by range(a1) (start(1)  end(16) every(8)"
-      "WITH(appendonly = true, orientation = parquet, compresstype = "
-      "snappy))");
-  util.execute("insert into t4(a1,a2) values(generate_series(1,5),'M')");
-  util.execute(
-      "alter table t4 add partition new_p start(17) end (20) WITH "
-      "(appendonly=true, orientation=parquet, compresstype=snappy)");
-  util.execute(
-      "alter table t4 add default partition df_p WITH "
-      "(appendonly=true, orientation=parquet, compresstype=gzip, "
-      "compresslevel=3)");
-  util.execute("insert into t4(a1,a2) values(generate_series(6,25),'F')");
-  util.query("select * from t4", 25);
-}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ec098032/src/test/feature/parquet/test_parquet.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/parquet/test_parquet.cpp b/src/test/feature/parquet/test_parquet.cpp
new file mode 100644
index 0000000..cf27870
--- /dev/null
+++ b/src/test/feature/parquet/test_parquet.cpp
@@ -0,0 +1,140 @@
+#include "gtest/gtest.h"
+
+#include "lib/data_gen.h"
+#include "lib/sql_util.h"
+
+using hawq::test::SQLUtility;
+
+class TestParquet : public ::testing::Test {
+ public:
+  TestParquet() {}
+  ~TestParquet() {}
+};
+
+TEST_F(TestParquet, TestMultipleType) {
+  SQLUtility util;
+  util.execute("drop table if exists t1");
+  hawq::test::DataGenerator dGen(&util);
+  dGen.genTableWithFullTypes("t1", true, "parquet");
+  util.query(
+      "select * from t1",
+      "2147483647|||00:00:00||ff:89:71:45:ae:01|2000-01-01 "
+      "07:00:00+08||32767|t|192.168.1.255/"
+      "32|<(1,2),3>|[(0,0),(6,6)]|-178000000 "
+      "years|0|-$21,474,836.48|(200,400),(100,200)||<aa>bb</"
+      "aa>||123456789a|2001:db8:85a3:8d3:1319:8a2e:370:7344/"
+      "64|||1|0|(1,2)|4277-12-31|128|\n0|((100,123),(5,10),(7,2),(4,5))|hello "
+      "world||04:45:05.0012+08:40|||bbccddeeff|128||2001:db8:85a3:8d3:1319:"
+      "8a2e:370:7344/128|<(1,2),3>|[(0,0),(6,6)]||1|$0.00|(2,3),(0,1)|hello "
+      "world|<aa>bb</aa>||aaaa|2001:db8:85a3:8d3:1319:8a2e:370:7344/"
+      "64|0||2147483647|-Infinity|(1,2)|4277-12-31|Infinity|\n||abcd|15:01:03||"
+      "|2000-01-01 07:00:00+08|||t|||[(0,0),(6,6)]|-178000000 "
+      "years|0|-$21,474,836.48|(200,400),(100,200)||<aa>bb</"
+      "aa>||123456789a|2001:db8:85a3:8d3:1319:8a2e:370:7344/"
+      "64|||1|0|(1,2)|4277-12-31|128|\n0|((100,123),(5,10),(7,2),(4,5))|hello "
+      "world||04:45:05.0012+08:40|||bbccddeeff|128||2001:db8:85a3:8d3:1319:"
+      "8a2e:370:7344/128|<(1,2),3>||||$0.00||hello "
+      "world|||aaaa|2001:db8:85a3:8d3:1319:8a2e:370:7344/"
+      "64|0||2147483647|-Infinity|(1,2)|4277-12-31|Infinity|\n0|((100,123),(5,"
+      "10),(7,2),(4,5))|hello "
+      "world||04:45:05.0012+08:40|||bbccddeeff|128||2001:db8:85a3:8d3:1319:"
+      "8a2e:370:7344/128|<(1,2),3>||||$0.00||hello "
+      "world|||||0||2147483647|-Infinity|(1,2)|4277-12-31|Infinity|\n0|((100,"
+      "123),(5,10),(7,2),(4,5))|hello "
+      "world||04:45:05.0012+08:40|||bbccddeeff|128||2001:db8:85a3:8d3:1319:"
+      "8a2e:370:7344/128|<(1,2),3>||||||hello world|||||0||34|||||\n");
+}
+
+TEST_F(TestParquet, TestCompression) {
+  SQLUtility util;
+  util.execute("drop table if exists t21");
+  util.execute("drop table if exists t22");
+  hawq::test::DataGenerator dGen(&util);
+  dGen.genTableWithNull("t21", true, "parquet", "gzip", 9);
+  dGen.genTableWithNull("t22", true, "parquet", "snappy");
+  util.query("select * from t21,t22",
+             "15||aa|15||aa|\n15||aa|||WET|\n15||aa||51||\n||WET|15||aa|\n||"
+             "WET|||WET|\n||WET||51||\n|51||15||aa|\n|51||||WET|\n|51|||51||"
+             "\n");
+}
+
+TEST_F(TestParquet, TestSize) {
+  SQLUtility util;
+  // value/record size equal to pagesize/rowgroupsize
+  util.execute("drop table if exists t31");
+  util.execute(
+      "create table t31 (a1 char(10485760), a2 char(10485760), a3 "
+      "char(10485760), a4 char(10485760), a5 char(10485760), a6 "
+      "char(10485760), a7 char(10485760), a8 char(10485760), a9 "
+      "char(10485760), a10 char(10485760)) with(appendonly=true, "
+      "orientation=parquet, pagesize=10485760, rowgroupsize=104857600)");
+  util.execute(
+      "insert into t31 values ( ('a'::char(10485760)), "
+      "('a'::char(10485760)), ('a'::char(10485760)), ('a'::char(10485760)), "
+      "('a'::char(10485760)), ('a'::char(10485760)), ('a'::char(10485760)), "
+      "('a'::char(10485760)), ('a'::char(10485760)), ('a'::char(10485760)) );",
+      false);
+  EXPECT_STREQ("ERROR:  value for column \"a1\" exceeds pagesize 10485760!",
+               util.getPSQL()->getLastResult().substr(0, 56).c_str());
+
+  // single column, one data page contains several values, one rwo group
+  // contains several groups
+  util.execute("drop table if exists t32");
+  util.execute("drop table if exists t33");
+  util.execute(
+      "create table t32 ( a1 text ) with(appendonly=true, "
+      "orientation=parquet)");
+  util.execute("insert into t32 values(repeat('parquet',100))");
+  util.execute("insert into t32 values(repeat('parquet',20))");
+  util.execute("insert into t32 values(repeat('parquet',30))");
+  util.execute(
+      "create table t33 ( a1 text ) with(appendonly=true, orientation=parquet, "
+      "pagesize=1024, rowgroupsize=1025)");
+  util.execute("insert into t33 select * from t32");
+  util.query("select * from t33", 3);
+
+  // large data insert, several column values in one page, several rows in one
+  // rowgroup
+  util.execute("drop table if exists t34");
+  util.execute("drop table if exists t35");
+  util.execute(
+      "create table t34 (a1 char(1048576), a2 char(2048576), a3 "
+      "char(3048576), a4 char(4048576), a5 char(5048576), a6 char(6048576), a7 "
+      "char(7048576), a8 char(8048576), a9 char(9048576), a10 char(9)) "
+      "with(appendonly=true, orientation=parquet, pagesize=10485760, "
+      "rowgroupsize=90874386)");
+  util.execute(
+      "insert into t34 values ( ('a'::char(1048576)), "
+      "('a'::char(2048576)), ('a'::char(3048576)), ('a'::char(4048576)), "
+      "('a'::char(5048576)), ('a'::char(6048576)), ('a'::char(7048576)), "
+      "('a'::char(8048576)), ('a'::char(9048576)), ('a'::char(9)) )");
+  util.execute(
+      "create table t35 (a1 char(1048576), a2 char(2048576), a3 "
+      "char(3048576), a4 char(4048576), a5 char(5048576), a6 char(6048576), a7 "
+      "char(7048576), a8 char(8048576), a9 char(9048576), a10 char(9)) "
+      "with(appendonly=true, orientation=parquet, pagesize=10485760, "
+      "rowgroupsize=17437200)");
+  util.execute("insert into t35 select * from t34");
+  util.query("select * from t35", 1);
+}
+
+TEST_F(TestParquet, TestPartition) {
+  SQLUtility util;
+  util.execute("drop table if exists t4");
+  util.execute(
+      "create table t4 (id SERIAL,a1 int,a2 char(5)) WITH (appendonly=true, "
+      "orientation=parquet,compresstype=gzip,compresslevel=1) distributed "
+      "randomly Partition by range(a1) (start(1)  end(16) every(8)"
+      "WITH(appendonly = true, orientation = parquet, compresstype = "
+      "snappy))");
+  util.execute("insert into t4(a1,a2) values(generate_series(1,5),'M')");
+  util.execute(
+      "alter table t4 add partition new_p start(17) end (20) WITH "
+      "(appendonly=true, orientation=parquet, compresstype=snappy)");
+  util.execute(
+      "alter table t4 add default partition df_p WITH "
+      "(appendonly=true, orientation=parquet, compresstype=gzip, "
+      "compresslevel=3)");
+  util.execute("insert into t4(a1,a2) values(generate_series(6,25),'F')");
+  util.query("select * from t4", 25);
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ec098032/src/test/feature/query/test-prepare.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/query/test-prepare.cpp b/src/test/feature/query/test-prepare.cpp
deleted file mode 100644
index 89b806c..0000000
--- a/src/test/feature/query/test-prepare.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-#include <pwd.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <vector>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <iostream>
-
-#include "lib/command.h"
-#include "lib/common.h"
-#include "lib/data-gen.h"
-#include "lib/hawq-config.h"
-#include "lib/sql-util.h"
-
-#include "gtest/gtest.h"
-
-class TestQueryPrepare : public ::testing::Test {
- public:
-  TestQueryPrepare() {}
-  ~TestQueryPrepare() {}
-};
-
-
-TEST_F(TestQueryPrepare, TestPrepareUniqueness) {
-  SQLUtility util;
-  util.execSQLFile("query/sql/prepare-uniqueness.sql",
-		  	  	   "query/ans/prepare-uniqueness.ans");
-}
-
-TEST_F(TestQueryPrepare, TestPrepareParameters) {
-  SQLUtility util;
-  // prepare
-  util.execute("drop table if exists test1");
-  util.execute("drop table if exists test2");
-  util.execute("create table test1 ("
-		  	   "	unique1		int4,"
-		  	   "	unique2		int4,"
-		  	   "	two			int4,"
-		  	   "	four		int4,"
-		  	   "	ten			int4,"
-		  	   "	twenty		int4,"
-		  	   "	hundred		int4,"
-		  	   "	thousand	int4,"
-		  	   "	twothousand	int4,"
-		  	   "	fivethous	int4,"
-		  	   "	tenthous	int4,"
-		  	   "	odd			int4,"
-		  	   "	even		int4,"
-		  	   "	stringu1	name,"
-		  	   "	stringu2	name,"
-		  	   "	string4		name) with oids");
-  util.execute("create table test2 ("
-		  	   "	name		text,"
-		  	   "	thepath		path)");
-
-  std::string pwd = util.getTestRootPath();
-  std::string cmd = "COPY test1 FROM '" + pwd + "/query/data/tenk.data'";
-  std::cout << cmd << std::endl;
-  util.execute(cmd);
-  cmd = "COPY test2 FROM '" + pwd + "/query/data/streets.data'";
-  std::cout << cmd << std::endl;
-  util.execute(cmd);
-
-  // do test
-  util.execSQLFile("query/sql/prepare-parameters.sql",
-		  	  	   "query/ans/prepare-parameters.ans");
-
-  // cleanup
-  util.execute("drop table test1");
-  util.execute("drop table test2");
-}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ec098032/src/test/feature/query/test-sequence.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/query/test-sequence.cpp b/src/test/feature/query/test-sequence.cpp
deleted file mode 100644
index d657dab..0000000
--- a/src/test/feature/query/test-sequence.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-#include <pwd.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <vector>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <iostream>
-
-#include "lib/command.h"
-#include "lib/common.h"
-#include "lib/data-gen.h"
-#include "lib/hawq-config.h"
-#include "lib/sql-util.h"
-
-#include "gtest/gtest.h"
-
-class TestQuerySequence : public ::testing::Test {
- public:
-  TestQuerySequence() {}
-  ~TestQuerySequence() {}
-};
-
-
-TEST_F(TestQuerySequence, TestSequenceCreateSerialColumn) {
-  SQLUtility util;
-
-  util.execute("drop table if exists serialtest");
-  util.execute("create table serialtest (f1 text, f2 serial)");
-  util.execute("insert into serialtest values('foo')");
-  util.execute("insert into serialtest values('force',100)");
-  // expect failure due to null value in serial column
-  util.execSQLFile("query/sql/sequence-serialcol-null.sql",
-		  	  	   "query/ans/sequence-serialcol-null.ans");
-  // query table to check rows with generated and specified values in serial col
-  util.execSQLFile("query/sql/sequence-serialcol-query.sql",
-		  	  	   "query/ans/sequence-serialcol-query.ans");
-
-  // rename the sequence for that serial column
-  util.execute("alter table serialtest_f2_seq rename to serialtest_f2_foo");
-  util.execute("insert into serialtest values('more')");
-
-  // query table to check rows
-  util.execSQLFile("query/sql/sequence-serialcol-query.sql",
-		  	  	   "query/ans/sequence-serialcol-query2.ans");
-
-  // cleanup
-  util.execute("drop table serialtest");
-}
-
-TEST_F(TestQuerySequence, TestSequenceBasicOperations) {
-	SQLUtility util;
-
-	// prepare
-	util.execute("drop sequence if exists sequence_test");
-	util.execute("create sequence sequence_test");
-
-	// normal nextval operation
-	util.query("select nextval('sequence_test'::text)", "1|\n");
-	util.query("select nextval('sequence_test'::regclass)", "2|\n");
-
-	// setval with different params
-	util.query("select setval('sequence_test'::text, 32)", "32|\n");
-	util.query("select nextval('sequence_test'::regclass)", "33|\n");
-
-	util.query("select setval('sequence_test'::text, 99, false)", "99|\n");
-	util.query("select nextval('sequence_test'::regclass)", "99|\n");
-
-	util.query("select setval('sequence_test'::regclass, 32)", "32|\n");
-	util.query("select nextval('sequence_test'::text)", "33|\n");
-
-	util.query("select setval('sequence_test'::regclass, 99, false)", "99|\n");
-	util.query("select nextval('sequence_test'::text)", "99|\n");
-
-	// cleanup
-	util.execute("drop sequence sequence_test");
-}
-
-TEST_F(TestQuerySequence, TestSequenceRenaming) {
-	SQLUtility util;
-	// prepare
-	util.execute("drop sequence if exists foo_seq");
-	util.execute("create sequence foo_seq");
-	// alter sequence name
-	util.execute("alter table foo_seq rename to foo_seq_new");
-	util.query("select * from foo_seq_new",
-			   "foo_seq|1|1|9223372036854775807|1|1|1|f|f|\n");
-	// cleanup
-	util.execute("drop sequence foo_seq_new");
-}
-
-TEST_F(TestQuerySequence, TestSequenceDependency) {
-	SQLUtility util;
-	util.execSQLFile("query/sql/sequence-dependency.sql",
-			  	  	 "query/ans/sequence-dependency.ans");
-}
-
-TEST_F(TestQuerySequence, TestSequenceAlternate) {
-	SQLUtility util;
-	// prepare
-	util.execute("drop sequence if exists sequence_test2");
-	util.execute("create sequence sequence_test2 start with 32");
-	util.query("select nextval('sequence_test2')", "32|\n");
-
-	// alter sequence
-	util.execute("alter sequence sequence_test2 "
-				 	 "restart with 16 "
-				 	 "increment by 4 "
-				 	 "maxvalue 22 "
-				 	 "minvalue 5 "
-				 	 "cycle");
-	// check the sequence value
-	util.query("select nextval('sequence_test2')","16|\n");
-	util.query("select nextval('sequence_test2')","20|\n");
-	util.query("select nextval('sequence_test2')","5|\n");
-
-	// cleanup
-	util.execute("drop sequence sequence_test2");
-}
-
-
-

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ec098032/src/test/feature/query/test_prepare.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/query/test_prepare.cpp b/src/test/feature/query/test_prepare.cpp
new file mode 100644
index 0000000..0905889
--- /dev/null
+++ b/src/test/feature/query/test_prepare.cpp
@@ -0,0 +1,70 @@
+#include <pwd.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <vector>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <iostream>
+
+#include "lib/command.h"
+#include "lib/data_gen.h"
+#include "lib/hawq_config.h"
+#include "lib/sql_util.h"
+
+#include "gtest/gtest.h"
+
+class TestQueryPrepare : public ::testing::Test {
+ public:
+  TestQueryPrepare() {}
+  ~TestQueryPrepare() {}
+};
+
+TEST_F(TestQueryPrepare, TestPrepareUniqueness) {
+  hawq::test::SQLUtility util;
+  util.execSQLFile("query/sql/prepare-uniqueness.sql",
+		  	  	   "query/ans/prepare-uniqueness.ans");
+}
+
+TEST_F(TestQueryPrepare, TestPrepareParameters) {
+  hawq::test::SQLUtility util;
+  // prepare
+  util.execute("drop table if exists test1");
+  util.execute("drop table if exists test2");
+  util.execute("create table test1 ("
+		  	   "	unique1		int4,"
+		  	   "	unique2		int4,"
+		  	   "	two			int4,"
+		  	   "	four		int4,"
+		  	   "	ten			int4,"
+		  	   "	twenty		int4,"
+		  	   "	hundred		int4,"
+		  	   "	thousand	int4,"
+		  	   "	twothousand	int4,"
+		  	   "	fivethous	int4,"
+		  	   "	tenthous	int4,"
+		  	   "	odd			int4,"
+		  	   "	even		int4,"
+		  	   "	stringu1	name,"
+		  	   "	stringu2	name,"
+		  	   "	string4		name) with oids");
+  util.execute("create table test2 ("
+		  	   "	name		text,"
+		  	   "	thepath		path)");
+
+  std::string pwd = util.getTestRootPath();
+  std::string cmd = "COPY test1 FROM '" + pwd + "/query/data/tenk.data'";
+  std::cout << cmd << std::endl;
+  util.execute(cmd);
+  cmd = "COPY test2 FROM '" + pwd + "/query/data/streets.data'";
+  std::cout << cmd << std::endl;
+  util.execute(cmd);
+
+  // do test
+  util.execSQLFile("query/sql/prepare-parameters.sql",
+		  	  	   "query/ans/prepare-parameters.ans");
+
+  // cleanup
+  util.execute("drop table test1");
+  util.execute("drop table test2");
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ec098032/src/test/feature/query/test_sequence.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/query/test_sequence.cpp b/src/test/feature/query/test_sequence.cpp
new file mode 100644
index 0000000..45027b9
--- /dev/null
+++ b/src/test/feature/query/test_sequence.cpp
@@ -0,0 +1,120 @@
+#include <pwd.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <vector>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <iostream>
+
+#include "lib/command.h"
+#include "lib/data_gen.h"
+#include "lib/hawq_config.h"
+#include "lib/sql_util.h"
+
+#include "gtest/gtest.h"
+
+class TestQuerySequence : public ::testing::Test {
+ public:
+  TestQuerySequence() {}
+  ~TestQuerySequence() {}
+};
+
+TEST_F(TestQuerySequence, TestSequenceCreateSerialColumn) {
+  hawq::test::SQLUtility util;
+
+  util.execute("drop table if exists serialtest");
+  util.execute("create table serialtest (f1 text, f2 serial)");
+  util.execute("insert into serialtest values('foo')");
+  util.execute("insert into serialtest values('force',100)");
+  // expect failure due to null value in serial column
+  util.execSQLFile("query/sql/sequence-serialcol-null.sql",
+		  	  	   "query/ans/sequence-serialcol-null.ans");
+  // query table to check rows with generated and specified values in serial col
+  util.execSQLFile("query/sql/sequence-serialcol-query.sql",
+		  	  	   "query/ans/sequence-serialcol-query.ans");
+
+  // rename the sequence for that serial column
+  util.execute("alter table serialtest_f2_seq rename to serialtest_f2_foo");
+  util.execute("insert into serialtest values('more')");
+
+  // query table to check rows
+  util.execSQLFile("query/sql/sequence-serialcol-query.sql",
+		  	  	   "query/ans/sequence-serialcol-query2.ans");
+
+  // cleanup
+  util.execute("drop table serialtest");
+}
+
+TEST_F(TestQuerySequence, TestSequenceBasicOperations) {
+  hawq::test::SQLUtility util;
+
+	// prepare
+	util.execute("drop sequence if exists sequence_test");
+	util.execute("create sequence sequence_test");
+
+	// normal nextval operation
+	util.query("select nextval('sequence_test'::text)", "1|\n");
+	util.query("select nextval('sequence_test'::regclass)", "2|\n");
+
+	// setval with different params
+	util.query("select setval('sequence_test'::text, 32)", "32|\n");
+	util.query("select nextval('sequence_test'::regclass)", "33|\n");
+
+	util.query("select setval('sequence_test'::text, 99, false)", "99|\n");
+	util.query("select nextval('sequence_test'::regclass)", "99|\n");
+
+	util.query("select setval('sequence_test'::regclass, 32)", "32|\n");
+	util.query("select nextval('sequence_test'::text)", "33|\n");
+
+	util.query("select setval('sequence_test'::regclass, 99, false)", "99|\n");
+	util.query("select nextval('sequence_test'::text)", "99|\n");
+
+	// cleanup
+	util.execute("drop sequence sequence_test");
+}
+
+TEST_F(TestQuerySequence, TestSequenceRenaming) {
+  hawq::test::SQLUtility util;
+	// prepare
+	util.execute("drop sequence if exists foo_seq");
+	util.execute("create sequence foo_seq");
+	// alter sequence name
+	util.execute("alter table foo_seq rename to foo_seq_new");
+	util.query("select * from foo_seq_new",
+			   "foo_seq|1|1|9223372036854775807|1|1|1|f|f|\n");
+	// cleanup
+	util.execute("drop sequence foo_seq_new");
+}
+
+TEST_F(TestQuerySequence, TestSequenceDependency) {
+  hawq::test::SQLUtility util;
+	util.execSQLFile("query/sql/sequence-dependency.sql",
+			  	  	 "query/ans/sequence-dependency.ans");
+}
+
+TEST_F(TestQuerySequence, TestSequenceAlternate) {
+  hawq::test::SQLUtility util;
+	// prepare
+	util.execute("drop sequence if exists sequence_test2");
+	util.execute("create sequence sequence_test2 start with 32");
+	util.query("select nextval('sequence_test2')", "32|\n");
+
+	// alter sequence
+	util.execute("alter sequence sequence_test2 "
+				 	 "restart with 16 "
+				 	 "increment by 4 "
+				 	 "maxvalue 22 "
+				 	 "minvalue 5 "
+				 	 "cycle");
+	// check the sequence value
+	util.query("select nextval('sequence_test2')","16|\n");
+	util.query("select nextval('sequence_test2')","20|\n");
+	util.query("select nextval('sequence_test2')","5|\n");
+
+	// cleanup
+	util.execute("drop sequence sequence_test2");
+}
+
+
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ec098032/src/test/feature/test-main.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/test-main.cpp b/src/test/feature/test-main.cpp
deleted file mode 100644
index 70e0f53..0000000
--- a/src/test/feature/test-main.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "gtest/gtest.h"
-
-int main(int argc, char** argv) {
-  ::testing::InitGoogleTest(&argc, argv);
-
-  return RUN_ALL_TESTS();
-}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ec098032/src/test/feature/test_main.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/test_main.cpp b/src/test/feature/test_main.cpp
new file mode 100644
index 0000000..70e0f53
--- /dev/null
+++ b/src/test/feature/test_main.cpp
@@ -0,0 +1,7 @@
+#include "gtest/gtest.h"
+
+int main(int argc, char** argv) {
+  ::testing::InitGoogleTest(&argc, argv);
+
+  return RUN_ALL_TESTS();
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ec098032/src/test/feature/testlib/test-lib.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/testlib/test-lib.cpp b/src/test/feature/testlib/test-lib.cpp
deleted file mode 100644
index 97556d8..0000000
--- a/src/test/feature/testlib/test-lib.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-#include <pwd.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <vector>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#include "lib/command.h"
-#include "lib/common.h"
-#include "lib/data-gen.h"
-#include "lib/hawq-config.h"
-#include "lib/sql-util.h"
-
-#include "gtest/gtest.h"
-
-class TestCommonLib : public ::testing::Test {
- public:
-  TestCommonLib() {}
-  ~TestCommonLib() {}
-};
-
-TEST_F(TestCommonLib, TestHawqConfig) {
-  std::string hostname = "";
-  int port = 0;
-
-  HawqConfig hc;
-  hc.getMaster(hostname, port);
-
-  hostname = "";
-  port = 0;
-  hc.getStandbyMaster(hostname, port);
-
-  std::vector<std::string> segmentHostname;
-  std::vector<int> segmentPort;
-  hc.getSlaves(segmentHostname);
-
-  segmentHostname.clear();
-  segmentPort.clear();
-  hc.getTotalSegments(segmentHostname, segmentPort);
-
-  segmentHostname.clear();
-  segmentPort.clear();
-  hc.getDownSegments(segmentHostname, segmentPort);
-
-  segmentHostname.clear();
-  segmentPort.clear();
-  hc.getUpSegments(segmentHostname, segmentPort);
-
-  hc.isMasterMirrorSynchronized();
-  hc.isMultinodeMode();
-
-  hc.setGucValue("default_hash_table_bucket_number", "4");
-  hc.getGucValue("default_hash_table_bucket_number");
-  return;
-}
-
-TEST_F(TestCommonLib, TestCommand) {
-  Command c("ls ./");
-  c.run().getResultOutput();
-
-  Command::getCommandOutput("pwd");
-  Command::getCommandStatus("date");
-  Command::getCommandStatus("datewrong");
-  Command::getCommandOutput("datewrong");
-}
-
-TEST_F(TestCommonLib, TestSqlUtil) {
-  SQLUtility util;
-  util.execute("create table test(p int, q float)");
-  util.execute("insert into test values(1,1.1),(2,2.2)");
-  util.query("select * from test", 2);
-  util.query("select * from test", "1|1.1|\n2|2.2|\n");
-  util.execSQLFile("testlib/sql/sample.sql", "testlib/ans/sample.ans");
-}
-
-TEST_F(TestCommonLib, TestDataGenerator) {
-  SQLUtility util;
-  DataGenerator dGen(&util);
-  dGen.genSimpleTable("simpleAO");
-  dGen.genSimpleTable("simpleParquet", true, "parquet");
-
-  dGen.genTableWithFullTypes("fullTypeAO");
-  dGen.genTableWithSeries("tSeries");
-
-  dGen.genTableWithNull("tNull");
-}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ec098032/src/test/feature/testlib/test_lib.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/testlib/test_lib.cpp b/src/test/feature/testlib/test_lib.cpp
new file mode 100644
index 0000000..1c30284
--- /dev/null
+++ b/src/test/feature/testlib/test_lib.cpp
@@ -0,0 +1,86 @@
+#include <pwd.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <vector>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "lib/command.h"
+#include "lib/data_gen.h"
+#include "lib/hawq_config.h"
+#include "lib/sql_util.h"
+
+#include "gtest/gtest.h"
+
+class TestCommonLib : public ::testing::Test {
+ public:
+  TestCommonLib() {}
+  ~TestCommonLib() {}
+};
+
+TEST_F(TestCommonLib, TestHawqConfig) {
+  std::string hostname = "";
+  int port = 0;
+
+  hawq::test::HawqConfig hc;
+  hc.getMaster(hostname, port);
+
+  hostname = "";
+  port = 0;
+  hc.getStandbyMaster(hostname, port);
+
+  std::vector<std::string> segmentHostname;
+  std::vector<int> segmentPort;
+  hc.getSlaves(segmentHostname);
+
+  segmentHostname.clear();
+  segmentPort.clear();
+  hc.getTotalSegments(segmentHostname, segmentPort);
+
+  segmentHostname.clear();
+  segmentPort.clear();
+  hc.getDownSegments(segmentHostname, segmentPort);
+
+  segmentHostname.clear();
+  segmentPort.clear();
+  hc.getUpSegments(segmentHostname, segmentPort);
+
+  hc.isMasterMirrorSynchronized();
+  hc.isMultinodeMode();
+
+  hc.setGucValue("default_hash_table_bucket_number", "4");
+  hc.getGucValue("default_hash_table_bucket_number");
+  return;
+}
+
+TEST_F(TestCommonLib, TestCommand) {
+  hawq::test::Command c("ls ./");
+  c.run().getResultOutput();
+
+  hawq::test::Command::getCommandOutput("pwd");
+  hawq::test::Command::getCommandStatus("date");
+  hawq::test::Command::getCommandStatus("datewrong");
+  hawq::test::Command::getCommandOutput("datewrong");
+}
+
+TEST_F(TestCommonLib, TestSqlUtil) {
+  hawq::test::SQLUtility util;
+  util.execute("create table test(p int, q float)");
+  util.execute("insert into test values(1,1.1),(2,2.2)");
+  util.query("select * from test", 2);
+  util.query("select * from test", "1|1.1|\n2|2.2|\n");
+  util.execSQLFile("testlib/sql/sample.sql", "testlib/ans/sample.ans");
+}
+
+TEST_F(TestCommonLib, TestDataGenerator) {
+  hawq::test::SQLUtility util;
+  hawq::test::DataGenerator dGen(&util);
+  dGen.genSimpleTable("simpleAO");
+  dGen.genSimpleTable("simpleParquet", true, "parquet");
+
+  dGen.genTableWithFullTypes("fullTypeAO");
+  dGen.genTableWithSeries("tSeries");
+
+  dGen.genTableWithNull("tNull");
+}


Mime
View raw message