From 34878b4f0d2a52c0de50e5fe00a17c17676b43ec Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sat, 13 Jan 2024 15:10:48 +0800 Subject: [PATCH] tweak run and exe method --- tests/army/community/cluster/snapshot.py | 2 +- tests/army/community/cmdline/fullopt.py | 20 +++++++++++-------- .../enterprise/multi-level/mlevel_basic.py | 2 +- tests/army/enterprise/s3/s3_basic.py | 2 +- tests/army/frame/eos.py | 8 ++++---- tests/army/frame/etool.py | 12 +++++++++-- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/tests/army/community/cluster/snapshot.py b/tests/army/community/cluster/snapshot.py index b177ba3b29..92ecc00726 100644 --- a/tests/army/community/cluster/snapshot.py +++ b/tests/army/community/cluster/snapshot.py @@ -34,7 +34,7 @@ class TDTestCase(TBase): tdLog.info(f"insert data.") # taosBenchmark run jfile = etool.curFile(__file__, "snapshot.json") - etool.runBenchmark(json=jfile) + etool.benchMark(json=jfile) tdSql.execute(f"use {self.db}") # set insert data information diff --git a/tests/army/community/cmdline/fullopt.py b/tests/army/community/cmdline/fullopt.py index e0a0a51bfc..29711c7e0a 100644 --- a/tests/army/community/cmdline/fullopt.py +++ b/tests/army/community/cmdline/fullopt.py @@ -36,8 +36,11 @@ class TDTestCase(TBase): self.timestamp_step = 1000 # taosBenchmark run - etool.runBenchmark(command = f"-d {self.db} -t {self.childtable_count} -n {self.insert_rows} -v 2 -y") - + etool.benchMark(command = f"-d {self.db} -t {self.childtable_count} -n {self.insert_rows} -v 2 -y") + + def doTaos(self): + tdLog.info(f"check taos command options...") + def doTaosd(self): tdLog.info(f"check taosd command options...") @@ -72,11 +75,11 @@ class TDTestCase(TBase): etool.runBinFile("taosd", f"-dm -c {cfg}") sc.dnodeStop(idx) etool.runBinFile("taosd", "-a http://192.168.1.10") - etool.runBinFile("taosd", f"-E abc -c {cfg}") - etool.runBinFile("taosd", f"-e abc -c {cfg}") - def doTaos(self): - tdLog.info(f"check taos command options...") + #exe + etool.exeBinFile("taosd", f"-E abc -c {cfg}") + sc.dnodeStop(idx) + etool.exeBinFile("taosd", f"-e def -c {cfg}") # run @@ -86,11 +89,12 @@ class TDTestCase(TBase): # insert data self.insertData() + # do taos + self.doTaos() + # do action self.doTaosd() - # do taos - self.doTaos() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/army/enterprise/multi-level/mlevel_basic.py b/tests/army/enterprise/multi-level/mlevel_basic.py index 3bec2bfb72..081a1bb9bd 100644 --- a/tests/army/enterprise/multi-level/mlevel_basic.py +++ b/tests/army/enterprise/multi-level/mlevel_basic.py @@ -32,7 +32,7 @@ class TDTestCase(TBase): tdLog.info(f"insert data.") # taosBenchmark run json = etool.curFile(__file__, "mlevel_basic.json") - etool.runBenchmark(json=json) + etool.benchMark(json=json) tdSql.execute(f"use {self.db}") # set insert data information diff --git a/tests/army/enterprise/s3/s3_basic.py b/tests/army/enterprise/s3/s3_basic.py index 8e7c1f2d35..f22d482502 100644 --- a/tests/army/enterprise/s3/s3_basic.py +++ b/tests/army/enterprise/s3/s3_basic.py @@ -54,7 +54,7 @@ class TDTestCase(TBase): tdLog.info(f"insert data.") # taosBenchmark run json = etool.curFile(__file__, "s3_basic.json") - etool.runBenchmark(json=json) + etool.benchMark(json=json) tdSql.execute(f"use {self.db}") # set insert data information diff --git a/tests/army/frame/eos.py b/tests/army/frame/eos.py index d0b37d1d10..defbaf4975 100644 --- a/tests/army/frame/eos.py +++ b/tests/army/frame/eos.py @@ -61,9 +61,9 @@ def exeNoWait(file): # run return output and error -def run(command): +def run(command, timeout = 10): process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - process.wait(3) + process.wait(timeout) output = process.stdout.read().decode(encoding="gbk") error = process.stderr.read().decode(encoding="gbk") @@ -72,8 +72,8 @@ def run(command): # return list after run -def runRetList(command): - output,error = run(command) +def runRetList(command, timeout=10): + output,error = run(command, timeout) return output.splitlines() diff --git a/tests/army/frame/etool.py b/tests/army/frame/etool.py index d0c51ca39e..6ab827d028 100644 --- a/tests/army/frame/etool.py +++ b/tests/army/frame/etool.py @@ -24,7 +24,7 @@ import frame.eos from frame.log import * # run taosBenchmark with command or json file mode -def runBenchmark(command = "", json = "") : +def benchMark(command = "", json = "") : # get taosBenchmark path bmFile = frame.epath.binFile("taosBenchmark") if frame.eos.isWin(): @@ -52,4 +52,12 @@ def runBinFile(fname, command): if frame.eos.isWin(): binFile += ".exe" - frame.eos.runRetList(f"{binFile} {command}") \ No newline at end of file + frame.eos.runRetList(f"{binFile} {command}") + +# exe build/bin file +def exeBinFile(fname, command): + binFile = frame.epath.binFile(fname) + if frame.eos.isWin(): + binFile += ".exe" + + frame.eos.exe(f"{binFile} {command}") \ No newline at end of file