当前位置: 首页>>代码示例>>C++>>正文


C++ SQLUtility::getTestRootPath方法代码示例

本文整理汇总了C++中SQLUtility::getTestRootPath方法的典型用法代码示例。如果您正苦于以下问题:C++ SQLUtility::getTestRootPath方法的具体用法?C++ SQLUtility::getTestRootPath怎么用?C++ SQLUtility::getTestRootPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SQLUtility的用法示例。


在下文中一共展示了SQLUtility::getTestRootPath方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rootPath

TEST_F(TestHawqRegister, TestUsage1NotParquetTable) {
    SQLUtility util;
    string rootPath(util.getTestRootPath());
    string relativePath("/ManagementTool/test_hawq_register_hawq.paq");
    string filePath = rootPath + relativePath;

    /* register a parquet file to a row random table, should fail */
    auto cmd = hawq::test::stringFormat("hadoop fs -put -f %s %s/hawq_register_hawq.paq", filePath.c_str(), getHdfsLocation().c_str());
    EXPECT_EQ(0, Command::getCommandStatus(cmd));

    util.execute("create table hawqregister(i int);");
    util.query("select * from hawqregister;", 0);

    cmd = hawq::test::stringFormat("hawq register -d %s -f %s/hawq_register_hawq.paq hawqregister", HAWQ_DB, getHdfsLocation().c_str());
    EXPECT_EQ(1, Command::getCommandStatus(cmd));
    util.query("select * from hawqregister;", 0);
    util.execute("drop table hawqregister;");

    /* register a parquet file to a row hash table, should fail */
    util.execute("create table hawqregister(i int) distributed by (i);");
    cmd = hawq::test::stringFormat("hawq register -d %s -f %s/hawq_register_hawq.paq hawqregister", HAWQ_DB, getHdfsLocation().c_str());
    EXPECT_EQ(1, Command::getCommandStatus(cmd));
    util.query("select * from hawqregister;", 0);
    util.execute("drop table hawqregister;");

    /* register a parquet file to a parquet hash table, should fail */
    util.execute("create table hawqregister(i int) with (appendonly=true, orientation=parquet) distributed by (i);");
    cmd = hawq::test::stringFormat("hawq register -d %s -f %s/hawq_register_hawq.paq hawqregister", HAWQ_DB, getHdfsLocation().c_str());
    EXPECT_EQ(1, Command::getCommandStatus(cmd));
    util.query("select * from hawqregister;", 0);
    util.execute("drop table hawqregister;");

    cmd = hawq::test::stringFormat("hadoop fs -rm  %s/hawq_register_hawq.paq", getHdfsLocation().c_str());
    EXPECT_EQ(0, Command::getCommandStatus(cmd));
}
开发者ID:hsyuan,项目名称:incubator-hawq,代码行数:35,代码来源:test_hawq_register_usage1.cpp

示例2: runYamlCaseTableNotExists

void TestHawqRegister::runYamlCaseTableNotExists(std::string casename, std::string ymlname, int isexpectederror=1, int checknum=100) {
    SQLUtility util;
    string test_root(util.getTestRootPath());
    util.execute("drop table if exists t;");
    util.execute("drop table if exists nt;");
    
    util.execute("create table t(i int) with (appendonly=true, orientation=parquet) distributed by (i);");
    util.execute("insert into t select generate_series(1, 100);");
    util.query("select * from t;", 100);
    string t_yml(hawq::test::stringFormat("%s/ManagementTool/%s.yml", test_root.c_str(), ymlname.c_str()));
    string t_yml_tpl(hawq::test::stringFormat("%s/ManagementTool/%s_tpl.yml", test_root.c_str(), ymlname.c_str()));
    hawq::test::FileReplace frep;
    std::unordered_map<std::string, std::string> strs_src_dst;
    strs_src_dst["@[email protected]"]= getDatabaseOid();
    strs_src_dst["@[email protected]"]= getTableOid("t");
    hawq::test::HdfsConfig hc;
    string hdfs_prefix;
    hc.getNamenodeHost(hdfs_prefix);
    strs_src_dst["@[email protected]"]= hdfs_prefix;
    frep.replace(t_yml_tpl, t_yml, strs_src_dst);
    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);
    } else {
        util.query("select * from nt;", checknum);
    }
    
    EXPECT_EQ(0, Command::getCommandStatus(hawq::test::stringFormat("rm -rf %s", t_yml.c_str())));
    util.execute("drop table t;");
    util.execute("drop table if exists nt;");
}
开发者ID:kdunn926,项目名称:incubator-hawq,代码行数:32,代码来源:test_hawq_register_usage2_case1.cpp

