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

[TD-13052]<feature>: taosdump prepare for 3.0 (#11125)

* [TD-13052]<feature>: taosdump prepare for 3.0

for 2.4

* update taos-tools

for 2.4

* add -y -g in tests/pytest/tools/taosdumpTestNanoSupport.py
上级 b5033b4c
Subproject commit 8145dd1713ab9e7652ea621ca7e6895fd0b21d65 Subproject commit 33cdfe4f90a209f105c1b6091439798a9cde1e93
...@@ -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,13 +43,14 @@ class TDTestCase: ...@@ -43,13 +43,14 @@ 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 return paths[0]
def run(self): def run(self):
if not os.path.exists("./taosdumptest/tmp1"): if not os.path.exists("./taosdumptest/tmp1"):
...@@ -78,16 +79,15 @@ class TDTestCase: ...@@ -78,16 +79,15 @@ 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")
...@@ -95,8 +95,8 @@ class TDTestCase: ...@@ -95,8 +95,8 @@ class TDTestCase:
tdSql.query("show databases") tdSql.query("show databases")
tdSql.checkRows(0) tdSql.checkRows(0)
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")
...@@ -168,9 +168,10 @@ class TDTestCase: ...@@ -168,9 +168,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)
......
...@@ -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,13 +43,14 @@ class TDTestCase: ...@@ -43,13 +43,14 @@ 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 return paths[0]
def createdb(self, precision="ns"): def createdb(self, precision="ns"):
tb_nums = self.numberOfTables tb_nums = self.numberOfTables
...@@ -118,12 +119,11 @@ class TDTestCase: ...@@ -118,12 +119,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,31 +132,31 @@ class TDTestCase: ...@@ -132,31 +132,31 @@ class TDTestCase:
# dump all data # dump all data
os.system( os.system(
"%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % "%s -y -g --databases timedb1 -o ./taosdumptest/dumptmp1" %
binPath) 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)
tdSql.execute("drop database timedb1") tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) os.system("%s -i ./taosdumptest/dumptmp2" % binPath)
# dump data and check for taosdump # dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st") tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 510) tdSql.checkData(0, 0, 510)
tdSql.execute("drop database timedb1") tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) os.system("%s -i ./taosdumptest/dumptmp3" % binPath)
# dump data and check for taosdump # dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st") tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 900) tdSql.checkData(0, 0, 900)
tdSql.execute("drop database timedb1") tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) os.system("%s -i ./taosdumptest/dumptmp1" % binPath)
# dump data and check for taosdump # dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st") tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 1000) tdSql.checkData(0, 0, 1000)
...@@ -164,7 +164,7 @@ class TDTestCase: ...@@ -164,7 +164,7 @@ class TDTestCase:
# check data # check data
origin_res = tdSql.getResult("select * from timedb1.st") origin_res = tdSql.getResult("select * from timedb1.st")
tdSql.execute("drop database timedb1") tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) os.system("%s -i ./taosdumptest/dumptmp1" % binPath)
# dump data and check for taosdump # dump data and check for taosdump
dump_res = tdSql.getResult("select * from timedb1.st") dump_res = tdSql.getResult("select * from timedb1.st")
if origin_res == dump_res: if origin_res == dump_res:
...@@ -178,7 +178,6 @@ class TDTestCase: ...@@ -178,7 +178,6 @@ class TDTestCase:
os.system("rm -rf ./taosdumptest/") os.system("rm -rf ./taosdumptest/")
tdSql.execute("drop database if exists timedb1") tdSql.execute("drop database if exists timedb1")
if not os.path.exists("./taosdumptest/tmp1"): if not os.path.exists("./taosdumptest/tmp1"):
os.makedirs("./taosdumptest/dumptmp1") os.makedirs("./taosdumptest/dumptmp1")
else: else:
...@@ -190,44 +189,43 @@ class TDTestCase: ...@@ -190,44 +189,43 @@ 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" % "%s -y -g --databases timedb1 -o ./taosdumptest/dumptmp1" %
binPath) 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("%staosdump -i ./taosdumptest/dumptmp1" % binPath) os.system("%s -i ./taosdumptest/dumptmp1" % binPath)
os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) os.system("%s -i ./taosdumptest/dumptmp2" % binPath)
os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) os.system("%s -i ./taosdumptest/dumptmp3" % binPath)
tdSql.execute("drop database timedb1") tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) os.system("%s -i ./taosdumptest/dumptmp2" % binPath)
# dump data and check for taosdump # dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st") tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 510) tdSql.checkData(0, 0, 510)
tdSql.execute("drop database timedb1") tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) os.system("%s -i ./taosdumptest/dumptmp3" % binPath)
# dump data and check for taosdump # dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st") tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 900) tdSql.checkData(0, 0, 900)
tdSql.execute("drop database timedb1") tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) os.system("%s -i ./taosdumptest/dumptmp1" % binPath)
# dump data and check for taosdump # dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st") tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 1000) tdSql.checkData(0, 0, 1000)
...@@ -235,7 +233,7 @@ class TDTestCase: ...@@ -235,7 +233,7 @@ class TDTestCase:
# check data # check data
origin_res = tdSql.getResult("select * from timedb1.st") origin_res = tdSql.getResult("select * from timedb1.st")
tdSql.execute("drop database timedb1") tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) os.system("%s -i ./taosdumptest/dumptmp1" % binPath)
# dump data and check for taosdump # dump data and check for taosdump
dump_res = tdSql.getResult("select * from timedb1.st") dump_res = tdSql.getResult("select * from timedb1.st")
if origin_res == dump_res: if origin_res == dump_res:
...@@ -260,44 +258,43 @@ class TDTestCase: ...@@ -260,44 +258,43 @@ 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" % "%s -y -g --databases timedb1 -o ./taosdumptest/dumptmp1" %
binPath) 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("%staosdump -i ./taosdumptest/dumptmp1" % binPath) os.system("%s -i ./taosdumptest/dumptmp1" % binPath)
os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) os.system("%s -i ./taosdumptest/dumptmp2" % binPath)
os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) os.system("%s -i ./taosdumptest/dumptmp3" % binPath)
tdSql.execute("drop database timedb1") tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) os.system("%s -i ./taosdumptest/dumptmp2" % binPath)
# dump data and check for taosdump # dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st") tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 510) tdSql.checkData(0, 0, 510)
tdSql.execute("drop database timedb1") tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) os.system("%s -i ./taosdumptest/dumptmp3" % binPath)
# dump data and check for taosdump # dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st") tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 900) tdSql.checkData(0, 0, 900)
tdSql.execute("drop database timedb1") tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) os.system("%s -i ./taosdumptest/dumptmp1" % binPath)
# dump data and check for taosdump # dump data and check for taosdump
tdSql.query("select count(*) from timedb1.st") tdSql.query("select count(*) from timedb1.st")
tdSql.checkData(0, 0, 1000) tdSql.checkData(0, 0, 1000)
...@@ -305,11 +302,12 @@ class TDTestCase: ...@@ -305,11 +302,12 @@ class TDTestCase:
# check data # check data
origin_res = tdSql.getResult("select * from timedb1.st") origin_res = tdSql.getResult("select * from timedb1.st")
tdSql.execute("drop database timedb1") tdSql.execute("drop database timedb1")
os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) os.system("%s -i ./taosdumptest/dumptmp1" % binPath)
# dump data and check for taosdump # dump data and check for taosdump
dump_res = tdSql.getResult("select * from timedb1.st") dump_res = tdSql.getResult("select * from timedb1.st")
if origin_res == dump_res: if origin_res == dump_res:
tdLog.info("test million second : dump check data pass for all data!") tdLog.info(
"test million second : dump check data pass for all data!")
else: else:
tdLog.info( tdLog.info(
"test million second : dump check data failed for all data!") "test million second : dump check data failed for all data!")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册