From dfdeb7e0cc1578da9482fcb436672c1021b011f5 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 23 Mar 2021 11:15:11 +0800 Subject: [PATCH] [TD-3431] : fix taosdemo cmdline incorrect arguments. (#5536) Co-authored-by: Shuduo Sang --- src/kit/taosdemo/taosdemo.c | 43 +++++++++---------- tests/pytest/tools/taosdemoTest.py | 2 +- tests/pytest/tools/taosdemoTest2.py | 2 +- .../pytest/tools/taosdemoTestWithoutMetric.py | 2 +- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index b390ee76cd..6534196603 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -523,8 +523,8 @@ SArguments g_args = { 1, // replica "t", // tb_prefix NULL, // sqlFile - false, // use_metric - false, // insert_only + true, // use_metric + true, // insert_only false, // debug_print false, // verbose_print false, // performance statistic print @@ -614,7 +614,7 @@ static void printHelp() { printf("%s%s%s%s\n", indent, "-m", indent, "Table prefix name. Default is 't'."); printf("%s%s%s%s\n", indent, "-s", indent, "The select sql file."); - printf("%s%s%s%s\n", indent, "-M", indent, "Use metric flag."); + printf("%s%s%s%s\n", indent, "-N", indent, "Use normal table flag."); printf("%s%s%s%s\n", indent, "-o", indent, "Direct output to the named file. Default is './output.txt'."); printf("%s%s%s%s\n", indent, "-q", indent, @@ -742,10 +742,10 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { arguments->len_of_binary = atoi(argv[++i]); } else if (strcmp(argv[i], "-m") == 0) { arguments->tb_prefix = argv[++i]; - } else if (strcmp(argv[i], "-M") == 0) { - arguments->use_metric = true; + } else if (strcmp(argv[i], "-N") == 0) { + arguments->use_metric = false; } else if (strcmp(argv[i], "-x") == 0) { - arguments->insert_only = true; + arguments->insert_only = false; } else if (strcmp(argv[i], "-y") == 0) { arguments->answer_yes = true; } else if (strcmp(argv[i], "-g") == 0) { @@ -2576,12 +2576,12 @@ static int startMultiThreadCreateChildTable( t_info->ntables = iend_table_to = i < b ? startFrom + a : startFrom + a - 1; startFrom = t_info->end_table_to + 1; - t_info->use_metric = 1; + t_info->use_metric = true; t_info->cols = cols; t_info->minDelay = INT16_MAX; pthread_create(pids + i, NULL, createTable, t_info); } - + for (int i = 0; i < threads; i++) { pthread_join(pids[i], NULL); } @@ -2592,12 +2592,11 @@ static int startMultiThreadCreateChildTable( } free(pids); - free(infos); + free(infos); return 0; } - static void createChildTables() { char tblColsBuf[MAX_SQL_SIZE]; int len; @@ -6150,13 +6149,13 @@ static void queryResult() { static void testCmdLine() { - g_args.test_mode = INSERT_TEST; - insertTestProcess(); + g_args.test_mode = INSERT_TEST; + insertTestProcess(); - if (g_Dbs.insert_only) - return; - else - queryResult(); + if (g_Dbs.insert_only) + return; + else + queryResult(); } int main(int argc, char *argv[]) { @@ -6166,7 +6165,7 @@ int main(int argc, char *argv[]) { if (g_args.metaFile) { initOfInsertMeta(); - initOfQueryMeta(); + initOfQueryMeta(); if (false == getInfoFromJsonFile(g_args.metaFile)) { printf("Failed to read %s\n", g_args.metaFile); @@ -6180,12 +6179,12 @@ int main(int argc, char *argv[]) { if (NULL != g_args.sqlFile) { TAOS* qtaos = taos_connect( - g_Dbs.host, - g_Dbs.user, - g_Dbs.password, - g_Dbs.db[0].dbName, + g_Dbs.host, + g_Dbs.user, + g_Dbs.password, + g_Dbs.db[0].dbName, g_Dbs.port); - querySqlFile(qtaos, g_args.sqlFile); + querySqlFile(qtaos, g_args.sqlFile); taos_close(qtaos); } else { diff --git a/tests/pytest/tools/taosdemoTest.py b/tests/pytest/tools/taosdemoTest.py index 2ce9228c54..ff5921be60 100644 --- a/tests/pytest/tools/taosdemoTest.py +++ b/tests/pytest/tools/taosdemoTest.py @@ -51,7 +51,7 @@ class TDTestCase: else: tdLog.info("taosd found in %s" % buildPath) binPath = buildPath + "/build/bin/" - os.system("%staosdemo -y -M -t %d -n %d -x" % + os.system("%staosdemo -y -t %d -n %d" % (binPath, self.numberOfTables, self.numberOfRecords)) tdSql.execute("use test") diff --git a/tests/pytest/tools/taosdemoTest2.py b/tests/pytest/tools/taosdemoTest2.py index 75a79d0585..92f6fa1265 100644 --- a/tests/pytest/tools/taosdemoTest2.py +++ b/tests/pytest/tools/taosdemoTest2.py @@ -31,7 +31,7 @@ class TDTestCase: def insertDataAndAlterTable(self, threadID): if(threadID == 0): - os.system("taosdemo -M -y -t %d -n %d -x" % + os.system("taosdemo -y -t %d -n %d" % (self.numberOfTables, self.numberOfRecords)) if(threadID == 1): time.sleep(2) diff --git a/tests/pytest/tools/taosdemoTestWithoutMetric.py b/tests/pytest/tools/taosdemoTestWithoutMetric.py index 647d6a37cb..9687600563 100644 --- a/tests/pytest/tools/taosdemoTestWithoutMetric.py +++ b/tests/pytest/tools/taosdemoTestWithoutMetric.py @@ -50,7 +50,7 @@ class TDTestCase: else: tdLog.info("taosd found in %s" % buildPath) binPath = buildPath + "/build/bin/" - os.system("%staosdemo -y -t %d -n %d -x" % + os.system("%staosdemo -N -y -t %d -n %d" % (binPath, self.numberOfTables, self.numberOfRecords)) tdSql.query("show databases") -- GitLab