示例3: test_root

TEST_F(TestHawqRegister, TestUsage2Case1FileUnderTableDirectory) {
    SQLUtility util;
    string test_root(util.getTestRootPath());
    util.execute("drop table if exists t;");
    
    util.execute("create table t(i int) with (appendonly=true, orientation=parquet) distributed by (i);");
    util.execute("insert into t select generate_series(1, 100);");
    util.query("select * from t;", 100);
    string t_yml(hawq::test::stringFormat("%s/ManagementTool/usage2case1/file_under_table_directory.yml", test_root.c_str()));
    string t_yml_tpl(hawq::test::stringFormat("%s/ManagementTool/usage2case1/file_under_table_directory_tpl.yml", test_root.c_str()));
    hawq::test::FileReplace frep;
    std::unordered_map<std::string, std::string> strs_src_dst;
    strs_src_dst["@[email protected]"]= getDatabaseOid();
    strs_src_dst["@[email protected]"]= getTableOid("t");
    hawq::test::HdfsConfig hc;
    string hdfs_prefix;
    hc.getNamenodeHost(hdfs_prefix);
    strs_src_dst["@[email protected]"]= hdfs_prefix;
    frep.replace(t_yml_tpl, t_yml, strs_src_dst);
    EXPECT_EQ(1, Command::getCommandStatus(hawq::test::stringFormat("hawq register -d %s -c %s testhawqregister_testusage2case1fileUndertabledirectory.t", HAWQ_DB, t_yml.c_str())));
    util.query("select * from t;", 100);
    
    EXPECT_EQ(0, Command::getCommandStatus(hawq::test::stringFormat("rm -rf %s", t_yml.c_str())));
    util.execute("drop table t;");
}
开发者ID:kdunn926,项目名称:incubator-hawq,代码行数:25,代码来源:test_hawq_register_usage2_case1.cpp

示例4: test_root

