未验证 提交 4f709c0c 编写于 作者: sangshuduo's avatar sangshuduo 提交者: GitHub

feat: taosbenchmark support partial col 9284147 for 2.6 (#17457)

* feat: taosbenchmark support partial col 9284147 for 2.6

* fix: free cfgs

* fix: better handle command line and json memory

* test: fix two taosbenchmark test cases

* feat: update taos-tools cc973e0

* test: fix 5-taos-tools/taosbenchmark/taosdemoTestInsertWithJson.py
上级 ee98673e
Subproject commit 217a267b5365b7a4089eb6ee2d4b2ceedfc4df66 Subproject commit cc973e0c2999a739fa2d06c25ab5adb2a7537c8f
...@@ -25,8 +25,8 @@ from util.cases import * ...@@ -25,8 +25,8 @@ from util.cases import *
from util.dnodes import * from util.dnodes import *
from util.dnodes import TDDnode from util.dnodes import TDDnode
class TDTestCase:
class TDTestCase:
def __init__(self): def __init__(self):
self.path = "" self.path = ""
...@@ -68,7 +68,7 @@ class TDTestCase: ...@@ -68,7 +68,7 @@ class TDTestCase:
"cachelast": 0, "cachelast": 0,
"quorum": 1, "quorum": 1,
"fsync": 3000, "fsync": 3000,
"update": 0 "update": 0,
} }
# set stable schema # set stable schema
...@@ -99,8 +99,7 @@ class TDTestCase: ...@@ -99,8 +99,7 @@ class TDTestCase:
{"type": "TINYINT", "count": 2}, {"type": "TINYINT", "count": 2},
{"type": "BOOL", "count": 2}, {"type": "BOOL", "count": 2},
{"type": "NCHAR", "len": 3, "count": 1}, {"type": "NCHAR", "len": 3, "count": 1},
{"type": "BINARY", "len": 8, "count": 1} {"type": "BINARY", "len": 8, "count": 1},
], ],
"tags": [ "tags": [
{"type": "INT", "count": 2}, {"type": "INT", "count": 2},
...@@ -111,17 +110,14 @@ class TDTestCase: ...@@ -111,17 +110,14 @@ class TDTestCase:
{"type": "TINYINT", "count": 2}, {"type": "TINYINT", "count": 2},
{"type": "BOOL", "count": 2}, {"type": "BOOL", "count": 2},
{"type": "NCHAR", "len": 3, "count": 1}, {"type": "NCHAR", "len": 3, "count": 1},
{"type": "BINARY", "len": 8, "count": 1} {"type": "BINARY", "len": 8, "count": 1},
] ],
} }
# create different stables like stable1 and add to list super_tables # create different stables like stable1 and add to list super_tables
super_tables = [] super_tables = []
super_tables.append(stable1) super_tables.append(stable1)
database = { database = {"dbinfo": dbinfo, "super_tables": super_tables}
"dbinfo": dbinfo,
"super_tables": super_tables
}
cfgdir = self.getCfgDir() cfgdir = self.getCfgDir()
create_table = { create_table = {
...@@ -137,33 +133,60 @@ class TDTestCase: ...@@ -137,33 +133,60 @@ class TDTestCase:
"confirm_parameter_prompt": "no", "confirm_parameter_prompt": "no",
"insert_interval": 0, "insert_interval": 0,
"num_of_records_per_req": 100, "num_of_records_per_req": 100,
"databases": [database] "databases": [database],
} }
return create_table return create_table
def getPath(self, tool="taosBenchmark"):
selfPath = os.path.dirname(os.path.realpath(__file__))
if "community" in selfPath:
projPath = selfPath[: selfPath.find("community")]
elif "src" in selfPath:
projPath = selfPath[: selfPath.find("src")]
elif "/tools/" in selfPath:
projPath = selfPath[: selfPath.find("/tools/")]
elif "/tests/" in selfPath:
projPath = selfPath[: selfPath.find("/tests/")]
else:
tdLog.exit("path: %s is not supported" % selfPath)
paths = []
for root, dirs, files in os.walk(projPath):
if (tool) in files:
rootRealPath = os.path.dirname(os.path.realpath(root))
if "packaging" not in rootRealPath:
paths.append(os.path.join(root, tool))
break
if len(paths) == 0:
return ""
return paths[0]
def createinsertfile(self): def createinsertfile(self):
create_table = self.creatcfg() create_table = self.creatcfg()
date = datetime.datetime.now().strftime("%Y%m%d%H%M") date = datetime.datetime.now().strftime("%Y%m%d%H%M")
file_create_table = f"/tmp/insert_{date}.json" file_create_table = f"/tmp/insert_{date}.json"
with open(file_create_table, 'w') as f: with open(file_create_table, "w") as f:
json.dump(create_table, f) json.dump(create_table, f)
return file_create_table return file_create_table
def inserttable(self, filepath): def inserttable(self, filepath):
create_table_cmd = f"taosdemo -f {filepath} > /dev/null 2>&1" binPath = self.getPath("taosBenchmark")
if binPath == "":
tdLog.exit("taosBenchmark not found!")
else:
tdLog.info("taosBenchmark found in %s" % binPath)
create_table_cmd = "%s -f %s > /dev/null 2>&1" % (binPath, filepath)
_ = subprocess.check_output(create_table_cmd, shell=True).decode("utf-8") _ = subprocess.check_output(create_table_cmd, shell=True).decode("utf-8")
def sqlsquery(self): def sqlsquery(self):
# stable query # stable query
tdSql.query( tdSql.query("select * from stb2 where stb2.ts < '1970-01-01 00:00:00.000' ")
"select * from stb2 where stb2.ts < '1970-01-01 00:00:00.000' "
)
tdSql.checkRows(43200) tdSql.checkRows(43200)
tdSql.query( tdSql.query("select * from stb2 where stb2.ts >= '1970-01-01 00:00:00.000' ")
"select * from stb2 where stb2.ts >= '1970-01-01 00:00:00.000' "
)
tdSql.checkRows(6800) tdSql.checkRows(6800)
tdSql.query( tdSql.query(
...@@ -172,14 +195,10 @@ class TDTestCase: ...@@ -172,14 +195,10 @@ class TDTestCase:
tdSql.checkRows(3590) tdSql.checkRows(3590)
# child-tables query # child-tables query
tdSql.query( tdSql.query("select * from t0 where t0.ts < '1970-01-01 00:00:00.000' ")
"select * from t0 where t0.ts < '1970-01-01 00:00:00.000' "
)
tdSql.checkRows(4320) tdSql.checkRows(4320)
tdSql.query( tdSql.query("select * from t1 where t1.ts >= '1970-01-01 00:00:00.000' ")
"select * from t1 where t1.ts >= '1970-01-01 00:00:00.000' "
)
tdSql.checkRows(680) tdSql.checkRows(680)
tdSql.query( tdSql.query(
...@@ -192,9 +211,7 @@ class TDTestCase: ...@@ -192,9 +211,7 @@ class TDTestCase:
) )
tdSql.checkRows(680) tdSql.checkRows(680)
tdSql.query( tdSql.query("select diff(c1) from t0 where t0.ts >= '1970-01-01 00:00:00.000' ")
"select diff(c1) from t0 where t0.ts >= '1970-01-01 00:00:00.000' "
)
tdSql.checkRows(679) tdSql.checkRows(679)
tdSql.query( tdSql.query(
...@@ -203,9 +220,7 @@ class TDTestCase: ...@@ -203,9 +220,7 @@ class TDTestCase:
tdSql.checkRows(43200) tdSql.checkRows(43200)
# query with timestamp in 'where ...' # query with timestamp in 'where ...'
tdSql.query( tdSql.query("select * from stb2 where stb2.ts > -28800000 ")
"select * from stb2 where stb2.ts > -28800000 "
)
tdSql.checkRows(6790) tdSql.checkRows(6790)
tdSql.query( tdSql.query(
...@@ -219,14 +234,16 @@ class TDTestCase: ...@@ -219,14 +234,16 @@ class TDTestCase:
tdSql.checkRows(3590) tdSql.checkRows(3590)
def run(self): def run(self):
s = 'reset query cache' s = "reset query cache"
tdSql.execute(s) tdSql.execute(s)
s = 'create database if not exists db' s = "create database if not exists db"
tdSql.execute(s) tdSql.execute(s)
s = 'use db' s = "use db"
tdSql.execute(s) tdSql.execute(s)
tdLog.info("==========step1:create table stable and child table,then insert data automatically") tdLog.info(
"==========step1:create table stable and child table,then insert data automatically"
)
insertfile = self.createinsertfile() insertfile = self.createinsertfile()
self.inserttable(insertfile) self.inserttable(insertfile)
......
...@@ -24,36 +24,44 @@ class TDTestCase: ...@@ -24,36 +24,44 @@ class TDTestCase:
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)
def getBuildPath(self): def getPath(self, tool="taosBenchmark"):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath): if "community" in selfPath:
projPath = selfPath[:selfPath.find("community")] projPath = selfPath[: selfPath.find("community")]
elif "src" in selfPath:
projPath = selfPath[: selfPath.find("src")]
elif "/tools/" in selfPath:
projPath = selfPath[: selfPath.find("/tools/")]
elif "/tests/" in selfPath:
projPath = selfPath[: selfPath.find("/tests/")]
else: else:
projPath = selfPath[:selfPath.find("tests")] tdLog.exit("path: %s is not supported" % selfPath)
paths = []
for root, dirs, files in os.walk(projPath): for root, dirs, files in os.walk(projPath):
if ("taosd" in files): if (tool) in files:
rootRealPath = os.path.dirname(os.path.realpath(root)) rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath): if "packaging" not in rootRealPath:
buildPath = root[:len(root)-len("/build/bin")] paths.append(os.path.join(root, tool))
break break
return buildPath if len(paths) == 0:
return ""
return paths[0]
def run(self): def run(self):
buildPath = self.getBuildPath() binPath = self.getPath()
if (buildPath == ""): if binPath == "":
tdLog.exit("taosd not found!") tdLog.exit("taosBenchmark not found!")
else: else:
tdLog.info("taosd found in %s" % buildPath) tdLog.info("taosBenchmark found in %s" % binPath)
binPath = buildPath+ "/build/bin/"
testcaseFilename = os.path.split(__file__)[-1] testcaseFilename = os.path.split(__file__)[-1]
os.system("rm -rf ./insert*_res.txt*") os.system("rm -rf ./insert*_res.txt*")
os.system("rm -rf 5-taos-tools/taosbenchmark/%s.sql" % testcaseFilename ) os.system("rm -rf 5-taos-tools/taosbenchmark/%s.sql" % testcaseFilename)
# insert: create one or mutiple tables per sql and insert multiple rows per sql # insert: create one or mutiple tables per sql and insert multiple rows per sql
os.system("%staosBenchmark -f 5-taos-tools/taosbenchmark/insert-1s1tnt1r.json -y " % binPath) os.system("%s -f 5-taos-tools/taosbenchmark/insert-1s1tnt1r.json -y " % binPath)
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("select count (tbname) from stb0") tdSql.query("select count (tbname) from stb0")
tdSql.checkData(0, 0, 11) tdSql.checkData(0, 0, 11)
...@@ -69,7 +77,7 @@ class TDTestCase: ...@@ -69,7 +77,7 @@ class TDTestCase:
tdSql.checkData(0, 0, 2000) tdSql.checkData(0, 0, 2000)
# restful connector insert data # restful connector insert data
os.system("%staosBenchmark -f 5-taos-tools/taosbenchmark/insertRestful.json -y " % binPath) os.system("%s -f 5-taos-tools/taosbenchmark/insertRestful.json -y " % binPath)
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("select count (tbname) from stb0") tdSql.query("select count (tbname) from stb0")
tdSql.checkData(0, 0, 10) tdSql.checkData(0, 0, 10)
...@@ -84,19 +92,19 @@ class TDTestCase: ...@@ -84,19 +92,19 @@ class TDTestCase:
tdSql.query("select count(*) from stb1") tdSql.query("select count(*) from stb1")
tdSql.checkData(0, 0, 200) tdSql.checkData(0, 0, 200)
# default values json files # default values json files
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
os.system("%staosBenchmark -f 5-taos-tools/taosbenchmark/insert-default.json -y " % binPath) os.system("%s -f 5-taos-tools/taosbenchmark/insert-default.json -y " % binPath)
tdSql.query("show databases;") tdSql.query("show databases;")
for i in range(tdSql.queryRows): for i in range(tdSql.queryRows):
if tdSql.queryResult[i][0] == 'db': if tdSql.queryResult[i][0] == "db":
tdSql.checkData(i, 2, 100) tdSql.checkData(i, 2, 100)
tdSql.checkData(i, 4, 1) tdSql.checkData(i, 4, 1)
tdSql.checkData(i, 6, 10) tdSql.checkData(i, 6, 10)
tdSql.checkData(i, 16, 'ms') tdSql.checkData(i, 16, "ms")
# insert: create mutiple tables per sql and insert one rows per sql . # insert: create mutiple tables per sql and insert one rows per sql .
os.system("%staosBenchmark -f 5-taos-tools/taosbenchmark/insert-1s1tntmr.json -y " % binPath) os.system("%s -f 5-taos-tools/taosbenchmark/insert-1s1tntmr.json -y " % binPath)
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("select count (tbname) from stb0") tdSql.query("select count (tbname) from stb0")
tdSql.checkData(0, 0, 10) tdSql.checkData(0, 0, 10)
...@@ -113,7 +121,9 @@ class TDTestCase: ...@@ -113,7 +121,9 @@ class TDTestCase:
# insert: using parament "insert_interval to controls spped of insert. # insert: using parament "insert_interval to controls spped of insert.
# but We need to have accurate methods to control the speed, such as getting the speed value, checking the count and so on。 # but We need to have accurate methods to control the speed, such as getting the speed value, checking the count and so on。
os.system("%staosBenchmark -f 5-taos-tools/taosbenchmark/insert-interval-speed.json -y" % binPath) os.system(
"%s -f 5-taos-tools/taosbenchmark/insert-interval-speed.json -y" % binPath
)
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("show stables") tdSql.query("show stables")
tdSql.checkData(0, 4, 10) tdSql.checkData(0, 4, 10)
...@@ -131,11 +141,6 @@ class TDTestCase: ...@@ -131,11 +141,6 @@ class TDTestCase:
# rm useless files # rm useless files
os.system("rm -rf ./insert*_res.txt*") os.system("rm -rf ./insert*_res.txt*")
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册