提交 adbc5014 编写于 作者: G Ganlin Zhao

fix test cases

上级 db6eca9b
...@@ -45,7 +45,7 @@ class TDTestCase: ...@@ -45,7 +45,7 @@ class TDTestCase:
case1: limit offset base function test case1: limit offset base function test
case2: offset return valid case2: offset return valid
''' '''
return return
def getBuildPath(self): def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
...@@ -71,7 +71,7 @@ class TDTestCase: ...@@ -71,7 +71,7 @@ class TDTestCase:
# self.create_tables(); # self.create_tables();
self.ts = 1500000000000 self.ts = 1500000000000
# stop # stop
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
...@@ -82,7 +82,7 @@ class TDTestCase: ...@@ -82,7 +82,7 @@ class TDTestCase:
def newcur(self,host,cfg): def newcur(self,host,cfg):
user = "root" user = "root"
password = "taosdata" password = "taosdata"
port =6030 port =6030
con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port) con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port)
cur=con.cursor() cur=con.cursor()
print(cur) print(cur)
...@@ -92,7 +92,7 @@ class TDTestCase: ...@@ -92,7 +92,7 @@ class TDTestCase:
def create_tables(self,host,dbname,stbname,count): def create_tables(self,host,dbname,stbname,count):
buildPath = self.getBuildPath() buildPath = self.getBuildPath()
config = buildPath+ "../sim/dnode1/cfg/" config = buildPath+ "../sim/dnode1/cfg/"
tsql=self.newcur(host,config) tsql=self.newcur(host,config)
tsql.execute("use %s" %dbname) tsql.execute("use %s" %dbname)
...@@ -111,7 +111,7 @@ class TDTestCase: ...@@ -111,7 +111,7 @@ class TDTestCase:
tsql.execute(sql) tsql.execute(sql)
sql = pre_create sql = pre_create
# print(time.time()) # print(time.time())
# end sql # end sql
if sql != pre_create: if sql != pre_create:
# print(sql) # print(sql)
tsql.execute(sql) tsql.execute(sql)
...@@ -124,7 +124,7 @@ class TDTestCase: ...@@ -124,7 +124,7 @@ class TDTestCase:
def mutiThread_create_tables(self,host,dbname,stbname,vgroups,threadNumbers,childcount): def mutiThread_create_tables(self,host,dbname,stbname,vgroups,threadNumbers,childcount):
buildPath = self.getBuildPath() buildPath = self.getBuildPath()
config = buildPath+ "../sim/dnode1/cfg/" config = buildPath+ "../sim/dnode1/cfg/"
tsql=self.newcur(host,config) tsql=self.newcur(host,config)
tdLog.debug("create database %s"%dbname) tdLog.debug("create database %s"%dbname)
tsql.execute("drop database if exists %s"%dbname) tsql.execute("drop database if exists %s"%dbname)
...@@ -134,7 +134,7 @@ class TDTestCase: ...@@ -134,7 +134,7 @@ class TDTestCase:
threads = [] threads = []
for i in range(threadNumbers): for i in range(threadNumbers):
tsql.execute("create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%(stbname,i)) tsql.execute("create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%(stbname,i))
threads.append(thd.Thread(target=self.create_tables, args=(host, dbname, stbname+"%d"%i, count,))) threads.append(thd.Thread(target=self.create_tables, args=(host, dbname, stbname+"%d"%i, count,)))
start_time = time.time() start_time = time.time()
for tr in threads: for tr in threads:
tr.start() tr.start()
...@@ -144,7 +144,7 @@ class TDTestCase: ...@@ -144,7 +144,7 @@ class TDTestCase:
spendTime=end_time-start_time spendTime=end_time-start_time
speedCreate=threadNumbers*count/spendTime speedCreate=threadNumbers*count/spendTime
tdLog.debug("spent %.2fs to create %d stable and %d table, create speed is %.2f table/s... [OK]"% (spendTime,threadNumbers,threadNumbers*count,speedCreate)) tdLog.debug("spent %.2fs to create %d stable and %d table, create speed is %.2f table/s... [OK]"% (spendTime,threadNumbers,threadNumbers*count,speedCreate))
return return
# def create_tables(self,host,dbname,stbname,vgroups,tcountStart,tcountStop): # def create_tables(self,host,dbname,stbname,vgroups,tcountStart,tcountStop):
...@@ -171,7 +171,7 @@ class TDTestCase: ...@@ -171,7 +171,7 @@ class TDTestCase:
# print(sql) # print(sql)
tsql.execute(sql) tsql.execute(sql)
sql = "insert into %s_%d values " %(stbname,i) sql = "insert into %s_%d values " %(stbname,i)
# end sql # end sql
if sql != pre_insert: if sql != pre_insert:
# print(sql) # print(sql)
print(len(sql)) print(len(sql))
...@@ -186,7 +186,7 @@ class TDTestCase: ...@@ -186,7 +186,7 @@ class TDTestCase:
def mutiThread_insert_data(self, host, dbname, stbname, threadNumbers, chilCount, ts_start, childrowcount): def mutiThread_insert_data(self, host, dbname, stbname, threadNumbers, chilCount, ts_start, childrowcount):
buildPath = self.getBuildPath() buildPath = self.getBuildPath()
config = buildPath+ "../sim/dnode1/cfg/" config = buildPath+ "../sim/dnode1/cfg/"
tsql=self.newcur(host,config) tsql=self.newcur(host,config)
tdLog.debug("ready to inser data") tdLog.debug("ready to inser data")
...@@ -195,7 +195,7 @@ class TDTestCase: ...@@ -195,7 +195,7 @@ class TDTestCase:
threads = [] threads = []
for i in range(threadNumbers): for i in range(threadNumbers):
# tsql.execute("create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%(stbname,i)) # tsql.execute("create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%(stbname,i))
threads.append(thd.Thread(target=self.insert_data, args=(host, dbname, stbname+"%d"%i, chilCount, ts_start, childrowcount,))) threads.append(thd.Thread(target=self.insert_data, args=(host, dbname, stbname+"%d"%i, chilCount, ts_start, childrowcount,)))
start_time = time.time() start_time = time.time()
for tr in threads: for tr in threads:
tr.start() tr.start()
...@@ -226,10 +226,10 @@ class TDTestCase: ...@@ -226,10 +226,10 @@ class TDTestCase:
tdLog.info("taosd found in %s" % buildPath) tdLog.info("taosd found in %s" % buildPath)
taosBenchbin = buildPath+ "/build/bin/taosBenchmark" taosBenchbin = buildPath+ "/build/bin/taosBenchmark"
os.system("%s -f %s -y " %(taosBenchbin,jsonFile)) os.system("%s -f %s -y " %(taosBenchbin,jsonFile))
return return
def taosBenchCreate(self,host,dropdb,dbname,stbname,vgroups,processNumbers,count): def taosBenchCreate(self,host,dropdb,dbname,stbname,vgroups,processNumbers,count):
# count=50000 # count=50000
buildPath = self.getBuildPath() buildPath = self.getBuildPath()
config = buildPath+ "../sim/dnode1/cfg/" config = buildPath+ "../sim/dnode1/cfg/"
...@@ -243,7 +243,7 @@ class TDTestCase: ...@@ -243,7 +243,7 @@ class TDTestCase:
# tsql.getResult("show databases") # tsql.getResult("show databases")
# print(tdSql.queryResult) # print(tdSql.queryResult)
tsql.execute("use %s" %dbname) tsql.execute("use %s" %dbname)
threads = [] threads = []
for i in range(processNumbers): for i in range(processNumbers):
jsonfile="1-insert/Vgroups%d%d.json"%(vgroups,i) jsonfile="1-insert/Vgroups%d%d.json"%(vgroups,i)
...@@ -254,7 +254,7 @@ class TDTestCase: ...@@ -254,7 +254,7 @@ class TDTestCase:
os.system("sed -i 's/\"childtable_count\": 10000,/\"childtable_count\": %d,/g' %s "%(count,jsonfile)) os.system("sed -i 's/\"childtable_count\": 10000,/\"childtable_count\": %d,/g' %s "%(count,jsonfile))
os.system("sed -i 's/\"name\": \"stb1\",/\"name\": \"%s%d\",/g' %s "%(stbname,i,jsonfile)) os.system("sed -i 's/\"name\": \"stb1\",/\"name\": \"%s%d\",/g' %s "%(stbname,i,jsonfile))
os.system("sed -i 's/\"childtable_prefix\": \"stb1_\",/\"childtable_prefix\": \"%s%d_\",/g' %s "%(stbname,i,jsonfile)) os.system("sed -i 's/\"childtable_prefix\": \"stb1_\",/\"childtable_prefix\": \"%s%d_\",/g' %s "%(stbname,i,jsonfile))
threads.append(mp.Process(target=self.taosBench, args=("%s"%jsonfile,))) threads.append(mp.Process(target=self.taosBench, args=("%s"%jsonfile,)))
start_time = time.time() start_time = time.time()
for tr in threads: for tr in threads:
tr.start() tr.start()
...@@ -276,8 +276,8 @@ class TDTestCase: ...@@ -276,8 +276,8 @@ class TDTestCase:
for i in range(stableCount): for i in range(stableCount):
tdSql.query("select count(*) from %s%d"%(stbname,i)) tdSql.query("select count(*) from %s%d"%(stbname,i))
tdSql.checkData(0,0,rowsPerSTable) tdSql.checkData(0,0,rowsPerSTable)
return return
# test case : Switch back and forth among the three queryPolicy(1\2\3) # test case : Switch back and forth among the three queryPolicy(1\2\3)
def test_case1(self): def test_case1(self):
self.taosBenchCreate("127.0.0.1","no","db1", "stb1", 1, 2, 1*10) self.taosBenchCreate("127.0.0.1","no","db1", "stb1", 1, 2, 1*10)
...@@ -303,7 +303,7 @@ class TDTestCase: ...@@ -303,7 +303,7 @@ class TDTestCase:
tdSql.execute("reset query cache") tdSql.execute("reset query cache")
tdSql.query("select max(c1) from stb10;") tdSql.query("select max(c1) from stb10;")
tdSql.checkData(0, 0, "%s"%maxQnode) tdSql.checkData(0, 0, "%s"%maxQnode)
tdSql.query("select min(c1) from stb11;") tdSql.query("select min(c1) from stb11;")
tdSql.checkData(0, 0, "%s"%minQnode) tdSql.checkData(0, 0, "%s"%minQnode)
tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;") tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;")
unionVnode=tdSql.queryResult unionVnode=tdSql.queryResult
...@@ -352,8 +352,8 @@ class TDTestCase: ...@@ -352,8 +352,8 @@ class TDTestCase:
tdSql.execute("reset query cache") tdSql.execute("reset query cache")
tdSql.query("select max(c1) from stb10;") tdSql.query("select max(c1) from stb10;")
assert maxQnode==tdSql.getData(0,0) assert maxQnode==tdSql.getData(0,0)
tdSql.query("select min(c1) from stb11;") tdSql.query("select min(c1) from stb11;")
assert minQnode==tdSql.getData(0,0) assert minQnode==tdSql.getData(0,0)
tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;") tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;")
tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;") tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;")
...@@ -417,7 +417,7 @@ class TDTestCase: ...@@ -417,7 +417,7 @@ class TDTestCase:
tdLog.exit("alter queryPolicy to %d failed"%queryPolicy) tdLog.exit("alter queryPolicy to %d failed"%queryPolicy)
tdSql.execute("use db1;") tdSql.execute("use db1;")
tdSql.error("select max(c1) from stb10;") tdSql.error("select max(c1) from stb10;")
tdSql.error("select min(c1) from stb11;") tdSql.error("select min(c1) from stb11;")
tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;") tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;")
tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;") tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;")
...@@ -452,20 +452,20 @@ class TDTestCase: ...@@ -452,20 +452,20 @@ class TDTestCase:
tdSql.execute("reset query cache") tdSql.execute("reset query cache")
tdSql.error("select max(c1) from stb10;") tdSql.error("select max(c1) from stb10;")
tdSql.error("select min(c1) from stb11;") tdSql.error("select min(c1) from stb11;")
tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;") tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;")
tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;") tdSql.error("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;")
# run case # run case
def run(self): def run(self):
# test qnode # test qnode
tdLog.debug(" test_case1 ............ [start]") tdLog.debug(" test_case1 ............ [start]")
self.test_case1() self.test_case1()
tdLog.debug(" test_case1 ............ [OK]") tdLog.debug(" test_case1 ............ [OK]")
tdLog.debug(" test_case2 ............ [start]") tdLog.debug(" test_case2 ............ [start]")
self.test_case2() self.test_case2()
tdLog.debug(" test_case2 ............ [OK]") tdLog.debug(" test_case2 ............ [OK]")
tdLog.debug(" test_case3 ............ [start]") tdLog.debug(" test_case3 ............ [start]")
self.test_case3() self.test_case3()
tdLog.debug(" test_case3 ............ [OK]") tdLog.debug(" test_case3 ............ [OK]")
...@@ -475,7 +475,7 @@ class TDTestCase: ...@@ -475,7 +475,7 @@ class TDTestCase:
tdSql.close() tdSql.close()
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
return return
# #
# add case with filename # add case with filename
# #
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册