提交 f1454669 编写于 作者: W wenzhouwww

change test case for CI for dump data into databases

上级 0b01819d
......@@ -100,25 +100,40 @@ class TDTestCase:
shutil.rmtree("./dumpdata")
os.mkdir("./dumpdata")
os.system(build_path + "/" + "taosdump -D test -o ./dumpdata")
sleep(2)
os.system("cd ./dumpdata && mv dbs.sql tables.sql")
os.system('sed -i "s/test/dumptest/g" `grep test -rl ./dumpdata`')
os.system(build_path + "/" + "taos -D ./dumpdata")
tdSql.query("select count(*) from dumptest.st")
tdSql.checkData(0, 0, 50)
# write data into sqls file
tables = ["CREATE DATABASE IF NOT EXISTS opendbtest REPLICA 1 QUORUM 1 DAYS\
10 KEEP 3650 CACHE 16 BLOCKS 16 MINROWS 100 MAXROWS 4096 FSYNC 3000 CACHELAST 0 COMP 2 PRECISION 'ms' UPDATE 0;",
"CREATE TABLE IF NOT EXISTS opendbtest.cpus (ts TIMESTAMP, value DOUBLE) TAGS (author NCHAR(2), \
department NCHAR(7), env NCHAR(4), hostname NCHAR(5), os NCHAR(6), production NCHAR(8), \
team NCHAR(7), type NCHAR(10), useage NCHAR(7), workflow NCHAR(4));"]
with open("./dumpdata/tables.sql" ,"a") as f :
for item in tables:
f.write(item)
f.write("\n")
f.close()
records = [ "CREATE TABLE IF NOT EXISTS opendbtest.tb USING opendbtest.cpus TAGS ('dd', 'Beijing', 'test', 'vm_7', 'ubuntu', 'taosdata', 'develop', 'usage_user', 'monitor', 'TIMI');",
"INSERT INTO opendbtest.tb VALUES (1420070400000, 59.078475);",
"INSERT INTO opendbtest.tb VALUES (1420070410000, 44.844490);",
"INSERT INTO opendbtest.tb VALUES (1420070420000, 34.796703);",
"INSERT INTO opendbtest.tb VALUES (1420070430000, 35.758099);",
"INSERT INTO opendbtest.tb VALUES (1420070440000, 51.502387);"]
with open("./dumpdata/opendbtest.0.sql" ,"a") as f :
for item in records:
f.write(item)
f.write("\n")
f.close()
tdLog.info("========test other file name about tables.sql========")
os.system("rm -rf ./dumpdata/*")
os.system(build_path + "/" + "taosdump -D test -o ./dumpdata")
sleep(2)
os.system("cd ./dumpdata && mv dbs.sql table.sql")
os.system('sed -i "s/test/tt/g" `grep test -rl ./dumpdata`')
cmd = build_path + "/" + "taos -D ./dumpdata"
out = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE).stderr.read().decode("utf-8")
if out.find("error:") >=0:
print("===========expected error occured======")
tdSql.query("select value from opendbtest.tb")
tdSql.checkRows(5)
tdLog.info("====== check taos shell params ========")
......@@ -162,6 +177,7 @@ class TDTestCase:
continue
else:
cmd = build_path + "/" + "taos -s \" insert into dbst.tb2 values(now ,2,2.0,'"+code+"','汉字"+code+"\')\""
print(cmd)
self.execute_cmd(cmd)
......@@ -192,6 +208,7 @@ class TDTestCase:
for query in querys:
cmd = build_path + "/" + "taos -s \""+query+"\""
self.execute_cmd(cmd)
print(cmd)
def stop(self):
tdSql.close()
......
......@@ -182,7 +182,7 @@ python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoIns
python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.py
python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanosubscribe.py
python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestInsertTime_step.py
# disable due to taosdump don't support sql format. python3 test.py -f tools/taosdumpTestNanoSupport.py
python3 test.py -f tools/taosdumpTestNanoSupport.py
#
python3 ./test.py -f tsdb/tsdbComp.py
......@@ -305,7 +305,7 @@ python3 ./test.py -f client/client.py
python3 ./test.py -f client/version.py
python3 ./test.py -f client/alterDatabase.py
python3 ./test.py -f client/noConnectionErrorTest.py
# disable due to taosdump don't support sql format. python3 ./test.py -f client/taoshellCheckCase.py
python3 ./test.py -f client/taoshellCheckCase.py
# python3 test.py -f client/change_time_1_1.py
# python3 test.py -f client/change_time_1_2.py
......
......@@ -143,59 +143,41 @@ class TDTestCase:
'%staosdump --databases timedb1 -S 1625068810000000000 -o ./taosdumptest/dumptmp3 ' %
binPath)
# replace strings to dump in databases
os.system(
"sed -i \"s/timedb1/dumptmp1/g\" `grep timedb1 -rl ./taosdumptest/dumptmp1`")
os.system(
"sed -i \"s/timedb1/dumptmp2/g\" `grep timedb1 -rl ./taosdumptest/dumptmp2`")
os.system(
"sed -i \"s/timedb1/dumptmp3/g\" `grep timedb1 -rl ./taosdumptest/dumptmp3`")
os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath)
tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath)
os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath)
# dump data and check for taosdump
tdSql.query("select count(*) from dumptmp1.st")
tdSql.checkData(0, 0, 1000)
tdSql.query("select count(*) from dumptmp2.st")
tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 510)
tdSql.query("select count(*) from dumptmp3.st")
tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath)
# dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 900)
tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath)
# dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 1000)
# check data
origin_res = tdSql.getResult("select * from timedb1.st")
dump_res = tdSql.getResult("select * from dumptmp1.st")
tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath)
# dump data and check for taosdump
dump_res = tdSql.getResult("select * from timedb1.st")
if origin_res == dump_res:
tdLog.info("test nano second : dump check data pass for all data!")
else:
tdLog.info(
"test nano second : dump check data failed for all data!")
origin_res = tdSql.getResult(
"select * from timedb1.st where ts >=1625068810000000000 and ts <= 1625068860000000000")
dump_res = tdSql.getResult("select * from dumptmp2.st")
if origin_res == dump_res:
tdLog.info(" test nano second : dump check data pass for data! ")
else:
tdLog.info(" test nano second : dump check data failed for data !")
origin_res = tdSql.getResult(
"select * from timedb1.st where ts >=1625068810000000000 ")
dump_res = tdSql.getResult("select * from dumptmp3.st")
if origin_res == dump_res:
tdLog.info(" test nano second : dump check data pass for data! ")
else:
tdLog.info(" test nano second : dump check data failed for data !")
# us second support test case
os.system("rm -rf ./taosdumptest/")
tdSql.execute("drop database if exists dumptmp1")
tdSql.execute("drop database if exists dumptmp2")
tdSql.execute("drop database if exists dumptmp3")
tdSql.execute("drop database if exists timedb1")
if not os.path.exists("./taosdumptest/tmp1"):
os.makedirs("./taosdumptest/dumptmp1")
......@@ -228,55 +210,44 @@ class TDTestCase:
'%staosdump --databases timedb1 -S 1625068810000000 -o ./taosdumptest/dumptmp3 ' %
binPath)
os.system(
"sed -i \"s/timedb1/dumptmp1/g\" `grep timedb1 -rl ./taosdumptest/dumptmp1`")
os.system(
"sed -i \"s/timedb1/dumptmp2/g\" `grep timedb1 -rl ./taosdumptest/dumptmp2`")
os.system(
"sed -i \"s/timedb1/dumptmp3/g\" `grep timedb1 -rl ./taosdumptest/dumptmp3`")
os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath)
os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath)
os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath)
tdSql.query("select count(*) from dumptmp1.st")
tdSql.checkData(0, 0, 1000)
tdSql.query("select count(*) from dumptmp2.st")
tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath)
# dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 510)
tdSql.query("select count(*) from dumptmp3.st")
tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath)
# dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 900)
origin_res = tdSql.getResult("select * from timedb1.st")
dump_res = tdSql.getResult("select * from dumptmp1.st")
if origin_res == dump_res:
tdLog.info("test us second : dump check data pass for all data!")
else:
tdLog.info("test us second : dump check data failed for all data!")
origin_res = tdSql.getResult(
"select * from timedb1.st where ts >=1625068810000000 and ts <= 1625068860000000")
dump_res = tdSql.getResult("select * from dumptmp2.st")
if origin_res == dump_res:
tdLog.info(" test us second : dump check data pass for data! ")
else:
tdLog.info(" test us second : dump check data failed for data!")
tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath)
# dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 1000)
origin_res = tdSql.getResult(
"select * from timedb1.st where ts >=1625068810000000 ")
dump_res = tdSql.getResult("select * from dumptmp3.st")
# check data
origin_res = tdSql.getResult("select * from timedb1.st")
tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath)
# dump data and check for taosdump
dump_res = tdSql.getResult("select * from timedb1.st")
if origin_res == dump_res:
tdLog.info(" test us second : dump check data pass for data! ")
tdLog.info("test micro second : dump check data pass for all data!")
else:
tdLog.info(" test us second : dump check data failed for data! ")
tdLog.info(
"test micro second : dump check data failed for all data!")
# ms second support test case
os.system("rm -rf ./taosdumptest/")
tdSql.execute("drop database if exists dumptmp1")
tdSql.execute("drop database if exists dumptmp2")
tdSql.execute("drop database if exists dumptmp3")
tdSql.execute("drop database if exists timedb1")
if not os.path.exists("./taosdumptest/tmp1"):
os.makedirs("./taosdumptest/dumptmp1")
......@@ -309,48 +280,39 @@ class TDTestCase:
'%staosdump --databases timedb1 -S 1625068810000 -o ./taosdumptest/dumptmp3 ' %
binPath)
os.system(
"sed -i \"s/timedb1/dumptmp1/g\" `grep timedb1 -rl ./taosdumptest/dumptmp1`")
os.system(
"sed -i \"s/timedb1/dumptmp2/g\" `grep timedb1 -rl ./taosdumptest/dumptmp2`")
os.system(
"sed -i \"s/timedb1/dumptmp3/g\" `grep timedb1 -rl ./taosdumptest/dumptmp3`")
os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath)
os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath)
os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath)
tdSql.query("select count(*) from dumptmp1.st")
tdSql.checkData(0, 0, 1000)
tdSql.query("select count(*) from dumptmp2.st")
tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath)
# dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 510)
tdSql.query("select count(*) from dumptmp3.st")
tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath)
# dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 900)
origin_res = tdSql.getResult("select * from timedb1.st")
dump_res = tdSql.getResult("select * from dumptmp1.st")
if origin_res == dump_res:
tdLog.info("test ms second : dump check data pass for all data!")
else:
tdLog.info("test ms second : dump check data failed for all data!")
origin_res = tdSql.getResult(
"select * from timedb1.st where ts >=1625068810000 and ts <= 1625068860000")
dump_res = tdSql.getResult("select * from dumptmp2.st")
if origin_res == dump_res:
tdLog.info(" test ms second : dump check data pass for data! ")
else:
tdLog.info(" test ms second : dump check data failed for data!")
tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath)
# dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 1000)
origin_res = tdSql.getResult(
"select * from timedb1.st where ts >=1625068810000 ")
dump_res = tdSql.getResult("select * from dumptmp3.st")
# check data
origin_res = tdSql.getResult("select * from timedb1.st")
tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath)
# dump data and check for taosdump
dump_res = tdSql.getResult("select * from timedb1.st")
if origin_res == dump_res:
tdLog.info(" test ms second : dump check data pass for data! ")
tdLog.info("test million second : dump check data pass for all data!")
else:
tdLog.info(" test ms second : dump check data failed for data! ")
tdLog.info(
"test million second : dump check data failed for all data!")
os.system("rm -rf ./taosdumptest/")
os.system("rm -rf ./dump_result.txt")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册