From aff92b763c4a8b5b003af9e051b5fd00be6f7b89 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Tue, 25 Feb 2025 14:02:38 +0800 Subject: [PATCH] fix: support error return to vlist --- tests/army/frame/eos.py | 10 +++-- tests/army/frame/etool.py | 4 +- .../taosdump/native/taosdumpCommandline.py | 40 +++++++++---------- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/tests/army/frame/eos.py b/tests/army/frame/eos.py index 9e502c3e59..2d07fc5ffe 100644 --- a/tests/army/frame/eos.py +++ b/tests/army/frame/eos.py @@ -89,12 +89,16 @@ def run(command, show = True): # return list after run -def runRetList(command, show = True, checkRun = False): +def runRetList(command, show = True, checkRun = False, retFail = False): output, error, code = run(command, show) if checkRun and code != 0: print(f"eos.runRetList checkRun return code failed. code={code} error={error}") - assert code == 0 - return output.splitlines() + + assert code == 0 + rList = output.splitlines() + if retFail and error != "": + rList += error.splitlines() + return rList # # file diff --git a/tests/army/frame/etool.py b/tests/army/frame/etool.py index 164e5e127d..4ad3efb036 100644 --- a/tests/army/frame/etool.py +++ b/tests/army/frame/etool.py @@ -66,7 +66,7 @@ def curFile(fullPath, filename): # run build/bin file -def runBinFile(fname, command, show = True, checkRun = False): +def runBinFile(fname, command, show = True, checkRun = False, retFail = False ): binFile = frame.epath.binFile(fname) if frame.eos.isWin(): binFile += ".exe" @@ -74,7 +74,7 @@ def runBinFile(fname, command, show = True, checkRun = False): cmd = f"{binFile} {command}" if show: tdLog.info(cmd) - return frame.eos.runRetList(cmd, show, checkRun) + return frame.eos.runRetList(cmd, show, checkRun, retFail) # exe build/bin file def exeBinFile(fname, command, wait=True, show=True): diff --git a/tests/army/tools/taosdump/native/taosdumpCommandline.py b/tests/army/tools/taosdump/native/taosdumpCommandline.py index 837b48ff18..21562c15e0 100644 --- a/tests/army/tools/taosdump/native/taosdumpCommandline.py +++ b/tests/army/tools/taosdump/native/taosdumpCommandline.py @@ -157,21 +157,21 @@ class TDTestCase(TBase): def basicCommandLine(self, tmpdir): #command and check result checkItems = [ - f"-h 127.0.0.1 -P 6030 -uroot -ptaosdata -A -N -o {tmpdir}", ["OK: Database test dumped", "OK: 200 row(s) dumped out!"], - f"-r result -gg -a -e test d0 -o {tmpdir}", ["OK: table: d0 dumped", "OK: 100 row(s) dumped out!"], - f"-n -D test -o {tmpdir}", ["OK: Database test dumped", "OK: 200 row(s) dumped out!"], - f"-L -D test -o {tmpdir}", ["OK: Database test dumped", "OK: 200 row(s) dumped out!"], - f"-s -D test -o {tmpdir}", ["dumping out schema: 1 from meters.d0", "OK: Database test dumped", "OK: 0 row(s) dumped out!"], - f"-N -d deflate -S '2022-10-01 00:00:50.000' test meters -o {tmpdir}",["OK: table: meters dumped", "OK: 100 row(s) dumped out!"], - f"-N -d lzma -S '2022-10-01 00:00:50.000' test meters -o {tmpdir}",["OK: table: meters dumped", "OK: 100 row(s) dumped out!"], - f"-N -d snappy -S '2022-10-01 00:00:50.000' test meters -o {tmpdir}",["OK: table: meters dumped", "OK: 100 row(s) dumped out!"], - f" -S '2022-10-01 00:00:50.000' -E '2022-10-01 00:00:60.000' test meters -o {tmpdir}",["OK: table: meters dumped", "OK: 100 row(s) dumped out!"], - f"-T 2 -B 1000 -S '2022-10-01 00:00:50.000' -E '2022-10-01 00:00:60.000' test meters -o {tmpdir}", ["OK: table: meters dumped", "OK: 22 row(s) dumped out!"], - f"-g -E '2022-10-01 00:00:60.000' test -o {tmpdir}", ["OK: Database test dumped", "OK: 122 row(s) dumped out!"], - f"--help", ["Report bugs to"], - f"-?", ["Report bugs to"], - f"-V", ["version:"], - f"--usage", ["taosdump [OPTION...] -o outpath"] + [f"-h 127.0.0.1 -P 6030 -uroot -ptaosdata -A -N -o {tmpdir}", ["OK: Database test dumped", "OK: 200 row(s) dumped out!"]], + [f"-r result -gg -a -e test d0 -o {tmpdir}", ["OK: table: d0 dumped", "OK: 100 row(s) dumped out!"]], + [f"-n -D test -o {tmpdir}", ["OK: Database test dumped", "OK: 200 row(s) dumped out!"]], + [f"-L -D test -o {tmpdir}", ["OK: Database test dumped", "OK: 200 row(s) dumped out!"]], + [f"-s -D test -o {tmpdir}", ["dumping out schema: 1 from meters.d0", "OK: Database test dumped", "OK: 0 row(s) dumped out!"]], + [f"-N -d deflate -S '2022-10-01 00:00:50.000' test meters -o {tmpdir}",["OK: table: meters dumped", "OK: 100 row(s) dumped out!"]], + [f"-N -d lzma -S '2022-10-01 00:00:50.000' test meters -o {tmpdir}",["OK: table: meters dumped", "OK: 100 row(s) dumped out!"]], + [f"-N -d snappy -S '2022-10-01 00:00:50.000' test meters -o {tmpdir}",["OK: table: meters dumped", "OK: 100 row(s) dumped out!"]], + [f" -S '2022-10-01 00:00:50.000' -E '2022-10-01 00:00:60.000' test meters -o {tmpdir}",["OK: table: meters dumped", "OK: 100 row(s) dumped out!"]], + [f"-T 2 -B 1000 -S '2022-10-01 00:00:50.000' -E '2022-10-01 00:00:60.000' test meters -o {tmpdir}", ["OK: table: meters dumped", "OK: 22 row(s) dumped out!"]], + [f"-g -E '2022-10-01 00:00:60.000' test -o {tmpdir}", ["OK: Database test dumped", "OK: 122 row(s) dumped out!"]], + [f"--help", ["Report bugs to"]], + [f"-?", ["Report bugs to"]], + [f"-V", ["version:"]], + [f"--usage", ["taosdump [OPTION...] -o outpath"]] ] # executes @@ -180,7 +180,7 @@ class TDTestCase(TBase): results = item[1] rlist = self.taosdump(command) for result in results: - self.checkListString(result) + self.checkListString(rlist, result) # clear tmp self.clearPath(tmpdir) @@ -197,7 +197,7 @@ class TDTestCase(TBase): # except commandline - def exceptCommandLine(self, taosdump, tmpdir): + def exceptCommandLine(self, taosdump, db, stb, tmpdir): # -o self.checkExcept(taosdump + " -o= ") self.checkExcept(taosdump + " -o") @@ -220,14 +220,14 @@ class TDTestCase(TBase): json = "./tools/taosdump/native/json/insertFullType.json" # insert data with taosBenchmark - db, stb, child_count, insert_rows = self.insertData(benchmark, json) + db, stb, child_count, insert_rows = self.insertData(json) newdb = "new" + db # basic commandline - self.basicCommandLine(db, stb, tmpdir) + self.basicCommandLine(tmpdir) # except commandline - self.exceptCommandLine(db, stb, tmpdir) + self.exceptCommandLine(taosdump, db, stb, tmpdir) # dump out #self.dumpOut(taosdump, db, tmpdir)