From 86b09819cface009d7195b189e3a1137b3a9007e Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Thu, 31 Mar 2022 09:20:13 +0800 Subject: [PATCH] [TD-13052]: taosdump prepare for 3.0 (#11125) * [TD-13052]: taosdump prepare for 3.0 for 2.4 * update taos-tools for 2.4 * add -y -g in tests/pytest/tools/taosdumpTestNanoSupport.py --- src/kit/taos-tools | 2 +- tests/pytest/tools/taosdumpTest.py | 29 ++--- tests/pytest/tools/taosdumpTestNanoSupport.py | 112 +++++++++--------- 3 files changed, 71 insertions(+), 72 deletions(-) diff --git a/src/kit/taos-tools b/src/kit/taos-tools index 8145dd1713..33cdfe4f90 160000 --- a/src/kit/taos-tools +++ b/src/kit/taos-tools @@ -1 +1 @@ -Subproject commit 8145dd1713ab9e7652ea621ca7e6895fd0b21d65 +Subproject commit 33cdfe4f90a209f105c1b6091439798a9cde1e93 diff --git a/tests/pytest/tools/taosdumpTest.py b/tests/pytest/tools/taosdumpTest.py index 628617e27b..a92c242119 100644 --- a/tests/pytest/tools/taosdumpTest.py +++ b/tests/pytest/tools/taosdumpTest.py @@ -35,7 +35,7 @@ class TDTestCase: else: return True - def getBuildPath(self): + def getPath(self, tool="taosdump"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -43,13 +43,14 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosdump" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root) - len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + return paths[0] def run(self): if not os.path.exists("./taosdumptest/tmp1"): @@ -78,16 +79,15 @@ class TDTestCase: sql += "(%d, %d, 'nchar%d')" % (currts + i, i % 100, i % 100) tdSql.execute(sql) - buildPath = self.getBuildPath() - if (buildPath == ""): + binPath = self.getPath() + if (binPath == ""): tdLog.exit("taosdump not found!") else: - tdLog.info("taosdump found in %s" % buildPath) - binPath = buildPath + "/build/bin/" + tdLog.info("taosdump found: %s" % binPath) - os.system("%staosdump --databases db -o ./taosdumptest/tmp1" % binPath) + os.system("%s -y --databases db -o ./taosdumptest/tmp1" % binPath) os.system( - "%staosdump --databases db1 -o ./taosdumptest/tmp2" % + "%s -y --databases db1 -o ./taosdumptest/tmp2" % binPath) tdSql.execute("drop database db") @@ -95,8 +95,8 @@ class TDTestCase: tdSql.query("show databases") tdSql.checkRows(0) - os.system("%staosdump -i ./taosdumptest/tmp1" % binPath) - os.system("%staosdump -i ./taosdumptest/tmp2" % binPath) + os.system("%s -i ./taosdumptest/tmp1" % binPath) + os.system("%s -i ./taosdumptest/tmp2" % binPath) tdSql.execute("use db") tdSql.query("show databases") @@ -168,9 +168,10 @@ class TDTestCase: tdSql.query("show stables") tdSql.checkRows(2) 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") - os.system("%staosdump -i ./taosdumptest/tmp1" % binPath) + os.system("%s -i ./taosdumptest/tmp1" % binPath) tdSql.execute("use db12312313231231321312312312_323") tdSql.query("show stables") tdSql.checkRows(2) diff --git a/tests/pytest/tools/taosdumpTestNanoSupport.py b/tests/pytest/tools/taosdumpTestNanoSupport.py index 81e3159346..cbcf57db0a 100644 --- a/tests/pytest/tools/taosdumpTestNanoSupport.py +++ b/tests/pytest/tools/taosdumpTestNanoSupport.py @@ -35,7 +35,7 @@ class TDTestCase: else: return True - def getBuildPath(self): + def getPath(self, tool="taosdump"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -43,13 +43,14 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root) - len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + return paths[0] def createdb(self, precision="ns"): tb_nums = self.numberOfTables @@ -118,12 +119,11 @@ class TDTestCase: if not os.path.exists("./taosdumptest/dumptmp3"): os.makedirs("./taosdumptest/dumptmp3") - buildPath = self.getBuildPath() - if (buildPath == ""): + binPath = self.getPath("taosdump") + if (binPath == ""): tdLog.exit("taosdump not found!") else: - tdLog.info("taosdump found in %s" % buildPath) - binPath = buildPath + "/build/bin/" + tdLog.info("taosdump found: %s" % binPath) # create nano second database @@ -132,40 +132,40 @@ class TDTestCase: # dump all data os.system( - "%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % + "%s -y -g --databases timedb1 -o ./taosdumptest/dumptmp1" % binPath) # dump part data with -S -E 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) os.system( - '%staosdump --databases timedb1 -S 1625068810000000000 -o ./taosdumptest/dumptmp3 ' % + '%s -y -g --databases timedb1 -S 1625068810000000000 -o ./taosdumptest/dumptmp3 ' % binPath) tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) - # dump data and check for taosdump + os.system("%s -i ./taosdumptest/dumptmp2" % binPath) + # dump data and check for taosdump tdSql.query("select count(*) from timedb1.st") tdSql.checkData(0, 0, 510) tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) - # dump data and check for taosdump + 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.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) - # dump data and check for taosdump + 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") tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) - # dump data and check for taosdump + os.system("%s -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!") @@ -177,7 +177,6 @@ class TDTestCase: os.system("rm -rf ./taosdumptest/") tdSql.execute("drop database if exists timedb1") - if not os.path.exists("./taosdumptest/tmp1"): os.makedirs("./taosdumptest/dumptmp1") @@ -190,53 +189,52 @@ class TDTestCase: if not os.path.exists("./taosdumptest/dumptmp3"): os.makedirs("./taosdumptest/dumptmp3") - buildPath = self.getBuildPath() - if (buildPath == ""): + binPath = self.getPath() + if (binPath == ""): tdLog.exit("taosdump not found!") else: - tdLog.info("taosdump found in %s" % buildPath) - binPath = buildPath + "/build/bin/" + tdLog.info("taosdump found: %s" % binPath) self.createdb(precision="us") os.system( - "%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % + "%s -y -g --databases timedb1 -o ./taosdumptest/dumptmp1" % binPath) 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) os.system( - '%staosdump --databases timedb1 -S 1625068810000000 -o ./taosdumptest/dumptmp3 ' % + '%s -y -g --databases timedb1 -S 1625068810000000 -o ./taosdumptest/dumptmp3 ' % binPath) - os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) - os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) - os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) + os.system("%s -i ./taosdumptest/dumptmp1" % binPath) + os.system("%s -i ./taosdumptest/dumptmp2" % binPath) + os.system("%s -i ./taosdumptest/dumptmp3" % binPath) tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) - # dump data and check for taosdump + os.system("%s -i ./taosdumptest/dumptmp2" % binPath) + # dump data and check for taosdump tdSql.query("select count(*) from timedb1.st") tdSql.checkData(0, 0, 510) tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) - # dump data and check for taosdump + 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.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) - # dump data and check for taosdump + 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") tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) - # dump data and check for taosdump + os.system("%s -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 micro second : dump check data pass for all data!") @@ -260,56 +258,56 @@ class TDTestCase: if not os.path.exists("./taosdumptest/dumptmp3"): os.makedirs("./taosdumptest/dumptmp3") - buildPath = self.getBuildPath() - if (buildPath == ""): + binPath = self.getPath() + if (binPath == ""): tdLog.exit("taosdump not found!") else: - tdLog.info("taosdump found in %s" % buildPath) - binPath = buildPath + "/build/bin/" + tdLog.info("taosdump found: %s" % binPath) self.createdb(precision="ms") os.system( - "%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % + "%s -y -g --databases timedb1 -o ./taosdumptest/dumptmp1" % binPath) 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) os.system( - '%staosdump --databases timedb1 -S 1625068810000 -o ./taosdumptest/dumptmp3 ' % + '%s -y -g --databases timedb1 -S 1625068810000 -o ./taosdumptest/dumptmp3 ' % binPath) - os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) - os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) - os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) + os.system("%s -i ./taosdumptest/dumptmp1" % binPath) + os.system("%s -i ./taosdumptest/dumptmp2" % binPath) + os.system("%s -i ./taosdumptest/dumptmp3" % binPath) tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) - # dump data and check for taosdump + os.system("%s -i ./taosdumptest/dumptmp2" % binPath) + # dump data and check for taosdump tdSql.query("select count(*) from timedb1.st") tdSql.checkData(0, 0, 510) tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) - # dump data and check for taosdump + 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.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) - # dump data and check for taosdump + 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") tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) - # dump data and check for taosdump + os.system("%s -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 million second : dump check data pass for all data!") + tdLog.info( + "test million second : dump check data pass for all data!") else: tdLog.info( "test million second : dump check data failed for all data!") -- GitLab