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

fix: tools/taosdumpTest2.py for 3.0 (#15691)

* fix: tools/taosdumpTest2.py for 3.0

* fix: tools/taosdumpTestNanoSupport.py for 3.0
上级 d6ce40ea
...@@ -35,7 +35,7 @@ class TDTestCase: ...@@ -35,7 +35,7 @@ class TDTestCase:
else: else:
return True return True
def getBuildPath(self): def getPath(self, tool="taosdump"):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath): if ("community" in selfPath):
...@@ -43,25 +43,33 @@ class TDTestCase: ...@@ -43,25 +43,33 @@ class TDTestCase:
else: else:
projPath = selfPath[:selfPath.find("tests")] projPath = selfPath[:selfPath.find("tests")]
paths = []
for root, dirs, files in os.walk(projPath): for root, dirs, files in os.walk(projPath):
if ("taosdump" 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):
if not os.path.exists("./taosdumptest/tmp1"): if not os.path.exists("./taosdumptest/tmp1"):
os.makedirs("./taosdumptest/tmp1") os.makedirs("./taosdumptest/tmp1")
else: else:
print("目录存在") os.system("rm -rf ./taosdumptest/tmp1")
os.makedirs("./taosdumptest/tmp1")
if not os.path.exists("./taosdumptest/tmp2"): if not os.path.exists("./taosdumptest/tmp2"):
os.makedirs("./taosdumptest/tmp2") os.makedirs("./taosdumptest/tmp2")
else:
os.system("rm -rf ./taosdumptest/tmp2")
os.makedirs("./taosdumptest/tmp2")
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
tdSql.execute("create database db duration 11 keep 3649 blocks 8 ") tdSql.execute("create database db duration 11 keep 3649")
tdSql.execute("create database db1 duration 12 keep 3640 blocks 7 ") tdSql.execute("create database db1 duration 12 keep 3640")
tdSql.execute("use db") tdSql.execute("use db")
tdSql.execute( tdSql.execute(
"create table st(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int, t2 binary(10))") "create table st(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int, t2 binary(10))")
...@@ -78,31 +86,30 @@ class TDTestCase: ...@@ -78,31 +86,30 @@ class TDTestCase:
sql += "(%d, %d, 'nchar%d')" % (currts + i, i % 100, i % 100) sql += "(%d, %d, 'nchar%d')" % (currts + i, i % 100, i % 100)
tdSql.execute(sql) tdSql.execute(sql)
buildPath = self.getBuildPath() binPath = self.getPath()
if (buildPath == ""): if (binPath == ""):
tdLog.exit("taosdump not found!") tdLog.exit("taosdump not found!")
else: else:
tdLog.info("taosdump found in %s" % buildPath) tdLog.info("taosdump found: %s" % binPath)
binPath = buildPath + "/build/bin/"
os.system("%staosdump --databases db -o ./taosdumptest/tmp1" % binPath) os.system("%s -y --databases db -o ./taosdumptest/tmp1" % binPath)
os.system( os.system(
"%staosdump --databases db1 -o ./taosdumptest/tmp2" % "%s -y --databases db1 -o ./taosdumptest/tmp2" %
binPath) binPath)
tdSql.execute("drop database db") tdSql.execute("drop database db")
tdSql.execute("drop database db1") tdSql.execute("drop database db1")
tdSql.query("show databases") tdSql.query("show databases")
tdSql.checkRows(0) tdSql.checkRows(2)
os.system("%staosdump -i ./taosdumptest/tmp1" % binPath) os.system("%s -i ./taosdumptest/tmp1" % binPath)
os.system("%staosdump -i ./taosdumptest/tmp2" % binPath) os.system("%s -i ./taosdumptest/tmp2" % binPath)
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("show databases") tdSql.query("show databases")
tdSql.checkRows(2) tdSql.checkRows(4)
dbresult = tdSql.queryResult dbresult = tdSql.queryResult
# 6--duration,7--keep0,keep1,keep, 12--block, # 6--duration,7--keep0,keep1,keep
isCommunity = self.checkCommunity() isCommunity = self.checkCommunity()
print("iscommunity: %d" % isCommunity) print("iscommunity: %d" % isCommunity)
...@@ -111,20 +118,15 @@ class TDTestCase: ...@@ -111,20 +118,15 @@ class TDTestCase:
print(dbresult[i]) print(dbresult[i])
print(type(dbresult[i][6])) print(type(dbresult[i][6]))
print(type(dbresult[i][7])) print(type(dbresult[i][7]))
print(type(dbresult[i][9])) print((dbresult[i][6]))
assert dbresult[i][6] == 11 assert dbresult[i][6] == "15840m"
if isCommunity: print((dbresult[i][7]))
assert dbresult[i][7] == "3649" assert dbresult[i][7] == "5254560m,5254560m,5254560m"
else:
assert dbresult[i][7] == "3649,3649,3649"
assert dbresult[i][9] == 8
if dbresult[i][0] == 'db1': if dbresult[i][0] == 'db1':
assert dbresult[i][6] == 12 print((dbresult[i][6]))
if isCommunity: assert dbresult[i][6] == "17280m"
assert dbresult[i][7] == "3640" print((dbresult[i][7]))
else: assert dbresult[i][7] == "5241600m,5241600m,5241600m"
assert dbresult[i][7] == "3640,3640,3640"
assert dbresult[i][9] == 7
tdSql.query("show stables") tdSql.query("show stables")
tdSql.checkRows(1) tdSql.checkRows(1)
...@@ -132,8 +134,10 @@ class TDTestCase: ...@@ -132,8 +134,10 @@ class TDTestCase:
tdSql.query("show tables") tdSql.query("show tables")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.checkData(0, 0, 't2') dbresult = tdSql.queryResult
tdSql.checkData(1, 0, 't1') print(dbresult)
for i in range(len(dbresult)):
assert ((dbresult[i][0] == "t1") or (dbresult[i][0] == "t2"))
tdSql.query("select * from t1") tdSql.query("select * from t1")
tdSql.checkRows(100) tdSql.checkRows(100)
...@@ -155,7 +159,7 @@ class TDTestCase: ...@@ -155,7 +159,7 @@ class TDTestCase:
os.system("rm -rf ./taosdumptest/tmp2") os.system("rm -rf ./taosdumptest/tmp2")
os.makedirs("./taosdumptest/tmp1") os.makedirs("./taosdumptest/tmp1")
tdSql.execute("create database db12312313231231321312312312_323") tdSql.execute("create database db12312313231231321312312312_323")
tdSql.error("create database db12312313231231321312312312_3231") tdSql.error("create database db012345678911234567892234567893323456789423456789523456789bcdefe")
tdSql.execute("use db12312313231231321312312312_323") tdSql.execute("use db12312313231231321312312312_323")
tdSql.execute("create stable st12345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678_9(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int, t2 binary(10))") tdSql.execute("create stable st12345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678_9(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int, t2 binary(10))")
tdSql.error("create stable st_12345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678_9(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int, t2 binary(10))") tdSql.error("create stable st_12345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678_9(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int, t2 binary(10))")
...@@ -168,9 +172,10 @@ class TDTestCase: ...@@ -168,9 +172,10 @@ class TDTestCase:
tdSql.query("show stables") tdSql.query("show stables")
tdSql.checkRows(2) tdSql.checkRows(2)
os.system( os.system(
"%staosdump --databases db12312313231231321312312312_323 -o ./taosdumptest/tmp1" % binPath) "%s -y --databases db12312313231231321312312312_323 -o ./taosdumptest/tmp1" %
binPath)
tdSql.execute("drop database db12312313231231321312312312_323") tdSql.execute("drop database db12312313231231321312312312_323")
os.system("%staosdump -i ./taosdumptest/tmp1" % binPath) os.system("%s -i ./taosdumptest/tmp1" % binPath)
tdSql.execute("use db12312313231231321312312312_323") tdSql.execute("use db12312313231231321312312312_323")
tdSql.query("show stables") tdSql.query("show stables")
tdSql.checkRows(2) tdSql.checkRows(2)
......
...@@ -26,9 +26,9 @@ class TDTestCase: ...@@ -26,9 +26,9 @@ class TDTestCase:
self.ts = 1601481600000 self.ts = 1601481600000
self.numberOfTables = 1 self.numberOfTables = 1
self.numberOfRecords = 15000 self.numberOfRecords = 150
def getBuildPath(self): def getPath(self, tool="taosdump"):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath): if ("community" in selfPath):
...@@ -36,15 +36,24 @@ class TDTestCase: ...@@ -36,15 +36,24 @@ class TDTestCase:
else: else:
projPath = selfPath[:selfPath.find("tests")] projPath = selfPath[:selfPath.find("tests")]
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):
if not os.path.exists("./taosdumptest/tmp"):
os.makedirs("./taosdumptest/tmp")
else:
os.system("rm -rf ./taosdumptest/tmp")
os.makedirs("./taosdumptest/tmp")
tdSql.prepare() tdSql.prepare()
tdSql.execute("create table st(ts timestamp, c1 timestamp, c2 int, c3 bigint, c4 float, c5 double, c6 binary(8), c7 smallint, c8 tinyint, c9 bool, c10 nchar(8)) tags(t1 int)") tdSql.execute("create table st(ts timestamp, c1 timestamp, c2 int, c3 bigint, c4 float, c5 double, c6 binary(8), c7 smallint, c8 tinyint, c9 bool, c10 nchar(8)) tags(t1 int)")
...@@ -60,27 +69,26 @@ class TDTestCase: ...@@ -60,27 +69,26 @@ class TDTestCase:
break break
tdSql.execute(sql) tdSql.execute(sql)
buildPath = self.getBuildPath() binPath = self.getPath()
if (buildPath == ""): if (binPath == ""):
tdLog.exit("taosdump not found!") tdLog.exit("taosdump not found!")
else: else:
tdLog.info("taosdump found in %s" % buildPath) tdLog.info("taosdump found in %s" % binPath)
binPath = buildPath + "/build/bin/"
os.system("rm /tmp/*.sql") os.system("rm ./taosdumptest/tmp/*.sql")
os.system( os.system(
"%staosdump --databases db -o /tmp -B 32766 -L 1048576" % "%s --databases db -o ./taosdumptest/tmp -B 32766 -L 1048576" %
binPath) binPath)
tdSql.execute("drop database db") tdSql.execute("drop database db")
tdSql.query("show databases") tdSql.query("show databases")
tdSql.checkRows(0) tdSql.checkRows(2)
os.system("%staosdump -i /tmp" % binPath) os.system("%s -i ./taosdumptest/tmp" % binPath)
tdSql.query("show databases") tdSql.query("show databases")
tdSql.checkRows(1) tdSql.checkRows(3)
tdSql.checkData(0, 0, 'db') tdSql.checkData(2, 0, 'db')
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("show stables") tdSql.query("show stables")
...@@ -90,6 +98,38 @@ class TDTestCase: ...@@ -90,6 +98,38 @@ class TDTestCase:
tdSql.query("select count(*) from t1") tdSql.query("select count(*) from t1")
tdSql.checkData(0, 0, self.numberOfRecords) tdSql.checkData(0, 0, self.numberOfRecords)
# test case for TS-1225
tdSql.execute("create database test")
tdSql.execute("use test")
tdSql.execute(
"create table stb(ts timestamp, c1 binary(16374), c2 binary(16374), c3 binary(16374)) tags(t1 nchar(256))")
tdSql.execute(
"insert into t1 using stb tags('t1') values(now, '%s', '%s', '%s')" %
("16374",
"16374",
"16374"))
# sys.exit(0)
os.system("rm ./taosdumptest/tmp/*.sql")
os.system("rm ./taosdumptest/tmp/*.avro*")
os.system("%s -D test -o ./taosdumptest/tmp -y" % binPath)
tdSql.execute("drop database test")
tdSql.query("show databases")
tdSql.checkRows(3)
os.system("%s -i ./taosdumptest/tmp -y" % binPath)
tdSql.execute("use test")
tdSql.error("show vnodes '' ")
tdSql.query("show stables")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 'stb')
tdSql.query("select * from stb")
tdSql.checkRows(1)
os.system("rm -rf dump_result.txt")
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
......
...@@ -35,7 +35,7 @@ class TDTestCase: ...@@ -35,7 +35,7 @@ class TDTestCase:
else: else:
return True return True
def getBuildPath(self): def getPath(self, tool="taosdump"):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath): if ("community" in selfPath):
...@@ -43,15 +43,16 @@ class TDTestCase: ...@@ -43,15 +43,16 @@ class TDTestCase:
else: else:
projPath = selfPath[:selfPath.find("tests")] projPath = selfPath[:selfPath.find("tests")]
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 createdb(self, precision="ns"): def createdb(self, precision="ns"):
tb_nums = self.numberOfTables tb_nums = self.numberOfTables
...@@ -60,13 +61,16 @@ class TDTestCase: ...@@ -60,13 +61,16 @@ class TDTestCase:
def build_db(precision, start_time): def build_db(precision, start_time):
tdSql.execute("drop database if exists timedb1") tdSql.execute("drop database if exists timedb1")
tdSql.execute( tdSql.execute(
"create database timedb1 duration 10 keep 36500 blocks 8 precision "+"\""+precision+"\"") "create database timedb1 duration 10 keep 36500 precision " +
"\"" +
precision +
"\"")
tdSql.execute("use timedb1") tdSql.execute("use timedb1")
tdSql.execute( tdSql.execute(
"create stable st(ts timestamp, c1 int, c2 nchar(10),c3 timestamp) tags(t1 int, t2 binary(10))") "create stable st(ts timestamp, c1 int, c2 nchar(10),c3 timestamp) tags(t1 int, t2 binary(10))")
for tb in range(tb_nums): for tb in range(tb_nums):
tbname = "t"+str(tb) tbname = "t" + str(tb)
tdSql.execute("create table " + tbname + tdSql.execute("create table " + tbname +
" using st tags(1, 'beijing')") " using st tags(1, 'beijing')")
sql = "insert into " + tbname + " values" sql = "insert into " + tbname + " values"
...@@ -79,8 +83,8 @@ class TDTestCase: ...@@ -79,8 +83,8 @@ class TDTestCase:
ts_seed = 1000 ts_seed = 1000
for i in range(per_tb_rows): for i in range(per_tb_rows):
sql += "(%d, %d, 'nchar%d',%d)" % (currts + i*ts_seed, i % sql += "(%d, %d, 'nchar%d',%d)" % (currts + i * ts_seed, i %
100, i % 100, currts + i*100) # currts +1000ms (1000000000ns) 100, i % 100, currts + i * 100) # currts +1000ms (1000000000ns)
tdSql.execute(sql) tdSql.execute(sql)
if precision == "ns": if precision == "ns":
...@@ -97,7 +101,6 @@ class TDTestCase: ...@@ -97,7 +101,6 @@ class TDTestCase:
else: else:
print("other time precision not valid , please check! ") print("other time precision not valid , please check! ")
def run(self): def run(self):
...@@ -118,12 +121,11 @@ class TDTestCase: ...@@ -118,12 +121,11 @@ class TDTestCase:
if not os.path.exists("./taosdumptest/dumptmp3"): if not os.path.exists("./taosdumptest/dumptmp3"):
os.makedirs("./taosdumptest/dumptmp3") os.makedirs("./taosdumptest/dumptmp3")
buildPath = self.getBuildPath() binPath = self.getPath("taosdump")
if (buildPath == ""): if (binPath == ""):
tdLog.exit("taosdump not found!") tdLog.exit("taosdump not found!")
else: else:
tdLog.info("taosdump found in %s" % buildPath) tdLog.info("taosdump found: %s" % binPath)
binPath = buildPath + "/build/bin/"
# create nano second database # create nano second database
...@@ -132,67 +134,51 @@ class TDTestCase: ...@@ -132,67 +134,51 @@ class TDTestCase:
# dump all data # dump all data
os.system( os.system(
"%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % binPath) "%s -y -g --databases timedb1 -o ./taosdumptest/dumptmp1" %
binPath)
# dump part data with -S -E # dump part data with -S -E
os.system( os.system(
'%staosdump --databases timedb1 -S 1625068810000000000 -E 1625068860000000000 -o ./taosdumptest/dumptmp2 ' % '%s -y -g --databases timedb1 -S 1625068810000000000 -E 1625068860000000000 -o ./taosdumptest/dumptmp2 ' %
binPath) binPath)
os.system( os.system(
'%staosdump --databases timedb1 -S 1625068810000000000 -o ./taosdumptest/dumptmp3 ' % '%s -y -g --databases timedb1 -S 1625068810000000000 -o ./taosdumptest/dumptmp3 ' %
binPath) binPath)
# replace strings to dump in databases tdSql.execute("drop database timedb1")
os.system( os.system("%s -i ./taosdumptest/dumptmp2" % binPath)
"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)
# dump data and check for taosdump # dump data and check for taosdump
tdSql.query("select count(*) from dumptmp1.st") tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0,0,1000) tdSql.checkData(0, 0, 510)
tdSql.query("select count(*) from dumptmp2.st") tdSql.execute("drop database timedb1")
tdSql.checkData(0,0,510) os.system("%s -i ./taosdumptest/dumptmp3" % binPath)
# dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 900)
tdSql.query("select count(*) from dumptmp3.st") tdSql.execute("drop database timedb1")
tdSql.checkData(0,0,900) os.system("%s -i ./taosdumptest/dumptmp1" % binPath)
# dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 1000)
# check data # check data
origin_res = tdSql.getResult("select * from timedb1.st") origin_res = tdSql.getResult("select * from timedb1.st")
dump_res = tdSql.getResult("select * from dumptmp1.st") tdSql.execute("drop database timedb1")
if origin_res == dump_res: os.system("%s -i ./taosdumptest/dumptmp1" % binPath)
tdLog.info("test nano second : dump check data pass for all data!" ) # dump data and check for taosdump
else: dump_res = tdSql.getResult("select * from timedb1.st")
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: if origin_res == dump_res:
tdLog.info(" test nano second : dump check data pass for data! " ) tdLog.info("test nano second : dump check data pass for all data!")
else: else:
tdLog.info(" test nano second : dump check data failed for data !" ) tdLog.info(
"test nano second : dump check data failed for all data!")
# us second support test case # us second support test case
os.system("rm -rf ./taosdumptest/") os.system("rm -rf ./taosdumptest/")
tdSql.execute("drop database if exists dumptmp1") tdSql.execute("drop database if exists timedb1")
tdSql.execute("drop database if exists dumptmp2")
tdSql.execute("drop database if exists dumptmp3")
if not os.path.exists("./taosdumptest/tmp1"): if not os.path.exists("./taosdumptest/tmp1"):
os.makedirs("./taosdumptest/dumptmp1") os.makedirs("./taosdumptest/dumptmp1")
...@@ -205,75 +191,63 @@ class TDTestCase: ...@@ -205,75 +191,63 @@ class TDTestCase:
if not os.path.exists("./taosdumptest/dumptmp3"): if not os.path.exists("./taosdumptest/dumptmp3"):
os.makedirs("./taosdumptest/dumptmp3") os.makedirs("./taosdumptest/dumptmp3")
buildPath = self.getBuildPath() binPath = self.getPath()
if (buildPath == ""): if (binPath == ""):
tdLog.exit("taosdump not found!") tdLog.exit("taosdump not found!")
else: else:
tdLog.info("taosdump found in %s" % buildPath) tdLog.info("taosdump found: %s" % binPath)
binPath = buildPath + "/build/bin/"
self.createdb(precision="us") self.createdb(precision="us")
os.system( os.system(
"%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % binPath) "%s -y -g --databases timedb1 -o ./taosdumptest/dumptmp1" %
binPath)
os.system( os.system(
'%staosdump --databases timedb1 -S 1625068810000000 -E 1625068860000000 -o ./taosdumptest/dumptmp2 ' % '%s -y -g --databases timedb1 -S 1625068810000000 -E 1625068860000000 -o ./taosdumptest/dumptmp2 ' %
binPath) binPath)
os.system( os.system(
'%staosdump --databases timedb1 -S 1625068810000000 -o ./taosdumptest/dumptmp3 ' % '%s -y -g --databases timedb1 -S 1625068810000000 -o ./taosdumptest/dumptmp3 ' %
binPath) binPath)
os.system( os.system("%s -i ./taosdumptest/dumptmp1" % binPath)
"sed -i \"s/timedb1/dumptmp1/g\" `grep timedb1 -rl ./taosdumptest/dumptmp1`") os.system("%s -i ./taosdumptest/dumptmp2" % binPath)
os.system( os.system("%s -i ./taosdumptest/dumptmp3" % binPath)
"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("%s -i ./taosdumptest/dumptmp2" % binPath)
os.system( "%staosdump -i ./taosdumptest/dumptmp3" %binPath) # dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 510)
tdSql.query("select count(*) from dumptmp1.st")
tdSql.checkData(0,0,1000)
tdSql.query("select count(*) from dumptmp2.st") tdSql.execute("drop database timedb1")
tdSql.checkData(0,0,510) os.system("%s -i ./taosdumptest/dumptmp3" % binPath)
# dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 900)
tdSql.query("select count(*) from dumptmp3.st") tdSql.execute("drop database timedb1")
tdSql.checkData(0,0,900) os.system("%s -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") origin_res = tdSql.getResult("select * from timedb1.st")
dump_res = tdSql.getResult("select * from dumptmp1.st") tdSql.execute("drop database timedb1")
if origin_res == dump_res: os.system("%s -i ./taosdumptest/dumptmp1" % binPath)
tdLog.info("test us second : dump check data pass for all data!" ) # dump data and check for taosdump
else: dump_res = tdSql.getResult("select * from timedb1.st")
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!" )
origin_res = tdSql.getResult("select * from timedb1.st where ts >=1625068810000000 ")
dump_res = tdSql.getResult("select * from dumptmp3.st")
if origin_res == dump_res: 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: 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 # ms second support test case
os.system("rm -rf ./taosdumptest/") os.system("rm -rf ./taosdumptest/")
tdSql.execute("drop database if exists dumptmp1") tdSql.execute("drop database if exists timedb1")
tdSql.execute("drop database if exists dumptmp2")
tdSql.execute("drop database if exists dumptmp3")
if not os.path.exists("./taosdumptest/tmp1"): if not os.path.exists("./taosdumptest/tmp1"):
os.makedirs("./taosdumptest/dumptmp1") os.makedirs("./taosdumptest/dumptmp1")
...@@ -286,69 +260,60 @@ class TDTestCase: ...@@ -286,69 +260,60 @@ class TDTestCase:
if not os.path.exists("./taosdumptest/dumptmp3"): if not os.path.exists("./taosdumptest/dumptmp3"):
os.makedirs("./taosdumptest/dumptmp3") os.makedirs("./taosdumptest/dumptmp3")
buildPath = self.getBuildPath() binPath = self.getPath()
if (buildPath == ""): if (binPath == ""):
tdLog.exit("taosdump not found!") tdLog.exit("taosdump not found!")
else: else:
tdLog.info("taosdump found in %s" % buildPath) tdLog.info("taosdump found: %s" % binPath)
binPath = buildPath + "/build/bin/"
self.createdb(precision="ms") self.createdb(precision="ms")
os.system( os.system(
"%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % binPath) "%s -y -g --databases timedb1 -o ./taosdumptest/dumptmp1" %
binPath)
os.system( os.system(
'%staosdump --databases timedb1 -S 1625068810000 -E 1625068860000 -o ./taosdumptest/dumptmp2 ' % '%s -y -g --databases timedb1 -S 1625068810000 -E 1625068860000 -o ./taosdumptest/dumptmp2 ' %
binPath) binPath)
os.system( os.system(
'%staosdump --databases timedb1 -S 1625068810000 -o ./taosdumptest/dumptmp3 ' % '%s -y -g --databases timedb1 -S 1625068810000 -o ./taosdumptest/dumptmp3 ' %
binPath) binPath)
os.system( os.system("%s -i ./taosdumptest/dumptmp1" % binPath)
"sed -i \"s/timedb1/dumptmp1/g\" `grep timedb1 -rl ./taosdumptest/dumptmp1`") os.system("%s -i ./taosdumptest/dumptmp2" % binPath)
os.system( os.system("%s -i ./taosdumptest/dumptmp3" % binPath)
"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.execute("drop database timedb1")
tdSql.query("select count(*) from dumptmp1.st") os.system("%s -i ./taosdumptest/dumptmp2" % binPath)
tdSql.checkData(0,0,1000) # dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 510)
tdSql.query("select count(*) from dumptmp2.st") tdSql.execute("drop database timedb1")
tdSql.checkData(0,0,510) os.system("%s -i ./taosdumptest/dumptmp3" % binPath)
# dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 900)
tdSql.query("select count(*) from dumptmp3.st") tdSql.execute("drop database timedb1")
tdSql.checkData(0,0,900) os.system("%s -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") origin_res = tdSql.getResult("select * from timedb1.st")
dump_res = tdSql.getResult("select * from dumptmp1.st") tdSql.execute("drop database timedb1")
if origin_res == dump_res: os.system("%s -i ./taosdumptest/dumptmp1" % binPath)
tdLog.info("test ms second : dump check data pass for all data!" ) # dump data and check for taosdump
else: dump_res = tdSql.getResult("select * from timedb1.st")
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!" )
origin_res = tdSql.getResult("select * from timedb1.st where ts >=1625068810000 ")
dump_res = tdSql.getResult("select * from dumptmp3.st")
if origin_res == dump_res: 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: 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 ./taosdumptest/")
os.system("rm -rf ./dump_result.txt") os.system("rm -rf ./dump_result.txt")
os.system("rm -rf *.py.sql") os.system("rm -rf *.py.sql")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册