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:
Alex Duan 2025-03-18 17:48:24 +08:00 committed by GitHub
parent f62ef250fd
commit e333f44dfb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 53 additions and 16 deletions

1
.gitignore vendored
View File

@ -132,7 +132,6 @@ tools/THANKS
tools/NEWS tools/NEWS
tools/COPYING tools/COPYING
tools/BUGS tools/BUGS
tools/taos-tools
tools/taosws-rs tools/taosws-rs
tags tags
.clangd .clangd

View File

@ -80,12 +80,16 @@ class TDTestCase(TBase):
cmdVG = arr[1] cmdVG = arr[1]
# vgropus # vgropus
vgroups = None
try: try:
if cmdVG != None: if cmdVG != None:
# command special vgroups first priority # command special vgroups first priority
vgroups = cmdVG vgroups = cmdVG
else: 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: except:
vgroups = None vgroups = None

View File

@ -31,6 +31,7 @@ class TDTestCase(TBase):
# exe insert # exe insert
cmd = f"{benchmark} {options} -f {jsonFile}" cmd = f"{benchmark} {options} -f {jsonFile}"
os.system(cmd) os.system(cmd)
precision = None
# #
# check insert result # check insert result
@ -39,14 +40,17 @@ class TDTestCase(TBase):
data = json.load(file) data = json.load(file)
db = data["databases"][0]["dbinfo"]["name"] 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"] stb = data["databases"][0]["super_tables"][0]["name"]
child_count = data["databases"][0]["super_tables"][0]["childtable_count"] child_count = data["databases"][0]["super_tables"][0]["childtable_count"]
insert_rows = data["databases"][0]["super_tables"][0]["insert_rows"] insert_rows = data["databases"][0]["super_tables"][0]["insert_rows"]
timestamp_step = data["databases"][0]["super_tables"][0]["timestamp_step"] timestamp_step = data["databases"][0]["super_tables"][0]["timestamp_step"]
start_timestamp = data["databases"][0]["super_tables"][0]["start_timestamp"] 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") f"start_timestamp={start_timestamp} timestamp_step={timestamp_step} \n")
# all count insert_rows * child_table_count # all count insert_rows * child_table_count

View File

@ -14,7 +14,7 @@
"name": "test", "name": "test",
"drop": "yes", "drop": "yes",
"precision": "ns", "precision": "ns",
"vgroups": 2 " vgroups ": 2
}, },
"super_tables": [ "super_tables": [
{ {

View File

@ -13,7 +13,7 @@
"dbinfo": { "dbinfo": {
"name": "test", "name": "test",
"drop": "yes", "drop": "yes",
"precision": "ms", " precision ": "ms",
"vgroups": 2 "vgroups": 2
}, },
"super_tables": [ "super_tables": [

View File

@ -13,7 +13,7 @@
"dbinfo": { "dbinfo": {
"name": "test", "name": "test",
"drop": "yes", "drop": "yes",
"precision": "ns", " precision": "ns",
"vgroups": 2 "vgroups": 2
}, },
"super_tables": [ "super_tables": [

View File

@ -13,7 +13,7 @@
"dbinfo": { "dbinfo": {
"name": "test", "name": "test",
"drop": "yes", "drop": "yes",
"precision": "us", "precision ": "us",
"vgroups": 2 "vgroups": 2
}, },
"super_tables": [ "super_tables": [

View File

@ -1061,4 +1061,7 @@ int killSlowQuery();
// fetch super table child name from server // fetch super table child name from server
int fetchChildTableName(char *dbName, char *stbName); int fetchChildTableName(char *dbName, char *stbName);
// trim prefix suffix blank cmp
int trimCaseCmp(char *str1,char *str2);
#endif // INC_BENCH_H_ #endif // INC_BENCH_H_

View File

@ -643,7 +643,7 @@ int geneDbCreateCmd(SDataBase *database, char *command, int remainVnodes) {
SDbCfg* cfg = benchArrayGet(database->cfgs, i); SDbCfg* cfg = benchArrayGet(database->cfgs, i);
// check vgroups // check vgroups
if (strcasecmp(cfg->name, "vgroups") == 0) { if (trimCaseCmp(cfg->name, "vgroups") == 0) {
if (vgroups > 0) { if (vgroups > 0) {
// inputted vgroups by commandline // inputted vgroups by commandline
infoPrint("ignore config set vgroups %d\n", cfg->valueint); infoPrint("ignore config set vgroups %d\n", cfg->valueint);

View File

@ -602,9 +602,9 @@ void setDBCfgString(SDbCfg* cfg , char * value) {
// need add quotation // need add quotation
bool add = false; bool add = false;
if (0 == strcasecmp(cfg->name, "cachemodel") || if (0 == trimCaseCmp(cfg->name, "cachemodel") ||
0 == strcasecmp(cfg->name, "dnodes" ) || 0 == trimCaseCmp(cfg->name, "dnodes" ) ||
0 == strcasecmp(cfg->name, "precision" ) ) { 0 == trimCaseCmp(cfg->name, "precision" ) ) {
add = true; add = true;
} }
@ -676,12 +676,12 @@ static int getDatabaseInfo(tools_cJSON *dbinfos, int index) {
&& (0 == strcasecmp(cfg_object->valuestring, "yes"))) { && (0 == strcasecmp(cfg_object->valuestring, "yes"))) {
database->flush = true; 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 (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->precision = TSDB_TIME_PRECISION_MICRO;
database->sml_precision = TSDB_SML_TIMESTAMP_MICRO_SECONDS; 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->precision = TSDB_TIME_PRECISION_NANO;
database->sml_precision = TSDB_SML_TIMESTAMP_NANO_SECONDS; 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; cfg->name = cfg_object->string;
// get duration value // get duration value
if (0 == strcasecmp(cfg_object->string, "duration")) { if (0 == trimCaseCmp(cfg_object->string, "duration")) {
database->durMinute = getDurationVal(cfg_object); database->durMinute = getDurationVal(cfg_object);
} }

View File

@ -1776,3 +1776,30 @@ int fetchChildTableName(char *dbName, char *stbName) {
// succ // succ
return 0; 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;
}