Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions test/cases/81-Tools/03-Benchmark/test_benchmark_website.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def getKeyValue(self, content, key, end):
s = content.find(key)
if s == -1:
return False,""

# skip self
s += len(key)
# skip blank
Expand All @@ -45,33 +45,40 @@ def getKeyValue(self, content, key, end):
# end check
if s + 1 == len(content):
return False, ""

# find end
if len(end) == 0:
e = -1
else:
e = content.find(end, s)

# get value
if e == -1:
value = content[s : ]
else:
value = content[s : e]

return True, value
return True, value

def getDbRows(self, times):
sql = f"select count(*) from test.meters"
tdSql.waitedQuery(sql, 1, times)
dbRows = tdSql.getData(0, 0)
return dbRows

def checkItem(self, output, key, end, expect, equal):
ret, value = self.getKeyValue(output, key, end)
if ret == False:
tdLog.exit(f"not found key:{key}. end:{end} output:\n{output}")

fval = float(value)
try:
fval = float(value)
except Exception as e:
tdLog.info(f"value:'{value}' is not float, key:'{key}' end:'{end}' output:\n{output}")
# Remove the line breaks and try again
value = value.splitlines()[0]
fval = float(value)
Comment thread
YamingPei marked this conversation as resolved.

# compare
if equal and fval != expect:
tdLog.exit(f"check not expect. expect:{expect} real:{fval}, key:'{key}' end:'{end}' output:\n{output}")
Expand All @@ -84,7 +91,7 @@ def checkItem(self, output, key, end, expect, equal):
else:
tdLog.info(f"check successfully. key:'{key}' {fval} > {expect}")


def checkAfterRun(self, benchmark, jsonFile, specMode, tbCnt):
# run
cmd = f"{benchmark} -f {jsonFile}"
Expand All @@ -99,7 +106,7 @@ def checkAfterRun(self, benchmark, jsonFile, specMode, tbCnt):
#
with open(jsonFile, "r") as file:
data = json.load(file)

queryTimes = data["query_times"]
# contineIfFail
try:
Expand Down Expand Up @@ -134,18 +141,18 @@ def checkAfterRun(self, benchmark, jsonFile, specMode, tbCnt):
allEnd = " "
else:
allEnd = "\n"

if specMode and mixedQuery.lower() != "yes":
# spec
threadQueries = queryTimes * threads
totalQueries = queryTimes * threads * len(sqls)
threadKey = f"complete query with {threads} threads and "
threadKey = f"complete query with {threads} threads and "
qpsKey = "QPS: "
avgKey = "query delay avg: "
minKey = "min:"
else:
# spec mixed or super
# spec mixed or super

if specMode:
totalQueries = queryTimes * len(sqls)
# spec mixed
Expand All @@ -158,7 +165,7 @@ def checkAfterRun(self, benchmark, jsonFile, specMode, tbCnt):
else:
# super
totalQueries = queryTimes * len(sqls) * tbCnt
threadQueries = totalQueries
threadQueries = totalQueries

nSql = len(sqls)
if specMode and nSql < threads :
Expand All @@ -182,11 +189,11 @@ def checkAfterRun(self, benchmark, jsonFile, specMode, tbCnt):
["completed total queries: ", ",", totalQueries, True],
["the QPS of all threads:", allEnd, QPS , False] # all qps need > 5
]

# check
for item in items:
if len(item[0]) > 0:
self.checkItem(output, item[0], item[1], item[2], item[3])
self.checkItem(output, item[0], item[1], item[2], item[3])



Expand All @@ -199,7 +206,7 @@ def checkTmqJson(self, benchmark, json):
tdLog.info(f"succ: {cmd} found '{OK_RESULT}'")
else:
tdLog.exit(f"failed: {cmd} not found {OK_RESULT} in:\n{output} \nerror:{error}")

#
# ------------------- main ----------------
#
Expand All @@ -221,7 +228,7 @@ def test_benchmark_website(self):
"""
tbCnt = 10
benchmark = etool.benchMarkFile()

# insert
json = "../tools/taos-tools/example/insert.json"
self.insertBenchJson(json, checkStep=True)
Expand Down
Loading
Loading