Feature/sangshuduo/td 5844 cmdline parameters align (#7229)
* [TD-5844]<feature>: make cmd line parameter similar. * fix test case align with taosdemo change. * fix windows stack overflow issue. * fix mac compile error. * fix taosdemo cmdline parameter in tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py
This commit is contained in:
parent
bacb85867a
commit
de4879f967
|
@ -76,7 +76,7 @@ extern char configDir[];
|
|||
#define COND_BUF_LEN (BUFFER_SIZE - 30)
|
||||
#define COL_BUFFER_LEN ((TSDB_COL_NAME_LEN + 15) * TSDB_MAX_COLUMNS)
|
||||
#define MAX_USERNAME_SIZE 64
|
||||
#define MAX_PASSWORD_SIZE 64
|
||||
#define MAX_PASSWORD_SIZE 16
|
||||
#define MAX_HOSTNAME_SIZE 253 // https://man7.org/linux/man-pages/man7/hostname.7.html
|
||||
#define MAX_TB_NAME_SIZE 64
|
||||
#define MAX_DATA_SIZE (16*TSDB_MAX_COLUMNS)+20 // max record len: 16*MAX_COLUMNS, timestamp string and ,('') need extra space
|
||||
|
@ -215,7 +215,7 @@ typedef struct SArguments_S {
|
|||
uint16_t port;
|
||||
uint16_t iface;
|
||||
char * user;
|
||||
char * password;
|
||||
char password[MAX_PASSWORD_SIZE];
|
||||
char * database;
|
||||
int replica;
|
||||
char * tb_prefix;
|
||||
|
@ -710,24 +710,24 @@ static void printHelp() {
|
|||
printf("%s%s%s%s\n", indent, "-u", indent,
|
||||
"The TDengine user name to use when connecting to the server. Default is 'root'.");
|
||||
#ifdef _TD_POWER_
|
||||
printf("%s%s%s%s\n", indent, "-P", indent,
|
||||
printf("%s%s%s%s\n", indent, "-p", indent,
|
||||
"The password to use when connecting to the server. Default is 'powerdb'.");
|
||||
printf("%s%s%s%s\n", indent, "-c", indent,
|
||||
"Configuration directory. Default is '/etc/power/'.");
|
||||
#elif (_TD_TQ_ == true)
|
||||
printf("%s%s%s%s\n", indent, "-P", indent,
|
||||
printf("%s%s%s%s\n", indent, "-p", indent,
|
||||
"The password to use when connecting to the server. Default is 'tqueue'.");
|
||||
printf("%s%s%s%s\n", indent, "-c", indent,
|
||||
"Configuration directory. Default is '/etc/tq/'.");
|
||||
#else
|
||||
printf("%s%s%s%s\n", indent, "-P", indent,
|
||||
printf("%s%s%s%s\n", indent, "-p", indent,
|
||||
"The password to use when connecting to the server. Default is 'taosdata'.");
|
||||
printf("%s%s%s%s\n", indent, "-c", indent,
|
||||
"Configuration directory. Default is '/etc/taos/'.");
|
||||
#endif
|
||||
printf("%s%s%s%s\n", indent, "-h", indent,
|
||||
"The host to connect to TDengine. Default is localhost.");
|
||||
printf("%s%s%s%s\n", indent, "-p", indent,
|
||||
printf("%s%s%s%s\n", indent, "-P", indent,
|
||||
"The TCP/IP port number to use for the connection. Default is 0.");
|
||||
printf("%s%s%s%s\n", indent, "-I", indent,
|
||||
#if STMT_IFACE_ENABLED == 1
|
||||
|
@ -827,11 +827,11 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
arguments->host = argv[++i];
|
||||
} else if (strcmp(argv[i], "-p") == 0) {
|
||||
} else if (strcmp(argv[i], "-P") == 0) {
|
||||
if ((argc == i+1) ||
|
||||
(!isStringNumber(argv[i+1]))) {
|
||||
printHelp();
|
||||
errorPrint("%s", "\n\t-p need a number following!\n");
|
||||
errorPrint("%s", "\n\t-P need a number following!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
arguments->port = atoi(argv[++i]);
|
||||
|
@ -861,13 +861,13 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
arguments->user = argv[++i];
|
||||
} else if (strcmp(argv[i], "-P") == 0) {
|
||||
if (argc == i+1) {
|
||||
printHelp();
|
||||
errorPrint("%s", "\n\t-P need a valid string following!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
} else if (strncmp(argv[i], "-p", 2) == 0) {
|
||||
if (strlen(argv[i]) == 2) {
|
||||
printf("Enter password:");
|
||||
scanf("%s", arguments->password);
|
||||
} else {
|
||||
tstrncpy(arguments->password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE);
|
||||
}
|
||||
arguments->password = argv[++i];
|
||||
} else if (strcmp(argv[i], "-o") == 0) {
|
||||
if (argc == i+1) {
|
||||
printHelp();
|
||||
|
@ -1065,7 +1065,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
|||
arguments->debug_print = true;
|
||||
} else if (strcmp(argv[i], "-gg") == 0) {
|
||||
arguments->verbose_print = true;
|
||||
} else if (strcmp(argv[i], "-pp") == 0) {
|
||||
} else if (strcmp(argv[i], "-PP") == 0) {
|
||||
arguments->performance_print = true;
|
||||
} else if (strcmp(argv[i], "-O") == 0) {
|
||||
if ((argc == i+1) ||
|
||||
|
@ -2318,15 +2318,15 @@ static void printfDbInfoForQueryToFile(
|
|||
}
|
||||
|
||||
static void printfQuerySystemInfo(TAOS * taos) {
|
||||
char filename[BUFFER_SIZE+1] = {0};
|
||||
char buffer[BUFFER_SIZE+1] = {0};
|
||||
char filename[MAX_FILE_NAME_LEN] = {0};
|
||||
char buffer[1024] = {0};
|
||||
TAOS_RES* res;
|
||||
|
||||
time_t t;
|
||||
struct tm* lt;
|
||||
time(&t);
|
||||
lt = localtime(&t);
|
||||
snprintf(filename, BUFFER_SIZE, "querySystemInfo-%d-%d-%d %d:%d:%d",
|
||||
snprintf(filename, MAX_FILE_NAME_LEN, "querySystemInfo-%d-%d-%d %d:%d:%d",
|
||||
lt->tm_year+1900, lt->tm_mon, lt->tm_mday, lt->tm_hour, lt->tm_min,
|
||||
lt->tm_sec);
|
||||
|
||||
|
@ -2358,12 +2358,12 @@ static void printfQuerySystemInfo(TAOS * taos) {
|
|||
printfDbInfoForQueryToFile(filename, dbInfos[i], i);
|
||||
|
||||
// show db.vgroups
|
||||
snprintf(buffer, BUFFER_SIZE, "show %s.vgroups;", dbInfos[i]->name);
|
||||
snprintf(buffer, 1024, "show %s.vgroups;", dbInfos[i]->name);
|
||||
res = taos_query(taos, buffer);
|
||||
xDumpResultToFile(filename, res);
|
||||
|
||||
// show db.stables
|
||||
snprintf(buffer, BUFFER_SIZE, "show %s.stables;", dbInfos[i]->name);
|
||||
snprintf(buffer, 1024, "show %s.stables;", dbInfos[i]->name);
|
||||
res = taos_query(taos, buffer);
|
||||
xDumpResultToFile(filename, res);
|
||||
free(dbInfos[i]);
|
||||
|
@ -2712,7 +2712,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
|
|||
char* dbName, char* sTblName, char** childTblNameOfSuperTbl,
|
||||
int64_t* childTblCountOfSuperTbl, int64_t limit, uint64_t offset) {
|
||||
|
||||
char command[BUFFER_SIZE] = "\0";
|
||||
char command[1024] = "\0";
|
||||
char limitBuf[100] = "\0";
|
||||
|
||||
TAOS_RES * res;
|
||||
|
@ -2726,7 +2726,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
|
|||
}
|
||||
|
||||
//get all child table name use cmd: select tbname from superTblName;
|
||||
snprintf(command, BUFFER_SIZE, "select tbname from %s.%s %s",
|
||||
snprintf(command, 1024, "select tbname from %s.%s %s",
|
||||
dbName, sTblName, limitBuf);
|
||||
|
||||
res = taos_query(taos, command);
|
||||
|
@ -2804,13 +2804,13 @@ static int getAllChildNameOfSuperTable(TAOS * taos, char* dbName,
|
|||
static int getSuperTableFromServer(TAOS * taos, char* dbName,
|
||||
SSuperTable* superTbls) {
|
||||
|
||||
char command[BUFFER_SIZE] = "\0";
|
||||
char command[1024] = "\0";
|
||||
TAOS_RES * res;
|
||||
TAOS_ROW row = NULL;
|
||||
int count = 0;
|
||||
|
||||
//get schema use cmd: describe superTblName;
|
||||
snprintf(command, BUFFER_SIZE, "describe %s.%s", dbName, superTbls->sTblName);
|
||||
snprintf(command, 1024, "describe %s.%s", dbName, superTbls->sTblName);
|
||||
res = taos_query(taos, command);
|
||||
int32_t code = taos_errno(res);
|
||||
if (code != 0) {
|
||||
|
@ -2890,7 +2890,8 @@ static int createSuperTable(
|
|||
TAOS * taos, char* dbName,
|
||||
SSuperTable* superTbl) {
|
||||
|
||||
char command[BUFFER_SIZE] = "\0";
|
||||
char *command = calloc(1, BUFFER_SIZE);
|
||||
assert(command);
|
||||
|
||||
char cols[COL_BUFFER_LEN] = "\0";
|
||||
int colIndex;
|
||||
|
@ -2901,6 +2902,7 @@ static int createSuperTable(
|
|||
if (superTbl->columnCount == 0) {
|
||||
errorPrint("%s() LN%d, super table column count is %d\n",
|
||||
__func__, __LINE__, superTbl->columnCount);
|
||||
free(command);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -2963,6 +2965,7 @@ static int createSuperTable(
|
|||
taos_close(taos);
|
||||
errorPrint("%s() LN%d, config error data type : %s\n",
|
||||
__func__, __LINE__, dataType);
|
||||
free(command);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
@ -2975,6 +2978,7 @@ static int createSuperTable(
|
|||
errorPrint("%s() LN%d, Failed when calloc, size:%d",
|
||||
__func__, __LINE__, len+1);
|
||||
taos_close(taos);
|
||||
free(command);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
@ -2985,6 +2989,7 @@ static int createSuperTable(
|
|||
if (superTbl->tagCount == 0) {
|
||||
errorPrint("%s() LN%d, super table tag count is %d\n",
|
||||
__func__, __LINE__, superTbl->tagCount);
|
||||
free(command);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -3050,6 +3055,7 @@ static int createSuperTable(
|
|||
taos_close(taos);
|
||||
errorPrint("%s() LN%d, config error tag type : %s\n",
|
||||
__func__, __LINE__, dataType);
|
||||
free(command);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
@ -3065,13 +3071,16 @@ static int createSuperTable(
|
|||
if (0 != queryDbExec(taos, command, NO_INSERT_TYPE, false)) {
|
||||
errorPrint( "create supertable %s failed!\n\n",
|
||||
superTbl->sTblName);
|
||||
free(command);
|
||||
return -1;
|
||||
}
|
||||
|
||||
debugPrint("create supertable %s success!\n\n", superTbl->sTblName);
|
||||
free(command);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int createDatabasesAndStables() {
|
||||
int createDatabasesAndStables(char *command) {
|
||||
TAOS * taos = NULL;
|
||||
int ret = 0;
|
||||
taos = taos_connect(g_Dbs.host, g_Dbs.user, g_Dbs.password, NULL, g_Dbs.port);
|
||||
|
@ -3079,8 +3088,7 @@ static int createDatabasesAndStables() {
|
|||
errorPrint( "Failed to connect to TDengine, reason:%s\n", taos_errstr(NULL));
|
||||
return -1;
|
||||
}
|
||||
char command[BUFFER_SIZE] = "\0";
|
||||
|
||||
|
||||
for (int i = 0; i < g_Dbs.dbCount; i++) {
|
||||
if (g_Dbs.db[i].drop) {
|
||||
sprintf(command, "drop database if exists %s;", g_Dbs.db[i].dbName);
|
||||
|
@ -7111,7 +7119,8 @@ static void startMultiThreadInsertData(int threads, char* db_name,
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
char buffer[BUFFER_SIZE];
|
||||
char *buffer = calloc(1, BUFFER_SIZE);
|
||||
assert(buffer);
|
||||
char *pstr = buffer;
|
||||
|
||||
if ((superTblInfo)
|
||||
|
@ -7140,8 +7149,11 @@ static void startMultiThreadInsertData(int threads, char* db_name,
|
|||
ret, taos_stmt_errstr(pThreadInfo->stmt));
|
||||
free(pids);
|
||||
free(infos);
|
||||
free(buffer);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
|
@ -7276,12 +7288,15 @@ static void *readTable(void *sarg) {
|
|||
threadInfo *pThreadInfo = (threadInfo *)sarg;
|
||||
TAOS *taos = pThreadInfo->taos;
|
||||
setThreadName("readTable");
|
||||
char command[BUFFER_SIZE] = "\0";
|
||||
char *command = calloc(1, BUFFER_SIZE);
|
||||
assert(command);
|
||||
|
||||
uint64_t sTime = pThreadInfo->start_time;
|
||||
char *tb_prefix = pThreadInfo->tb_prefix;
|
||||
FILE *fp = fopen(pThreadInfo->filePath, "a");
|
||||
if (NULL == fp) {
|
||||
errorPrint( "fopen %s fail, reason:%s.\n", pThreadInfo->filePath, strerror(errno));
|
||||
free(command);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -7320,6 +7335,7 @@ static void *readTable(void *sarg) {
|
|||
taos_free_result(pSql);
|
||||
taos_close(taos);
|
||||
fclose(fp);
|
||||
free(command);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -7340,6 +7356,7 @@ static void *readTable(void *sarg) {
|
|||
}
|
||||
fprintf(fp, "\n");
|
||||
fclose(fp);
|
||||
free(command);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
@ -7349,10 +7366,13 @@ static void *readMetric(void *sarg) {
|
|||
threadInfo *pThreadInfo = (threadInfo *)sarg;
|
||||
TAOS *taos = pThreadInfo->taos;
|
||||
setThreadName("readMetric");
|
||||
char command[BUFFER_SIZE] = "\0";
|
||||
char *command = calloc(1, BUFFER_SIZE);
|
||||
assert(command);
|
||||
|
||||
FILE *fp = fopen(pThreadInfo->filePath, "a");
|
||||
if (NULL == fp) {
|
||||
printf("fopen %s fail, reason:%s.\n", pThreadInfo->filePath, strerror(errno));
|
||||
free(command);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -7397,6 +7417,7 @@ static void *readMetric(void *sarg) {
|
|||
taos_free_result(pSql);
|
||||
taos_close(taos);
|
||||
fclose(fp);
|
||||
free(command);
|
||||
return NULL;
|
||||
}
|
||||
int count = 0;
|
||||
|
@ -7414,6 +7435,7 @@ static void *readMetric(void *sarg) {
|
|||
fprintf(fp, "\n");
|
||||
}
|
||||
fclose(fp);
|
||||
free(command);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
@ -7450,11 +7472,16 @@ static int insertTestProcess() {
|
|||
init_rand_data();
|
||||
|
||||
// create database and super tables
|
||||
if(createDatabasesAndStables() != 0) {
|
||||
char *cmdBuffer = calloc(1, BUFFER_SIZE);
|
||||
assert(cmdBuffer);
|
||||
|
||||
if(createDatabasesAndStables(cmdBuffer) != 0) {
|
||||
if (g_fpOfInsertResult)
|
||||
fclose(g_fpOfInsertResult);
|
||||
free(cmdBuffer);
|
||||
return -1;
|
||||
}
|
||||
free(cmdBuffer);
|
||||
|
||||
// pretreatement
|
||||
if (prepareSampleData() != 0) {
|
||||
|
@ -7623,7 +7650,9 @@ static void replaceChildTblName(char* inSql, char* outSql, int tblIndex) {
|
|||
}
|
||||
|
||||
static void *superTableQuery(void *sarg) {
|
||||
char sqlstr[BUFFER_SIZE];
|
||||
char *sqlstr = calloc(1, BUFFER_SIZE);
|
||||
assert(sqlstr);
|
||||
|
||||
threadInfo *pThreadInfo = (threadInfo *)sarg;
|
||||
|
||||
setThreadName("superTableQuery");
|
||||
|
@ -7638,6 +7667,7 @@ static void *superTableQuery(void *sarg) {
|
|||
if (taos == NULL) {
|
||||
errorPrint("[%d] Failed to connect to TDengine, reason:%s\n",
|
||||
pThreadInfo->threadID, taos_errstr(NULL));
|
||||
free(sqlstr);
|
||||
return NULL;
|
||||
} else {
|
||||
pThreadInfo->taos = taos;
|
||||
|
@ -7662,7 +7692,7 @@ static void *superTableQuery(void *sarg) {
|
|||
st = taosGetTimestampMs();
|
||||
for (int i = pThreadInfo->start_table_from; i <= pThreadInfo->end_table_to; i++) {
|
||||
for (int j = 0; j < g_queryInfo.superQueryInfo.sqlCount; j++) {
|
||||
memset(sqlstr,0,sizeof(sqlstr));
|
||||
memset(sqlstr, 0, BUFFER_SIZE);
|
||||
replaceChildTblName(g_queryInfo.superQueryInfo.sql[j], sqlstr, i);
|
||||
if (g_queryInfo.superQueryInfo.result[j][0] != '\0') {
|
||||
sprintf(pThreadInfo->filePath, "%s-%d",
|
||||
|
@ -7693,6 +7723,7 @@ static void *superTableQuery(void *sarg) {
|
|||
(double)(et - st)/1000.0);
|
||||
}
|
||||
|
||||
free(sqlstr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -7926,7 +7957,9 @@ static TAOS_SUB* subscribeImpl(
|
|||
|
||||
static void *superSubscribe(void *sarg) {
|
||||
threadInfo *pThreadInfo = (threadInfo *)sarg;
|
||||
char subSqlstr[BUFFER_SIZE];
|
||||
char *subSqlStr = calloc(1, BUFFER_SIZE);
|
||||
assert(subSqlStr);
|
||||
|
||||
TAOS_SUB* tsub[MAX_QUERY_SQL_COUNT] = {0};
|
||||
uint64_t tsubSeq;
|
||||
|
||||
|
@ -7935,6 +7968,7 @@ static void *superSubscribe(void *sarg) {
|
|||
if (pThreadInfo->ntables > MAX_QUERY_SQL_COUNT) {
|
||||
errorPrint("The table number(%"PRId64") of the thread is more than max query sql count: %d\n",
|
||||
pThreadInfo->ntables, MAX_QUERY_SQL_COUNT);
|
||||
free(subSqlStr);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
@ -7947,6 +7981,7 @@ static void *superSubscribe(void *sarg) {
|
|||
if (pThreadInfo->taos == NULL) {
|
||||
errorPrint("[%d] Failed to connect to TDengine, reason:%s\n",
|
||||
pThreadInfo->threadID, taos_errstr(NULL));
|
||||
free(subSqlStr);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -7957,6 +7992,7 @@ static void *superSubscribe(void *sarg) {
|
|||
taos_close(pThreadInfo->taos);
|
||||
errorPrint( "use database %s failed!\n\n",
|
||||
g_queryInfo.dbName);
|
||||
free(subSqlStr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -7971,25 +8007,26 @@ static void *superSubscribe(void *sarg) {
|
|||
pThreadInfo->end_table_to, i);
|
||||
sprintf(topic, "taosdemo-subscribe-%"PRIu64"-%"PRIu64"",
|
||||
i, pThreadInfo->querySeq);
|
||||
memset(subSqlstr, 0, sizeof(subSqlstr));
|
||||
memset(subSqlStr, 0, BUFFER_SIZE);
|
||||
replaceChildTblName(
|
||||
g_queryInfo.superQueryInfo.sql[pThreadInfo->querySeq],
|
||||
subSqlstr, i);
|
||||
subSqlStr, i);
|
||||
if (g_queryInfo.superQueryInfo.result[pThreadInfo->querySeq][0] != 0) {
|
||||
sprintf(pThreadInfo->filePath, "%s-%d",
|
||||
g_queryInfo.superQueryInfo.result[pThreadInfo->querySeq],
|
||||
pThreadInfo->threadID);
|
||||
}
|
||||
|
||||
verbosePrint("%s() LN%d, [%d] subSqlstr: %s\n",
|
||||
__func__, __LINE__, pThreadInfo->threadID, subSqlstr);
|
||||
verbosePrint("%s() LN%d, [%d] subSqlStr: %s\n",
|
||||
__func__, __LINE__, pThreadInfo->threadID, subSqlStr);
|
||||
tsub[tsubSeq] = subscribeImpl(
|
||||
STABLE_CLASS,
|
||||
pThreadInfo, subSqlstr, topic,
|
||||
pThreadInfo, subSqlStr, topic,
|
||||
g_queryInfo.superQueryInfo.subscribeRestart,
|
||||
g_queryInfo.superQueryInfo.subscribeInterval);
|
||||
if (NULL == tsub[tsubSeq]) {
|
||||
taos_close(pThreadInfo->taos);
|
||||
free(subSqlStr);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -8046,12 +8083,13 @@ static void *superSubscribe(void *sarg) {
|
|||
consumed[tsubSeq]= 0;
|
||||
tsub[tsubSeq] = subscribeImpl(
|
||||
STABLE_CLASS,
|
||||
pThreadInfo, subSqlstr, topic,
|
||||
pThreadInfo, subSqlStr, topic,
|
||||
g_queryInfo.superQueryInfo.subscribeRestart,
|
||||
g_queryInfo.superQueryInfo.subscribeInterval
|
||||
);
|
||||
if (NULL == tsub[tsubSeq]) {
|
||||
taos_close(pThreadInfo->taos);
|
||||
free(subSqlStr);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -8071,6 +8109,7 @@ static void *superSubscribe(void *sarg) {
|
|||
}
|
||||
|
||||
taos_close(pThreadInfo->taos);
|
||||
free(subSqlStr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -8373,9 +8412,7 @@ static void setParaFromArg() {
|
|||
tstrncpy(g_Dbs.user, g_args.user, MAX_USERNAME_SIZE);
|
||||
}
|
||||
|
||||
if (g_args.password) {
|
||||
tstrncpy(g_Dbs.password, g_args.password, MAX_PASSWORD_SIZE);
|
||||
}
|
||||
tstrncpy(g_Dbs.password, g_args.password, MAX_PASSWORD_SIZE);
|
||||
|
||||
if (g_args.port) {
|
||||
g_Dbs.port = g_args.port;
|
||||
|
|
|
@ -36,7 +36,7 @@ class TDTestCase:
|
|||
if ("taosd" in files):
|
||||
rootRealPath = os.path.dirname(os.path.realpath(root))
|
||||
if ("packaging" not in rootRealPath):
|
||||
buildPath = root[:len(root)-len("/build/bin")]
|
||||
buildPath = root[:len(root) - len("/build/bin")]
|
||||
break
|
||||
return buildPath
|
||||
|
||||
|
@ -46,14 +46,15 @@ class TDTestCase:
|
|||
tdLog.exit("taosd not found!")
|
||||
else:
|
||||
tdLog.info("taosd found in %s" % buildPath)
|
||||
binPath = buildPath+ "/build/bin/"
|
||||
binPath = buildPath + "/build/bin/"
|
||||
|
||||
|
||||
# insert: create one or mutiple tables per sql and insert multiple rows per sql
|
||||
# insert data from a special timestamp
|
||||
# check stable stb0
|
||||
|
||||
os.system("%staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json -y " % binPath)
|
||||
os.system(
|
||||
"%staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json -y " %
|
||||
binPath)
|
||||
tdSql.execute("use nsdb")
|
||||
tdSql.query("show stables")
|
||||
tdSql.checkData(0, 4, 100)
|
||||
|
@ -64,9 +65,9 @@ class TDTestCase:
|
|||
tdSql.query("select count(*) from stb0")
|
||||
tdSql.checkData(0, 0, 10000)
|
||||
tdSql.query("describe stb0")
|
||||
tdSql.checkDataType(9, 1,"TIMESTAMP")
|
||||
tdSql.checkDataType(9, 1, "TIMESTAMP")
|
||||
tdSql.query("select last(ts) from stb0")
|
||||
tdSql.checkData(0, 0,"2021-07-01 00:00:00.990000000")
|
||||
tdSql.checkData(0, 0, "2021-07-01 00:00:00.990000000")
|
||||
|
||||
# check stable stb1 which is insert with disord
|
||||
|
||||
|
@ -78,16 +79,18 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 0, 10000)
|
||||
# check c8 is an nano timestamp
|
||||
tdSql.query("describe stb1")
|
||||
tdSql.checkDataType(9, 1,"TIMESTAMP")
|
||||
tdSql.checkDataType(9, 1, "TIMESTAMP")
|
||||
# check insert timestamp_step is nano_second
|
||||
tdSql.query("select last(ts) from stb1")
|
||||
tdSql.checkData(0, 0,"2021-07-01 00:00:00.990000000")
|
||||
|
||||
tdSql.checkData(0, 0, "2021-07-01 00:00:00.990000000")
|
||||
|
||||
# insert data from now time
|
||||
|
||||
# check stable stb0
|
||||
os.system("%staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseNow.json -y " % binPath)
|
||||
|
||||
os.system(
|
||||
"%staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseNow.json -y " %
|
||||
binPath)
|
||||
|
||||
tdSql.execute("use nsdb2")
|
||||
tdSql.query("show stables")
|
||||
tdSql.checkData(0, 4, 100)
|
||||
|
@ -99,11 +102,14 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 0, 10000)
|
||||
# check c8 is an nano timestamp
|
||||
tdSql.query("describe stb0")
|
||||
tdSql.checkDataType(9,1,"TIMESTAMP")
|
||||
tdSql.checkDataType(9, 1, "TIMESTAMP")
|
||||
|
||||
# insert by csv files and timetamp is long int , strings in ts and cols
|
||||
|
||||
os.system("%staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json -y " % binPath)
|
||||
# insert by csv files and timetamp is long int , strings in ts and
|
||||
# cols
|
||||
|
||||
os.system(
|
||||
"%staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json -y " %
|
||||
binPath)
|
||||
tdSql.execute("use nsdbcsv")
|
||||
tdSql.query("show stables")
|
||||
tdSql.checkData(0, 4, 100)
|
||||
|
@ -111,29 +117,37 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 0, 10000)
|
||||
tdSql.query("describe stb0")
|
||||
tdSql.checkDataType(3, 1, "TIMESTAMP")
|
||||
tdSql.query("select count(*) from stb0 where ts > \"2021-07-01 00:00:00.490000000\"")
|
||||
tdSql.query(
|
||||
"select count(*) from stb0 where ts > \"2021-07-01 00:00:00.490000000\"")
|
||||
tdSql.checkData(0, 0, 5000)
|
||||
tdSql.query("select count(*) from stb0 where ts < 1626918583000000000")
|
||||
tdSql.checkData(0, 0, 10000)
|
||||
|
||||
os.system("rm -rf ./insert_res.txt")
|
||||
os.system("rm -rf tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNano*.py.sql")
|
||||
|
||||
# taosdemo test insert with command and parameter , detals show taosdemo --help
|
||||
os.system("%staosdemo -u root -P taosdata -p 6030 -a 1 -m pre -n 10 -T 20 -t 60 -o res.txt -y " % binPath)
|
||||
os.system("rm -rf ./insert_res.txt")
|
||||
os.system(
|
||||
"rm -rf tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNano*.py.sql")
|
||||
|
||||
# taosdemo test insert with command and parameter , detals show
|
||||
# taosdemo --help
|
||||
os.system(
|
||||
"%staosdemo -u root -ptaosdata -P 6030 -a 1 -m pre -n 10 -T 20 -t 60 -o res.txt -y " %
|
||||
binPath)
|
||||
tdSql.query("select count(*) from test.meters")
|
||||
tdSql.checkData(0, 0, 600)
|
||||
# check taosdemo -s
|
||||
|
||||
sqls_ls = ['drop database if exists nsdbsql;','create database nsdbsql precision "ns" keep 3600 days 6 update 1;',
|
||||
'use nsdbsql;','CREATE STABLE meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupdId int);',
|
||||
'CREATE TABLE d1001 USING meters TAGS ("Beijing.Chaoyang", 2);',
|
||||
'INSERT INTO d1001 USING METERS TAGS ("Beijng.Chaoyang", 2) VALUES (now, 10.2, 219, 0.32);',
|
||||
'INSERT INTO d1001 USING METERS TAGS ("Beijng.Chaoyang", 2) VALUES (now, 85, 32, 0.76);']
|
||||
sqls_ls = [
|
||||
'drop database if exists nsdbsql;',
|
||||
'create database nsdbsql precision "ns" keep 3600 days 6 update 1;',
|
||||
'use nsdbsql;',
|
||||
'CREATE STABLE meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupdId int);',
|
||||
'CREATE TABLE d1001 USING meters TAGS ("Beijing.Chaoyang", 2);',
|
||||
'INSERT INTO d1001 USING METERS TAGS ("Beijng.Chaoyang", 2) VALUES (now, 10.2, 219, 0.32);',
|
||||
'INSERT INTO d1001 USING METERS TAGS ("Beijng.Chaoyang", 2) VALUES (now, 85, 32, 0.76);']
|
||||
|
||||
with open("./taosdemoTestNanoCreateDB.sql",mode ="a" ) as sql_files:
|
||||
with open("./taosdemoTestNanoCreateDB.sql", mode="a") as sql_files:
|
||||
for sql in sqls_ls:
|
||||
sql_files.write(sql+"\n")
|
||||
sql_files.write(sql + "\n")
|
||||
sql_files.close()
|
||||
|
||||
sleep(10)
|
||||
|
@ -141,11 +155,10 @@ class TDTestCase:
|
|||
os.system("%staosdemo -s taosdemoTestNanoCreateDB.sql -y " % binPath)
|
||||
tdSql.query("select count(*) from nsdbsql.meters")
|
||||
tdSql.checkData(0, 0, 2)
|
||||
|
||||
|
||||
os.system("rm -rf ./res.txt")
|
||||
os.system("rm -rf ./*.py.sql")
|
||||
os.system("rm -rf ./taosdemoTestNanoCreateDB.sql")
|
||||
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
|
|
|
@ -120,7 +120,7 @@ class TDTestCase:
|
|||
os.system("rm -rf tools/taosdemoAllTest/taosdemoTestSupportNano*.py.sql")
|
||||
|
||||
# taosdemo test insert with command and parameter , detals show taosdemo --help
|
||||
os.system("%staosdemo -u root -P taosdata -p 6030 -a 1 -m pre -n 10 -T 20 -t 60 -o res.txt -y " % binPath)
|
||||
os.system("%staosdemo -u root -ptaosdata -P 6030 -a 1 -m pre -n 10 -T 20 -t 60 -o res.txt -y " % binPath)
|
||||
tdSql.query("select count(*) from test.meters")
|
||||
tdSql.checkData(0, 0, 600)
|
||||
# check taosdemo -s
|
||||
|
|
|
@ -49,7 +49,7 @@ class TDTestCase:
|
|||
else:
|
||||
tdLog.info("taosd found in %s" % buildPath)
|
||||
binPath = buildPath + "/build/bin/"
|
||||
taosdemoCmd = "%staosdemo -f tools/insert-interlace.json -pp 2>&1 | grep sleep | wc -l" % binPath
|
||||
taosdemoCmd = "%staosdemo -f tools/insert-interlace.json -PP 2>&1 | grep sleep | wc -l" % binPath
|
||||
sleepTimes = subprocess.check_output(
|
||||
taosdemoCmd, shell=True).decode("utf-8")
|
||||
print("sleep times: %d" % int(sleepTimes))
|
||||
|
|
Loading…
Reference in New Issue