TEST_F(TestHawqRegister, TestUsage2Case2Expected) {
    SQLUtility util;
    string test_root(util.getTestRootPath());
    std::vector<string> create_table_matrix = {"distributed by (i)", "distributed randomly"};
    std::vector<string> fmt_matrix = {"row", "parquet"};
    std::vector<string> option_matrix = {"--force", "-F"};
    int suffix=0;

    for (auto & opt : option_matrix) {
        suffix = 0;
        for (auto & ddl : create_table_matrix) {
            for (auto & fmt : fmt_matrix) {
                suffix++;
                string t_yml_tpl(hawq::test::stringFormat("%s/ManagementTool/usage2case2/t_tpl_%s.yml", test_root.c_str(), std::to_string(suffix).c_str()));
                string t_yml_tpl_new(hawq::test::stringFormat("%s/ManagementTool/usage2case2/t_tpl_new_%s.yml", test_root.c_str(), std::to_string(suffix).c_str()));
                string t_yml(hawq::test::stringFormat("%s/ManagementTool/usage2case2/t_%s.yml", test_root.c_str(), std::to_string(suffix).c_str()));
                string t_yml_new(hawq::test::stringFormat("%s/ManagementTool/usage2case2/t_new_%s.yml", test_root.c_str(), std::to_string(suffix).c_str()));
                auto t = hawq::test::stringFormat("t_usage2_case2_%s", std::to_string(suffix).c_str());
                auto nt = hawq::test::stringFormat("nt_usage2_case2_%s", std::to_string(suffix).c_str());
                util.execute(hawq::test::stringFormat("drop table if exists %s;", t.c_str()));
                util.execute(hawq::test::stringFormat("drop table if exists %s;", nt.c_str()));

                // hawq register -d hawq_feature_test -c t_#.yml nt_usage2_case2_#
                util.execute(hawq::test::stringFormat("create table %s(i int) with (appendonly=true, orientation=%s) %s;", t.c_str(), fmt.c_str(), ddl.c_str()));
                util.execute(hawq::test::stringFormat("insert into %s select generate_series(1, 100);", t.c_str()));
                util.execute(hawq::test::stringFormat("insert into %s select generate_series(101, 200);", t.c_str()));
                util.query(hawq::test::stringFormat("select * from %s;", t.c_str()), 200);
                hawq::test::FileReplace frep;
                std::unordered_map<std::string, std::string> strs_src_dst;
                strs_src_dst["@[email protected]"]= getDatabaseOid();
                strs_src_dst["@[email protected]"]= getTableOid(t);
                frep.replace(t_yml_tpl, t_yml, strs_src_dst);
                EXPECT_EQ(0, Command::getCommandStatus(hawq::test::stringFormat("hawq register -d %s -c %s testhawqregister_testusage2case2expected.%s", HAWQ_DB, t_yml.c_str(), nt.c_str())));
                util.query(hawq::test::stringFormat("select * from %s;", nt.c_str()), 200);

                // hawq register --force/-F -d hawq_feature_test -c t_new_#.yml nt_usage2_case2_#
                util.execute(hawq::test::stringFormat("drop table if exists %s;", t.c_str()));
                util.execute(hawq::test::stringFormat("create table %s(i int) with (appendonly=true, orientation=%s) %s;", t.c_str(), fmt.c_str(), ddl.c_str()));
                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["@[email protected]"]= getDatabaseOid();
                strs_src_dst["@[email protected]"]= getTableOid(nt);
                strs_src_dst["@[email protected]"]= getTableOid(t);
                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");
                else 
                   checkPgAOSegValue(nt, "-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())));
                util.execute(hawq::test::stringFormat("drop table %s;", t.c_str()));
                util.execute(hawq::test::stringFormat("drop table %s;", nt.c_str()));
            }
        }
    }
}
开发者ID:taojin0505,项目名称:incubator-hawq,代码行数:60,代码来源:test_hawq_register_usage2_case2.cpp

示例5: test_root

TEST_F(TestHawqRegister, TestRollBackHDFSFilePathContainErrorSymbol) {
    SQLUtility util;
    string test_root(util.getTestRootPath());
    util.execute("drop table if exists t;");
    util.execute("drop table if exists nt;");
    
    util.execute("create table t(i int) with (appendonly=true, orientation=row) distributed randomly;");
    util.execute("insert into t select generate_series(1, 100);");
    util.query("select * from t;", 100);
    util.execute("create table nt(i int) with (appendonly=true, orientation=row) distributed by (i);");
    util.execute("insert into nt select generate_series(1, 100);");
    util.query("select * from nt;", 100);
    string t_yml(hawq::test::stringFormat("%s/ManagementTool/rollback/error_schema.yml", test_root.c_str()));
    string t_yml_tpl(hawq::test::stringFormat("%s/ManagementTool/rollback/error_schema.yml", test_root.c_str()));
    hawq::test::FileReplace frep;
    std::unordered_map<std::string, std::string> strs_src_dst;
    strs_src_dst["@[email protected]"]= getDatabaseOid();
    strs_src_dst["@[email protected]"]= getTableOid("t", "testhawqregister_testrollbackhdfsfilepathcontainerrorsymbol");
    string hdfs_prefix;
    hawq::test::HdfsConfig hc;
    hc.getNamenodeHost(hdfs_prefix);
    strs_src_dst["@[email protected]"]= hdfs_prefix;
    frep.replace(t_yml_tpl, t_yml, strs_src_dst);
    EXPECT_EQ(1, Command::getCommandStatus(hawq::test::stringFormat("hawq register -d %s -c %s testhawqregister_testrollbackhdfsfilepathcontainerrorsymbol.nt", HAWQ_DB, t_yml.c_str())));
    util.query("select * from t;", 100);
    util.query("select * from nt;", 100);
    
    EXPECT_EQ(0, Command::getCommandStatus(hawq::test::stringFormat("rm -rf %s", t_yml.c_str())));
    util.execute("drop table t;");
    util.execute("drop table nt;");
}
开发者ID:laixiong,项目名称:incubator-hawq,代码行数:31,代码来源:test_hawq_register_rollback.cpp

示例6:

TEST_F(TestHawqRegister, TestUsage2Case1IncorrectYaml) {
    SQLUtility util;
    string filePath = util.getTestRootPath() + "/ManagementTool/";

    EXPECT_EQ(1, Command::getCommandStatus("hawq register -d " + (string) HAWQ_DB + " -c " + filePath + "missing_pagesize.yml testhawqregister_testusage2case1incorrectyaml.xx"));
    EXPECT_EQ(1, Command::getCommandStatus("hawq register -d " + (string) HAWQ_DB + " -c " + filePath + "missing_rowgroupsize.yml testhawqregister_testusage2case1incorrectyaml.xx"));
    EXPECT_EQ(1, Command::getCommandStatus("hawq register -d " + (string) HAWQ_DB + " -c " + filePath + "missing_filesize.yml testhawqregister_testusage2case1incorrectyaml.xx"));
    EXPECT_EQ(1, Command::getCommandStatus("hawq register -d " + (string) HAWQ_DB + " -c " + filePath + "wrong_schema.yml testhawqregister_testusage2case1incorrectyaml.xx"));
    EXPECT_EQ(1, Command::getCommandStatus("hawq register -d " + (string) HAWQ_DB + " -c " + filePath + "missing_checksum.yml testhawqregister_testusage2case1incorrectyaml.xx"));
    EXPECT_EQ(1, Command::getCommandStatus("hawq register -d " + (string) HAWQ_DB + " -c " + filePath + "wrong_dfs_url.yml testhawqregister_testusage2case1incorrectyaml.xx"));
    EXPECT_EQ(1, Command::getCommandStatus("hawq register -d " + (string) HAWQ_DB + " -c " + filePath + "missing_bucketnum.yml testhawqregister_testusage2case1incorrectyaml.xx"));
    EXPECT_EQ(1, Command::getCommandStatus("hawq register -d " + (string) HAWQ_DB + " -c " + filePath + "missing_constraint_partition.yml testhawqregister_testusage2case1incorrectyaml.xx"));
}
开发者ID:kdunn926,项目名称:incubator-hawq,代码行数:13,代码来源:test_hawq_register_usage2_case1.cpp

示例7:

TEST_F(TestExternalOid, TestExternalOidAll) {
  SQLUtility util;
  FileReplace frep;
  auto test_root = util.getTestRootPath();
  std::cout << test_root << std::endl;

  std::unordered_map<std::string, std::string> D;
  D["@[email protected]"] = test_root + "/ExternalSource/lib/function.so";
  D["@[email protected]"] = test_root + "/ExternalSource/data";
  frep.replace(test_root + "/ExternalSource/sql/external_oid.sql.source",
               test_root + "/ExternalSource/sql/external_oid.sql",
               D);
  frep.replace(test_root + "/ExternalSource/ans/external_oid.ans.source",
               test_root + "/ExternalSource/ans/external_oid.ans",
               D);
 
  util.execSQLFile("ExternalSource/sql/external_oid.sql",
                   "ExternalSource/ans/external_oid.ans");
}
开发者ID:laixiong,项目名称:incubator-hawq,代码行数:19,代码来源:test_external_oid.cpp

示例8:

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");
}
开发者ID:a320321wb,项目名称:incubator-hawq,代码行数:42,代码来源:test-prepare.cpp

示例9:

TEST_F(TestExternalTable, DISABLED_TestExternalTableAll) {
  SQLUtility util;
  auto test_root = util.getTestRootPath();
  auto replace_lambda = [&] () {
    FileReplace frep;
    std::unordered_map<std::string, std::string> D;
    D["@h[email protected]"] = std::string("localhost");
    D["@[email protected]"] = test_root + "/ExternalSource";
    D["@[email protected]"] = std::string(std::string(getenv("GPHOME")) + "/bin/gpfdist");
    frep.replace(test_root + "/ExternalSource/sql/exttab1.sql.source",
                 test_root + "/ExternalSource/sql/exttab1.sql",
                 D);
    frep.replace(test_root + "/ExternalSource/ans/exttab1.ans.source",
                 test_root + "/ExternalSource/ans/exttab1.ans",
                 D);
  };
  
  replace_lambda();
  util.execSQLFile("ExternalSource/sql/exttab1.sql",
                   "ExternalSource/ans/exttab1.ans");
}
开发者ID:laixiong,项目名称:incubator-hawq,代码行数:21,代码来源:test_exttab.cpp


注:本文中的SQLUtility::getTestRootPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。