fix(taosbenchmark): pass db options support prefix suffix with blank (#30205)
* fix: pass db parameter support prefix suffix blank * fix: add check vgroups have blank case * fix: remove strlen from trimCaseCmp * fix: case init variant and remove taos-tools from .gitignore
This commit is contained in:
parent
f62ef250fd
commit
e333f44dfb
|
@ -132,7 +132,6 @@ tools/THANKS
|
|||
tools/NEWS
|
||||
tools/COPYING
|
||||
tools/BUGS
|
||||
tools/taos-tools
|
||||
tools/taosws-rs
|
||||
tags
|
||||
.clangd
|
||||
|
|
|
@ -80,12 +80,16 @@ class TDTestCase(TBase):
|
|||
cmdVG = arr[1]
|
||||
|
||||
# vgropus
|
||||
vgroups = None
|
||||
try:
|
||||
if cmdVG != None:
|
||||
# command special vgroups first priority
|
||||
vgroups = cmdVG
|
||||
else:
|
||||
vgroups = data["databases"][0]["dbinfo"]["vgroups"]
|
||||
dbinfo = data["databases"][0]["dbinfo"]
|
||||
for key,value in dbinfo.items():
|
||||
if key.strip().lower() == "vgroups":
|
||||
vgroups = value
|
||||
except:
|
||||
vgroups = None
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ class TDTestCase(TBase):
|
|||
# exe insert
|
||||
cmd = f"{benchmark} {options} -f {jsonFile}"
|
||||
os.system(cmd)
|
||||
precision = None
|
||||
|
||||
#
|
||||
# check insert result
|
||||
|
@ -39,14 +40,17 @@ class TDTestCase(TBase):
|
|||
data = json.load(file)
|
||||
|
||||
db = data["databases"][0]["dbinfo"]["name"]
|
||||
precison = data["databases"][0]["dbinfo"]["precision"]
|
||||
dbinfo = data["databases"][0]["dbinfo"]
|
||||
for key,value in dbinfo.items():
|
||||
if key.strip().lower() == "precision":
|
||||
precision = value
|
||||
stb = data["databases"][0]["super_tables"][0]["name"]
|
||||
child_count = data["databases"][0]["super_tables"][0]["childtable_count"]
|
||||
insert_rows = data["databases"][0]["super_tables"][0]["insert_rows"]
|
||||
timestamp_step = data["databases"][0]["super_tables"][0]["timestamp_step"]
|
||||
start_timestamp = data["databases"][0]["super_tables"][0]["start_timestamp"]
|
||||
|
||||
tdLog.info(f"get json info: db={db} precision={precison} stb={stb} child_count={child_count} insert_rows={insert_rows} "
|
||||
tdLog.info(f"get json info: db={db} precision={precision} stb={stb} child_count={child_count} insert_rows={insert_rows} "
|
||||
f"start_timestamp={start_timestamp} timestamp_step={timestamp_step} \n")
|
||||
|
||||
# all count insert_rows * child_table_count
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"name": "test",
|
||||
"drop": "yes",
|
||||
"precision": "ns",
|
||||
"vgroups": 2
|
||||
" vgroups ": 2
|
||||
},
|
||||
"super_tables": [
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"dbinfo": {
|
||||
"name": "test",
|
||||
"drop": "yes",
|
||||
"precision": "ms",
|
||||
" precision ": "ms",
|
||||
"vgroups": 2
|
||||
},
|
||||
"super_tables": [
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"dbinfo": {
|
||||
"name": "test",
|
||||
"drop": "yes",
|
||||
"precision": "ns",
|
||||
" precision": "ns",
|
||||
"vgroups": 2
|
||||
},
|
||||
"super_tables": [
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"dbinfo": {
|
||||
"name": "test",
|
||||
"drop": "yes",
|
||||
"precision": "us",
|
||||
"precision ": "us",
|
||||
"vgroups": 2
|
||||
},
|
||||
"super_tables": [
|
||||
|
|
|
@ -1061,4 +1061,7 @@ int killSlowQuery();
|
|||
// fetch super table child name from server
|
||||
int fetchChildTableName(char *dbName, char *stbName);
|
||||
|
||||
// trim prefix suffix blank cmp
|
||||
int trimCaseCmp(char *str1,char *str2);
|
||||
|
||||
#endif // INC_BENCH_H_
|
||||
|
|
|
@ -643,7 +643,7 @@ int geneDbCreateCmd(SDataBase *database, char *command, int remainVnodes) {
|
|||
SDbCfg* cfg = benchArrayGet(database->cfgs, i);
|
||||
|
||||
// check vgroups
|
||||
if (strcasecmp(cfg->name, "vgroups") == 0) {
|
||||
if (trimCaseCmp(cfg->name, "vgroups") == 0) {
|
||||
if (vgroups > 0) {
|
||||
// inputted vgroups by commandline
|
||||
infoPrint("ignore config set vgroups %d\n", cfg->valueint);
|
||||
|
|
|
@ -602,9 +602,9 @@ void setDBCfgString(SDbCfg* cfg , char * value) {
|
|||
|
||||
// need add quotation
|
||||
bool add = false;
|
||||
if (0 == strcasecmp(cfg->name, "cachemodel") ||
|
||||
0 == strcasecmp(cfg->name, "dnodes" ) ||
|
||||
0 == strcasecmp(cfg->name, "precision" ) ) {
|
||||
if (0 == trimCaseCmp(cfg->name, "cachemodel") ||
|
||||
0 == trimCaseCmp(cfg->name, "dnodes" ) ||
|
||||
0 == trimCaseCmp(cfg->name, "precision" ) ) {
|
||||
add = true;
|
||||
}
|
||||
|
||||
|
@ -676,12 +676,12 @@ static int getDatabaseInfo(tools_cJSON *dbinfos, int index) {
|
|||
&& (0 == strcasecmp(cfg_object->valuestring, "yes"))) {
|
||||
database->flush = true;
|
||||
}
|
||||
} else if (0 == strcasecmp(cfg_object->string, "precision")) {
|
||||
} else if (0 == trimCaseCmp(cfg_object->string, "precision")) {
|
||||
if (tools_cJSON_IsString(cfg_object)) {
|
||||
if (0 == strcasecmp(cfg_object->valuestring, "us")) {
|
||||
if (0 == trimCaseCmp(cfg_object->valuestring, "us")) {
|
||||
database->precision = TSDB_TIME_PRECISION_MICRO;
|
||||
database->sml_precision = TSDB_SML_TIMESTAMP_MICRO_SECONDS;
|
||||
} else if (0 == strcasecmp(cfg_object->valuestring, "ns")) {
|
||||
} else if (0 == trimCaseCmp(cfg_object->valuestring, "ns")) {
|
||||
database->precision = TSDB_TIME_PRECISION_NANO;
|
||||
database->sml_precision = TSDB_SML_TIMESTAMP_NANO_SECONDS;
|
||||
}
|
||||
|
@ -691,7 +691,7 @@ static int getDatabaseInfo(tools_cJSON *dbinfos, int index) {
|
|||
cfg->name = cfg_object->string;
|
||||
|
||||
// get duration value
|
||||
if (0 == strcasecmp(cfg_object->string, "duration")) {
|
||||
if (0 == trimCaseCmp(cfg_object->string, "duration")) {
|
||||
database->durMinute = getDurationVal(cfg_object);
|
||||
}
|
||||
|
||||
|
|
|
@ -1776,3 +1776,30 @@ int fetchChildTableName(char *dbName, char *stbName) {
|
|||
// succ
|
||||
return 0;
|
||||
}
|
||||
|
||||
// skip prefix suffix blank
|
||||
int trimCaseCmp(char *str1, char *str2) {
|
||||
// Skip leading whitespace in str1
|
||||
while (isblank((unsigned char)*str1)) {
|
||||
str1++;
|
||||
}
|
||||
|
||||
// Compare characters case-insensitively
|
||||
while (*str2 != '\0') {
|
||||
if (tolower((unsigned char)*str1) != tolower((unsigned char)*str2)) {
|
||||
return -1;
|
||||
}
|
||||
str1++;
|
||||
str2++;
|
||||
}
|
||||
|
||||
// Check if the remaining characters in str1 are all whitespace
|
||||
while (*str1 != '\0') {
|
||||
if (!isblank((unsigned char)*str1)) {
|
||||
return -1;
|
||||
}
|
||||
str1++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue