[TD-5136]<feature>: taosdemo simulate real senario. (#6833)
* [TD-5136]<feature>: taosdemo simulate real senario. * update test case according to taosdemo change
This commit is contained in:
parent
f3279fa698
commit
4486cae180
|
@ -236,6 +236,7 @@ typedef struct SArguments_S {
|
||||||
char ** arg_list;
|
char ** arg_list;
|
||||||
uint64_t totalInsertRows;
|
uint64_t totalInsertRows;
|
||||||
uint64_t totalAffectedRows;
|
uint64_t totalAffectedRows;
|
||||||
|
bool demo_mode; // use default column name and semi-random data
|
||||||
} SArguments;
|
} SArguments;
|
||||||
|
|
||||||
typedef struct SColumn_S {
|
typedef struct SColumn_S {
|
||||||
|
@ -552,6 +553,8 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr,
|
||||||
uint16_t port, char* sqlstr, threadInfo *pThreadInfo);
|
uint16_t port, char* sqlstr, threadInfo *pThreadInfo);
|
||||||
static int64_t getTSRandTail(int64_t timeStampStep, int32_t seq,
|
static int64_t getTSRandTail(int64_t timeStampStep, int32_t seq,
|
||||||
int disorderRatio, int disorderRange);
|
int disorderRatio, int disorderRange);
|
||||||
|
static bool getInfoFromJsonFile(char* file);
|
||||||
|
static void init_rand_data();
|
||||||
|
|
||||||
/* ************ Global variables ************ */
|
/* ************ Global variables ************ */
|
||||||
|
|
||||||
|
@ -569,16 +572,16 @@ SArguments g_args = {
|
||||||
6030, // port
|
6030, // port
|
||||||
TAOSC_IFACE, // iface
|
TAOSC_IFACE, // iface
|
||||||
"root", // user
|
"root", // user
|
||||||
#ifdef _TD_POWER_
|
#ifdef _TD_POWER_
|
||||||
"powerdb", // password
|
"powerdb", // password
|
||||||
#elif (_TD_TQ_ == true)
|
#elif (_TD_TQ_ == true)
|
||||||
"tqueue", // password
|
"tqueue", // password
|
||||||
#else
|
#else
|
||||||
"taosdata", // password
|
"taosdata", // password
|
||||||
#endif
|
#endif
|
||||||
"test", // database
|
"test", // database
|
||||||
1, // replica
|
1, // replica
|
||||||
"t", // tb_prefix
|
"d", // tb_prefix
|
||||||
NULL, // sqlFile
|
NULL, // sqlFile
|
||||||
true, // use_metric
|
true, // use_metric
|
||||||
true, // drop_database
|
true, // drop_database
|
||||||
|
@ -590,10 +593,9 @@ SArguments g_args = {
|
||||||
"./output.txt", // output_file
|
"./output.txt", // output_file
|
||||||
0, // mode : sync or async
|
0, // mode : sync or async
|
||||||
{
|
{
|
||||||
|
"FLOAT", // datatype
|
||||||
"INT", // datatype
|
"INT", // datatype
|
||||||
"INT", // datatype
|
"FLOAT", // datatype
|
||||||
"INT", // datatype
|
|
||||||
"INT", // datatype
|
|
||||||
},
|
},
|
||||||
16, // len_of_binary
|
16, // len_of_binary
|
||||||
4, // num_of_CPR
|
4, // num_of_CPR
|
||||||
|
@ -609,7 +611,10 @@ SArguments g_args = {
|
||||||
0, // disorderRatio
|
0, // disorderRatio
|
||||||
1000, // disorderRange
|
1000, // disorderRange
|
||||||
1, // method_of_delete
|
1, // method_of_delete
|
||||||
NULL // arg_list
|
NULL, // arg_list
|
||||||
|
0, // totalInsertRows;
|
||||||
|
0, // totalAffectedRows;
|
||||||
|
true, // demo_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -709,7 +714,7 @@ static void printHelp() {
|
||||||
printf("%s%s%s%s\n", indent, "-a", indent,
|
printf("%s%s%s%s\n", indent, "-a", indent,
|
||||||
"Set the replica parameters of the database, Default 1, min: 1, max: 3.");
|
"Set the replica parameters of the database, Default 1, min: 1, max: 3.");
|
||||||
printf("%s%s%s%s\n", indent, "-m", indent,
|
printf("%s%s%s%s\n", indent, "-m", indent,
|
||||||
"Table prefix name. Default is 't'.");
|
"Table prefix name. Default is 'd'.");
|
||||||
printf("%s%s%s%s\n", indent, "-s", indent, "The select sql file.");
|
printf("%s%s%s%s\n", indent, "-s", indent, "The select sql file.");
|
||||||
printf("%s%s%s%s\n", indent, "-N", indent, "Use normal table flag.");
|
printf("%s%s%s%s\n", indent, "-N", indent, "Use normal table flag.");
|
||||||
printf("%s%s%s%s\n", indent, "-o", indent,
|
printf("%s%s%s%s\n", indent, "-o", indent,
|
||||||
|
@ -717,11 +722,11 @@ static void printHelp() {
|
||||||
printf("%s%s%s%s\n", indent, "-q", indent,
|
printf("%s%s%s%s\n", indent, "-q", indent,
|
||||||
"Query mode -- 0: SYNC, 1: ASYNC. Default is SYNC.");
|
"Query mode -- 0: SYNC, 1: ASYNC. Default is SYNC.");
|
||||||
printf("%s%s%s%s\n", indent, "-b", indent,
|
printf("%s%s%s%s\n", indent, "-b", indent,
|
||||||
"The data_type of columns, default: INT,INT,INT,INT.");
|
"The data_type of columns, default: FLOAT, INT, FLOAT.");
|
||||||
printf("%s%s%s%s\n", indent, "-w", indent,
|
printf("%s%s%s%s\n", indent, "-w", indent,
|
||||||
"The length of data_type 'BINARY' or 'NCHAR'. Default is 16");
|
"The length of data_type 'BINARY' or 'NCHAR'. Default is 16");
|
||||||
printf("%s%s%s%s%d\n", indent, "-l", indent,
|
printf("%s%s%s%s%d\n", indent, "-l", indent,
|
||||||
"The number of columns per record. Default is 4. Max values is ",
|
"The number of columns per record. Default is 3. Max values is ",
|
||||||
MAX_NUM_DATATYPE);
|
MAX_NUM_DATATYPE);
|
||||||
printf("%s%s%s%s\n", indent, "-T", indent,
|
printf("%s%s%s%s\n", indent, "-T", indent,
|
||||||
"The number of threads. Default is 10.");
|
"The number of threads. Default is 10.");
|
||||||
|
@ -733,6 +738,10 @@ static void printHelp() {
|
||||||
"The number of tables. Default is 10000.");
|
"The number of tables. Default is 10000.");
|
||||||
printf("%s%s%s%s\n", indent, "-n", indent,
|
printf("%s%s%s%s\n", indent, "-n", indent,
|
||||||
"The number of records per table. Default is 10000.");
|
"The number of records per table. Default is 10000.");
|
||||||
|
printf("%s%s%s%s\n", indent, "-M", indent,
|
||||||
|
"The value of records generated are totally random.");
|
||||||
|
printf("%s%s%s%s\n", indent, indent, indent,
|
||||||
|
" The default is to simulate power equipment senario.");
|
||||||
printf("%s%s%s%s\n", indent, "-x", indent, "Not insert only flag.");
|
printf("%s%s%s%s\n", indent, "-x", indent, "Not insert only flag.");
|
||||||
printf("%s%s%s%s\n", indent, "-y", indent, "Default input yes for prompt.");
|
printf("%s%s%s%s\n", indent, "-y", indent, "Default input yes for prompt.");
|
||||||
printf("%s%s%s%s\n", indent, "-O", indent,
|
printf("%s%s%s%s\n", indent, "-O", indent,
|
||||||
|
@ -745,8 +754,8 @@ static void printHelp() {
|
||||||
"Print version info.");
|
"Print version info.");
|
||||||
printf("%s%s%s%s\n", indent, "--help\t", indent,
|
printf("%s%s%s%s\n", indent, "--help\t", indent,
|
||||||
"Print command line arguments list info.");
|
"Print command line arguments list info.");
|
||||||
/* printf("%s%s%s%s\n", indent, "-D", indent,
|
/* printf("%s%s%s%s\n", indent, "-D", indent,
|
||||||
"if elete database if exists. 0: no, 1: yes, default is 1");
|
"Delete database if exists. 0: no, 1: yes, default is 1");
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -769,6 +778,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
||||||
|
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (strcmp(argv[i], "-f") == 0) {
|
if (strcmp(argv[i], "-f") == 0) {
|
||||||
|
arguments->demo_mode = false;
|
||||||
arguments->metaFile = argv[++i];
|
arguments->metaFile = argv[++i];
|
||||||
} else if (strcmp(argv[i], "-c") == 0) {
|
} else if (strcmp(argv[i], "-c") == 0) {
|
||||||
if (argc == i+1) {
|
if (argc == i+1) {
|
||||||
|
@ -911,6 +921,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
||||||
}
|
}
|
||||||
arguments->database = argv[++i];
|
arguments->database = argv[++i];
|
||||||
} else if (strcmp(argv[i], "-l") == 0) {
|
} else if (strcmp(argv[i], "-l") == 0) {
|
||||||
|
arguments->demo_mode = false;
|
||||||
if (argc == i+1) {
|
if (argc == i+1) {
|
||||||
if (!isStringNumber(argv[i+1])) {
|
if (!isStringNumber(argv[i+1])) {
|
||||||
printHelp();
|
printHelp();
|
||||||
|
@ -931,6 +942,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (strcmp(argv[i], "-b") == 0) {
|
} else if (strcmp(argv[i], "-b") == 0) {
|
||||||
|
arguments->demo_mode = false;
|
||||||
if (argc == i+1) {
|
if (argc == i+1) {
|
||||||
printHelp();
|
printHelp();
|
||||||
errorPrint("%s", "\n\t-b need valid string following!\n");
|
errorPrint("%s", "\n\t-b need valid string following!\n");
|
||||||
|
@ -1000,6 +1012,8 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
||||||
arguments->tb_prefix = argv[++i];
|
arguments->tb_prefix = argv[++i];
|
||||||
} else if (strcmp(argv[i], "-N") == 0) {
|
} else if (strcmp(argv[i], "-N") == 0) {
|
||||||
arguments->use_metric = false;
|
arguments->use_metric = false;
|
||||||
|
} else if (strcmp(argv[i], "-M") == 0) {
|
||||||
|
arguments->demo_mode = false;
|
||||||
} else if (strcmp(argv[i], "-x") == 0) {
|
} else if (strcmp(argv[i], "-x") == 0) {
|
||||||
arguments->insert_only = false;
|
arguments->insert_only = false;
|
||||||
} else if (strcmp(argv[i], "-y") == 0) {
|
} else if (strcmp(argv[i], "-y") == 0) {
|
||||||
|
@ -1133,8 +1147,6 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool getInfoFromJsonFile(char* file);
|
|
||||||
static void init_rand_data();
|
|
||||||
static void tmfclose(FILE *fp) {
|
static void tmfclose(FILE *fp) {
|
||||||
if (NULL != fp) {
|
if (NULL != fp) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -1231,7 +1243,8 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) {
|
||||||
//printf("query result:%s\n", temp);
|
//printf("query result:%s\n", temp);
|
||||||
memcpy(databuf + totalLen, temp, len);
|
memcpy(databuf + totalLen, temp, len);
|
||||||
totalLen += len;
|
totalLen += len;
|
||||||
verbosePrint("%s() LN%d, totalLen: %"PRId64"\n", __func__, __LINE__, totalLen);
|
verbosePrint("%s() LN%d, totalLen: %"PRId64"\n",
|
||||||
|
__func__, __LINE__, totalLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
verbosePrint("%s() LN%d, databuf=%s resultFile=%s\n",
|
verbosePrint("%s() LN%d, databuf=%s resultFile=%s\n",
|
||||||
|
@ -1314,6 +1327,27 @@ static float rand_float(){
|
||||||
return randfloat[cursor];
|
return randfloat[cursor];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static float demo_current_float(){
|
||||||
|
static int cursor;
|
||||||
|
cursor++;
|
||||||
|
cursor = cursor % MAX_PREPARED_RAND;
|
||||||
|
return (float)(5 + randfloat[cursor] / 1000000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t demo_voltage_int(){
|
||||||
|
static int cursor;
|
||||||
|
cursor++;
|
||||||
|
cursor = cursor % MAX_PREPARED_RAND;
|
||||||
|
return 210 + randint[cursor] % 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
static float demo_phase_float(){
|
||||||
|
static int cursor;
|
||||||
|
cursor++;
|
||||||
|
cursor = cursor % MAX_PREPARED_RAND;
|
||||||
|
return (float)(120 + randfloat[cursor] / 1000000000);
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static const char charNum[] = "0123456789";
|
static const char charNum[] = "0123456789";
|
||||||
|
|
||||||
|
@ -1351,7 +1385,6 @@ static double rand_double() {
|
||||||
cursor++;
|
cursor++;
|
||||||
cursor = cursor % MAX_PREPARED_RAND;
|
cursor = cursor % MAX_PREPARED_RAND;
|
||||||
return randdouble[cursor];
|
return randdouble[cursor];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_rand_data() {
|
static void init_rand_data() {
|
||||||
|
@ -1386,6 +1419,11 @@ static void init_rand_data() {
|
||||||
static int printfInsertMeta() {
|
static int printfInsertMeta() {
|
||||||
SHOW_PARSE_RESULT_START();
|
SHOW_PARSE_RESULT_START();
|
||||||
|
|
||||||
|
if (g_args.demo_mode)
|
||||||
|
printf("\ntaosdemo is simulating data generated by power equipments monitoring...\n\n");
|
||||||
|
else
|
||||||
|
printf("\ntaosdemo is simulating random data as you request..\n\n");
|
||||||
|
|
||||||
printf("interface: \033[33m%s\033[0m\n",
|
printf("interface: \033[33m%s\033[0m\n",
|
||||||
(g_args.iface==TAOSC_IFACE)?"taosc":(g_args.iface==REST_IFACE)?"rest":"stmt");
|
(g_args.iface==TAOSC_IFACE)?"taosc":(g_args.iface==REST_IFACE)?"rest":"stmt");
|
||||||
printf("host: \033[33m%s:%u\033[0m\n",
|
printf("host: \033[33m%s:%u\033[0m\n",
|
||||||
|
@ -1519,7 +1557,7 @@ static int printfInsertMeta() {
|
||||||
}
|
}
|
||||||
printf(" insertRows: \033[33m%"PRId64"\033[0m\n",
|
printf(" insertRows: \033[33m%"PRId64"\033[0m\n",
|
||||||
g_Dbs.db[i].superTbls[j].insertRows);
|
g_Dbs.db[i].superTbls[j].insertRows);
|
||||||
/*
|
/*
|
||||||
if (0 == g_Dbs.db[i].superTbls[j].multiThreadWriteOneTbl) {
|
if (0 == g_Dbs.db[i].superTbls[j].multiThreadWriteOneTbl) {
|
||||||
printf(" multiThreadWriteOneTbl: \033[33mno\033[0m\n");
|
printf(" multiThreadWriteOneTbl: \033[33mno\033[0m\n");
|
||||||
}else {
|
}else {
|
||||||
|
@ -1707,7 +1745,7 @@ static void printfInsertMetaToFile(FILE* fp) {
|
||||||
fprintf(fp, " stable insert interval: %"PRIu64"\n",
|
fprintf(fp, " stable insert interval: %"PRIu64"\n",
|
||||||
g_Dbs.db[i].superTbls[j].insertInterval);
|
g_Dbs.db[i].superTbls[j].insertInterval);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
if (0 == g_Dbs.db[i].superTbls[j].multiThreadWriteOneTbl) {
|
if (0 == g_Dbs.db[i].superTbls[j].multiThreadWriteOneTbl) {
|
||||||
fprintf(fp, " multiThreadWriteOneTbl: no\n");
|
fprintf(fp, " multiThreadWriteOneTbl: no\n");
|
||||||
}else {
|
}else {
|
||||||
|
@ -1863,7 +1901,7 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
|
||||||
tt = (time_t)(val / 1000);
|
tt = (time_t)(val / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* comment out as it make testcases like select_with_tags.sim fail.
|
/* comment out as it make testcases like select_with_tags.sim fail.
|
||||||
but in windows, this may cause the call to localtime crash if tt < 0,
|
but in windows, this may cause the call to localtime crash if tt < 0,
|
||||||
need to find a better solution.
|
need to find a better solution.
|
||||||
if (tt < 0) {
|
if (tt < 0) {
|
||||||
|
@ -1943,7 +1981,8 @@ static int xDumpResultToFile(const char* fname, TAOS_RES* tres) {
|
||||||
|
|
||||||
FILE* fp = fopen(fname, "at");
|
FILE* fp = fopen(fname, "at");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
errorPrint("%s() LN%d, failed to open file: %s\n", __func__, __LINE__, fname);
|
errorPrint("%s() LN%d, failed to open file: %s\n",
|
||||||
|
__func__, __LINE__, fname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1966,7 +2005,8 @@ static int xDumpResultToFile(const char* fname, TAOS_RES* tres) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
fputc(',', fp);
|
fputc(',', fp);
|
||||||
}
|
}
|
||||||
xDumpFieldToFile(fp, (const char*)row[i], fields +i, length[i], precision);
|
xDumpFieldToFile(fp,
|
||||||
|
(const char*)row[i], fields +i, length[i], precision);
|
||||||
}
|
}
|
||||||
fputc('\n', fp);
|
fputc('\n', fp);
|
||||||
|
|
||||||
|
@ -1988,7 +2028,8 @@ static int getDbFromServer(TAOS * taos, SDbInfo** dbInfos) {
|
||||||
int32_t code = taos_errno(res);
|
int32_t code = taos_errno(res);
|
||||||
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
errorPrint( "failed to run <show databases>, reason: %s\n", taos_errstr(res));
|
errorPrint( "failed to run <show databases>, reason: %s\n",
|
||||||
|
taos_errstr(res));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2318,8 +2359,10 @@ static char* generateTagVaulesForStb(SSuperTable* stbInfo, int32_t tableSeq) {
|
||||||
int dataLen = 0;
|
int dataLen = 0;
|
||||||
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen, "(");
|
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen, "(");
|
||||||
for (int i = 0; i < stbInfo->tagCount; i++) {
|
for (int i = 0; i < stbInfo->tagCount; i++) {
|
||||||
if ((0 == strncasecmp(stbInfo->tags[i].dataType, "binary", strlen("binary")))
|
if ((0 == strncasecmp(stbInfo->tags[i].dataType,
|
||||||
|| (0 == strncasecmp(stbInfo->tags[i].dataType, "nchar", strlen("nchar")))) {
|
"binary", strlen("binary")))
|
||||||
|
|| (0 == strncasecmp(stbInfo->tags[i].dataType,
|
||||||
|
"nchar", strlen("nchar")))) {
|
||||||
if (stbInfo->tags[i].dataLen > TSDB_MAX_BINARY_LEN) {
|
if (stbInfo->tags[i].dataLen > TSDB_MAX_BINARY_LEN) {
|
||||||
printf("binary or nchar length overflow, max size:%u\n",
|
printf("binary or nchar length overflow, max size:%u\n",
|
||||||
(uint32_t)TSDB_MAX_BINARY_LEN);
|
(uint32_t)TSDB_MAX_BINARY_LEN);
|
||||||
|
@ -2664,13 +2707,20 @@ static int createSuperTable(
|
||||||
superTbl->columns[colIndex].dataLen);
|
superTbl->columns[colIndex].dataLen);
|
||||||
lenOfOneRow += superTbl->columns[colIndex].dataLen + 3;
|
lenOfOneRow += superTbl->columns[colIndex].dataLen + 3;
|
||||||
} else if (strcasecmp(dataType, "INT") == 0) {
|
} else if (strcasecmp(dataType, "INT") == 0) {
|
||||||
|
if ((g_args.demo_mode) && (colIndex == 1)) {
|
||||||
|
len += snprintf(cols + len, STRING_LEN - len,
|
||||||
|
", VOLTAGE INT");
|
||||||
|
} else {
|
||||||
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "INT");
|
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "INT");
|
||||||
|
}
|
||||||
lenOfOneRow += 11;
|
lenOfOneRow += 11;
|
||||||
} else if (strcasecmp(dataType, "BIGINT") == 0) {
|
} else if (strcasecmp(dataType, "BIGINT") == 0) {
|
||||||
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "BIGINT");
|
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s",
|
||||||
|
colIndex, "BIGINT");
|
||||||
lenOfOneRow += 21;
|
lenOfOneRow += 21;
|
||||||
} else if (strcasecmp(dataType, "SMALLINT") == 0) {
|
} else if (strcasecmp(dataType, "SMALLINT") == 0) {
|
||||||
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "SMALLINT");
|
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s",
|
||||||
|
colIndex, "SMALLINT");
|
||||||
lenOfOneRow += 6;
|
lenOfOneRow += 6;
|
||||||
} else if (strcasecmp(dataType, "TINYINT") == 0) {
|
} else if (strcasecmp(dataType, "TINYINT") == 0) {
|
||||||
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "TINYINT");
|
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "TINYINT");
|
||||||
|
@ -2679,13 +2729,24 @@ static int createSuperTable(
|
||||||
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "BOOL");
|
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "BOOL");
|
||||||
lenOfOneRow += 6;
|
lenOfOneRow += 6;
|
||||||
} else if (strcasecmp(dataType, "FLOAT") == 0) {
|
} else if (strcasecmp(dataType, "FLOAT") == 0) {
|
||||||
|
if (g_args.demo_mode) {
|
||||||
|
if (colIndex == 0) {
|
||||||
|
len += snprintf(cols + len, STRING_LEN - len, ", CURRENT FLOAT");
|
||||||
|
} else if (colIndex == 2) {
|
||||||
|
len += snprintf(cols + len, STRING_LEN - len, ", PHASE FLOAT");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "FLOAT");
|
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "FLOAT");
|
||||||
|
}
|
||||||
|
|
||||||
lenOfOneRow += 22;
|
lenOfOneRow += 22;
|
||||||
} else if (strcasecmp(dataType, "DOUBLE") == 0) {
|
} else if (strcasecmp(dataType, "DOUBLE") == 0) {
|
||||||
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "DOUBLE");
|
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s",
|
||||||
|
colIndex, "DOUBLE");
|
||||||
lenOfOneRow += 42;
|
lenOfOneRow += 42;
|
||||||
} else if (strcasecmp(dataType, "TIMESTAMP") == 0) {
|
} else if (strcasecmp(dataType, "TIMESTAMP") == 0) {
|
||||||
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "TIMESTAMP");
|
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s",
|
||||||
|
colIndex, "TIMESTAMP");
|
||||||
lenOfOneRow += 21;
|
lenOfOneRow += 21;
|
||||||
} else {
|
} else {
|
||||||
taos_close(taos);
|
taos_close(taos);
|
||||||
|
@ -2696,7 +2757,6 @@ static int createSuperTable(
|
||||||
}
|
}
|
||||||
|
|
||||||
superTbl->lenOfOneRow = lenOfOneRow + 20; // timestamp
|
superTbl->lenOfOneRow = lenOfOneRow + 20; // timestamp
|
||||||
//printf("%s.%s column count:%d, column length:%d\n\n", g_Dbs.db[i].dbName, g_Dbs.db[i].superTbl[j].sTblName, g_Dbs.db[i].superTbl[j].columnCount, lenOfOneRow);
|
|
||||||
|
|
||||||
// save for creating child table
|
// save for creating child table
|
||||||
superTbl->colsOfCreateChildTable = (char*)calloc(len+20, 1);
|
superTbl->colsOfCreateChildTable = (char*)calloc(len+20, 1);
|
||||||
|
@ -4746,15 +4806,16 @@ static void postFreeResource() {
|
||||||
|
|
||||||
static int getRowDataFromSample(
|
static int getRowDataFromSample(
|
||||||
char* dataBuf, int64_t maxLen, int64_t timestamp,
|
char* dataBuf, int64_t maxLen, int64_t timestamp,
|
||||||
SSuperTable* superTblInfo, int64_t* sampleUsePos) {
|
SSuperTable* superTblInfo, int64_t* sampleUsePos)
|
||||||
|
{
|
||||||
if ((*sampleUsePos) == MAX_SAMPLES_ONCE_FROM_FILE) {
|
if ((*sampleUsePos) == MAX_SAMPLES_ONCE_FROM_FILE) {
|
||||||
/* int ret = readSampleFromCsvFileToMem(superTblInfo);
|
/* int ret = readSampleFromCsvFileToMem(superTblInfo);
|
||||||
if (0 != ret) {
|
if (0 != ret) {
|
||||||
tmfree(superTblInfo->sampleDataBuf);
|
tmfree(superTblInfo->sampleDataBuf);
|
||||||
superTblInfo->sampleDataBuf = NULL;
|
superTblInfo->sampleDataBuf = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
*sampleUsePos = 0;
|
*sampleUsePos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4763,7 +4824,9 @@ static int getRowDataFromSample(
|
||||||
dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen,
|
dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen,
|
||||||
"(%" PRId64 ", ", timestamp);
|
"(%" PRId64 ", ", timestamp);
|
||||||
dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen,
|
dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen,
|
||||||
"%s", superTblInfo->sampleDataBuf + superTblInfo->lenOfOneRow * (*sampleUsePos));
|
"%s",
|
||||||
|
superTblInfo->sampleDataBuf
|
||||||
|
+ superTblInfo->lenOfOneRow * (*sampleUsePos));
|
||||||
dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, ")");
|
dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, ")");
|
||||||
|
|
||||||
(*sampleUsePos)++;
|
(*sampleUsePos)++;
|
||||||
|
@ -4803,16 +4866,31 @@ static int64_t generateStbRowData(
|
||||||
tmfree(buf);
|
tmfree(buf);
|
||||||
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
|
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
|
||||||
"INT", strlen("INT"))) {
|
"INT", strlen("INT"))) {
|
||||||
|
if ((g_args.demo_mode) && (i == 1)) {
|
||||||
|
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
|
||||||
|
"%d,", demo_voltage_int());
|
||||||
|
} else {
|
||||||
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
|
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
|
||||||
"%d,", rand_int());
|
"%d,", rand_int());
|
||||||
|
}
|
||||||
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
|
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
|
||||||
"BIGINT", strlen("BIGINT"))) {
|
"BIGINT", strlen("BIGINT"))) {
|
||||||
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
|
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
|
||||||
"%"PRId64",", rand_bigint());
|
"%"PRId64",", rand_bigint());
|
||||||
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
|
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
|
||||||
"FLOAT", strlen("FLOAT"))) {
|
"FLOAT", strlen("FLOAT"))) {
|
||||||
|
if (g_args.demo_mode) {
|
||||||
|
if (i == 0) {
|
||||||
|
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
|
||||||
|
"%f,", demo_current_float());
|
||||||
|
} else {
|
||||||
|
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
|
||||||
|
"%f,", demo_phase_float());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
|
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
|
||||||
"%f,", rand_float());
|
"%f,", rand_float());
|
||||||
|
}
|
||||||
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
|
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
|
||||||
"DOUBLE", strlen("DOUBLE"))) {
|
"DOUBLE", strlen("DOUBLE"))) {
|
||||||
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
|
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
|
||||||
|
|
|
@ -51,7 +51,7 @@ class TDTestCase:
|
||||||
else:
|
else:
|
||||||
tdLog.info("taosdemo found in %s" % buildPath)
|
tdLog.info("taosdemo found in %s" % buildPath)
|
||||||
binPath = buildPath + "/build/bin/"
|
binPath = buildPath + "/build/bin/"
|
||||||
os.system("%staosdemo -y -t %d -n %d" %
|
os.system("%staosdemo -y -t %d -n %d -b INT,INT,INT,INT" %
|
||||||
(binPath, self.numberOfTables, self.numberOfRecords))
|
(binPath, self.numberOfTables, self.numberOfRecords))
|
||||||
|
|
||||||
tdSql.execute("use test")
|
tdSql.execute("use test")
|
||||||
|
|
|
@ -54,7 +54,7 @@ class TDTestCase:
|
||||||
binPath = buildPath + "/build/bin/"
|
binPath = buildPath + "/build/bin/"
|
||||||
|
|
||||||
if(threadID == 0):
|
if(threadID == 0):
|
||||||
os.system("%staosdemo -y -t %d -n %d" %
|
os.system("%staosdemo -y -t %d -n %d -b INT,INT,INT,INT -m t" %
|
||||||
(binPath, self.numberOfTables, self.numberOfRecords))
|
(binPath, self.numberOfTables, self.numberOfRecords))
|
||||||
if(threadID == 1):
|
if(threadID == 1):
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
|
@ -60,7 +60,7 @@ class TDTestCase:
|
||||||
|
|
||||||
tdSql.execute("use test")
|
tdSql.execute("use test")
|
||||||
tdSql.query(
|
tdSql.query(
|
||||||
"select count(*) from test.t%d" % (self.numberOfTables -1))
|
"select count(*) from test.d%d" % (self.numberOfTables -1))
|
||||||
tdSql.checkData(0, 0, self.numberOfRecords)
|
tdSql.checkData(0, 0, self.numberOfRecords)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
|
Loading…
Reference in New Issue