From f4e00a24834d7937e8034fb5f1a8ca272343531d Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Tue, 24 Dec 2024 14:57:46 +0800 Subject: [PATCH] fix: replace getPath() function --- tests/army/frame/etool.py | 10 +++++- .../tools/benchmark/basic/commandline-sml.py | 31 +---------------- .../tools/benchmark/basic/insert-json-csv.py | 5 --- .../benchmark/basic/sml_taosjson_alltypes.py | 33 +------------------ .../army/tools/benchmark/cloud/cloud-test.py | 14 +------- .../tools/taosdump/native/taosdumpTest.py | 2 +- .../tools/taosdump/native/taosdumpTest2.py | 2 +- .../native/taosdumpTestNanoSupport.py | 2 +- .../taosdump/native/taosdumpTypeGeometry.py | 2 +- .../taosdump/native/taosdumpTypeVarbinary.py | 2 +- .../tools/taosdump/ws3/taosdumpPrimaryKey.py | 2 +- .../army/tools/taosdump/ws3/taosdumpRetry.py | 7 ++-- 12 files changed, 20 insertions(+), 92 deletions(-) diff --git a/tests/army/frame/etool.py b/tests/army/frame/etool.py index 67af4f93c9..9065a3dede 100644 --- a/tests/army/frame/etool.py +++ b/tests/army/frame/etool.py @@ -23,19 +23,27 @@ import frame.epath import frame.eos from frame.log import * +# taosdump def taosDumpFile(): bmFile = frame.epath.binFile("taosdump") if frame.eos.isWin(): bmFile += ".exe" return bmFile - +# taosBenchmark def benchMarkFile(): bmFile = frame.epath.binFile("taosBenchmark") if frame.eos.isWin(): bmFile += ".exe" return bmFile +# taosAdapter +def taosAdapterFile(): + bmFile = frame.epath.binFile("taosAdapter") + if frame.eos.isWin(): + bmFile += ".exe" + return bmFile + # run taosBenchmark with command or json file mode def benchMark(command = "", json = "") : # get taosBenchmark path diff --git a/tests/army/tools/benchmark/basic/commandline-sml.py b/tests/army/tools/benchmark/basic/commandline-sml.py index a24bb515a7..7c3dc39f7b 100644 --- a/tests/army/tools/benchmark/basic/commandline-sml.py +++ b/tests/army/tools/benchmark/basic/commandline-sml.py @@ -22,42 +22,13 @@ from frame.caseBase import * from frame import * -def etool.benchMarkFile() - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if "community" in selfPath: - projPath = selfPath[: selfPath.find("community")] - elif "src" in selfPath: - projPath = selfPath[: selfPath.find("src")] - elif "/tools/" in selfPath: - projPath = selfPath[: selfPath.find("/tools/")] - elif "/tests/" in selfPath: - projPath = selfPath[: selfPath.find("/tests/")] - else: - tdLog.info("cannot found %s in path: %s, use system's" % (tool, selfPath)) - projPath = "/usr/local/taos/bin/" - - paths = [] - for root, dummy, files in os.walk(projPath): - if (tool) in files: - rootRealPath = os.path.dirname(os.path.realpath(root)) - if "packaging" not in rootRealPath: - paths.append(os.path.join(root, tool)) - break - if len(paths) == 0: - return "" - return paths[0] - - class TDTestCase(TBase): def caseDescription(self): """ [TD-21932] taosBenchmark sml test cases """ - - def run(self): - binPath = getPath() + binPath = etool.benchMarkFile() cmd = "%s -I sml -t 1 -n 1 -y" % binPath tdLog.info("%s" % cmd) diff --git a/tests/army/tools/benchmark/basic/insert-json-csv.py b/tests/army/tools/benchmark/basic/insert-json-csv.py index bb89cc56c2..bd5d96398f 100644 --- a/tests/army/tools/benchmark/basic/insert-json-csv.py +++ b/tests/army/tools/benchmark/basic/insert-json-csv.py @@ -23,11 +23,6 @@ from frame import * class TDTestCase(TBase): - - now = time.time() - self.ts = int(round(now * 1000)) - - def run(self): tdSql.query("select client_version()") client_ver = "".join(tdSql.queryResult[0]) diff --git a/tests/army/tools/benchmark/basic/sml_taosjson_alltypes.py b/tests/army/tools/benchmark/basic/sml_taosjson_alltypes.py index f46c63a40f..376b4956d2 100644 --- a/tests/army/tools/benchmark/basic/sml_taosjson_alltypes.py +++ b/tests/army/tools/benchmark/basic/sml_taosjson_alltypes.py @@ -20,49 +20,18 @@ from frame.caseBase import * from frame import * -def etool.benchMarkFile() - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if "community" in selfPath: - projPath = selfPath[: selfPath.find("community")] - elif "src" in selfPath: - projPath = selfPath[: selfPath.find("src")] - elif "/tools/" in selfPath: - projPath = selfPath[: selfPath.find("/tools/")] - elif "/tests/" in selfPath: - projPath = selfPath[: selfPath.find("/tests/")] - else: - tdLog.info("cannot found %s in path: %s, use system's" % (tool, selfPath)) - projPath = "/usr/local/taos/bin/" - - paths = [] - for root, dummy, files in os.walk(projPath): - if (tool) in files: - rootRealPath = os.path.dirname(os.path.realpath(root)) - if "packaging" not in rootRealPath: - paths.append(os.path.join(root, tool)) - break - if len(paths) == 0: - tdLog.exit("taosBenchmark not found!") - return - else: - tdLog.info("taosBenchmark found in %s" % paths[0]) - return paths[0] - - class TDTestCase(TBase): def caseDescription(self): """ [TD-21932] taosBenchmark sml test cases """ - def run(self): tdSql.query("select client_version()") client_ver = "".join(tdSql.queryResult[0]) major_ver = client_ver.split(".")[0] - binPath = getPath() + binPath = etool.benchMarkFile() cmd = "%s -f ./tools/benchmark/basic/json/sml_taosjson_alltypes.json" % binPath tdLog.info("%s" % cmd) os.system("%s" % cmd) diff --git a/tests/army/tools/benchmark/cloud/cloud-test.py b/tests/army/tools/benchmark/cloud/cloud-test.py index 24acd5e788..f8d39ae6c1 100644 --- a/tests/army/tools/benchmark/cloud/cloud-test.py +++ b/tests/army/tools/benchmark/cloud/cloud-test.py @@ -32,19 +32,7 @@ class TDTestCase(TBase): cmd = "%s -T 1 -t 2 -n 10 -y" % binPath tdLog.info("%s" % cmd) os.system("%s" % cmd) - - ''' - taosPath = self.getPath("taos") - cmd = f"{taosPath} -s 'select count(*) from test.meters'" - tdLog.info(f"{cmd}") - cmdOutput = subprocess.check_output(cmd, shell=True).decode("utf-8") - tdLog.info(f"{cmdOutput}") - if "20 |" in cmdOutput: - tdLog.info("count of records is correct!") - else: - tdLog.exit("count of records is incorrect") - ''' - + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/army/tools/taosdump/native/taosdumpTest.py b/tests/army/tools/taosdump/native/taosdumpTest.py index ac214ed6d7..1fab1a6c58 100644 --- a/tests/army/tools/taosdump/native/taosdumpTest.py +++ b/tests/army/tools/taosdump/native/taosdumpTest.py @@ -71,7 +71,7 @@ class TDTestCase: sql += "(%d, %d, 'nchar%d')" % (currts + i, i % 100, i % 100) tdSql.execute(sql) - binPath = self.etool.taosDumpFile() + binPath = etool.taosDumpFile() if binPath == "": tdLog.exit("taosdump not found!") else: diff --git a/tests/army/tools/taosdump/native/taosdumpTest2.py b/tests/army/tools/taosdump/native/taosdumpTest2.py index 972f866aed..824d711e21 100644 --- a/tests/army/tools/taosdump/native/taosdumpTest2.py +++ b/tests/army/tools/taosdump/native/taosdumpTest2.py @@ -68,7 +68,7 @@ class TDTestCase: break tdSql.execute(sql) - binPath = self.etool.taosDumpFile() + binPath = etool.taosDumpFile() if binPath == "": tdLog.exit("taosdump not found!") else: diff --git a/tests/army/tools/taosdump/native/taosdumpTestNanoSupport.py b/tests/army/tools/taosdump/native/taosdumpTestNanoSupport.py index 4e3d723df9..e0c123e1fb 100644 --- a/tests/army/tools/taosdump/native/taosdumpTestNanoSupport.py +++ b/tests/army/tools/taosdump/native/taosdumpTestNanoSupport.py @@ -110,7 +110,7 @@ class TDTestCase: if not os.path.exists("./taosdumptest/dumptmp3"): os.makedirs("./taosdumptest/dumptmp3") - binPath = self.etool.taosDumpFile() + binPath = etool.taosDumpFile() if binPath == "": tdLog.exit("taosdump not found!") else: diff --git a/tests/army/tools/taosdump/native/taosdumpTypeGeometry.py b/tests/army/tools/taosdump/native/taosdumpTypeGeometry.py index 80c565d641..b59a913358 100644 --- a/tests/army/tools/taosdump/native/taosdumpTypeGeometry.py +++ b/tests/army/tools/taosdump/native/taosdumpTypeGeometry.py @@ -35,7 +35,7 @@ class TDTestCase: def findPrograme(self): # taosdump - taosdump = self.etool.taosDumpFile() + taosdump = etool.taosDumpFile() if taosdump == "": tdLog.exit("taosdump not found!") else: diff --git a/tests/army/tools/taosdump/native/taosdumpTypeVarbinary.py b/tests/army/tools/taosdump/native/taosdumpTypeVarbinary.py index 39c6582119..87a5be5c7b 100644 --- a/tests/army/tools/taosdump/native/taosdumpTypeVarbinary.py +++ b/tests/army/tools/taosdump/native/taosdumpTypeVarbinary.py @@ -38,7 +38,7 @@ class TDTestCase: def findPrograme(self): # taosdump - taosdump = self.etool.taosDumpFile() + taosdump = etool.taosDumpFile() if taosdump == "": tdLog.exit("taosdump not found!") else: diff --git a/tests/army/tools/taosdump/ws3/taosdumpPrimaryKey.py b/tests/army/tools/taosdump/ws3/taosdumpPrimaryKey.py index d821ecc94f..5a88b263b2 100644 --- a/tests/army/tools/taosdump/ws3/taosdumpPrimaryKey.py +++ b/tests/army/tools/taosdump/ws3/taosdumpPrimaryKey.py @@ -37,7 +37,7 @@ class TDTestCase: def findPrograme(self): # taosdump - taosdump = self.etool.taosDumpFile() + taosdump = etool.taosDumpFile() if taosdump == "": tdLog.exit("taosdump not found!") else: diff --git a/tests/army/tools/taosdump/ws3/taosdumpRetry.py b/tests/army/tools/taosdump/ws3/taosdumpRetry.py index 800189b1f0..191f41e214 100644 --- a/tests/army/tools/taosdump/ws3/taosdumpRetry.py +++ b/tests/army/tools/taosdump/ws3/taosdumpRetry.py @@ -53,16 +53,13 @@ class TDTestCase: case1: [TS-3072] taosdump dump escaped db name test """ - - - def exec(self, command): tdLog.info(command) return os.system(command) def findPrograme(self): # taosdump - taosdump = self.etool.taosDumpFile() + taosdump = etool.taosDumpFile() if taosdump == "": tdLog.exit("taosdump not found!") else: @@ -76,7 +73,7 @@ class TDTestCase: tdLog.info("benchmark found in %s" % benchmark) # taosadapter - taosadapter = self.getPath("taosadapter") + taosadapter = etool.taosAdapterFile() if taosadapter == "": tdLog.exit("taosadapter not found!") else: