From 2dcec8304a9f93746ed2370e724c238641a61429 Mon Sep 17 00:00:00 2001 From: chenhaoran Date: Tue, 23 Jan 2024 11:35:13 +0800 Subject: [PATCH] test:add special compatibility testcase for code coverage --- tests/pytest/util/common.py | 58 +++++++++---------- .../0-others/compatibility_coverage.py | 2 +- .../6-cluster/clusterCommonCreate.py | 3 + 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/tests/pytest/util/common.py b/tests/pytest/util/common.py index c4885747d1..cb649d966f 100644 --- a/tests/pytest/util/common.py +++ b/tests/pytest/util/common.py @@ -1862,38 +1862,38 @@ class TDCom: time.sleep(1) return tbname -def is_json(msg): - if isinstance(msg, str): - try: - json.loads(msg) - return True - except: + def is_json(msg): + if isinstance(msg, str): + try: + json.loads(msg) + return True + except: + return False + else: return False - else: - return False -def get_path(tool="taosd"): - selfPath = os.path.dirname(os.path.realpath(__file__)) - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] + def get_path(tool="taosd"): + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] - paths = [] - for root, dirs, files in os.walk(projPath): - if ((tool) in files or ("%s.exe"%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): + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files or ("%s.exe"%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] + + def dict2toml(in_dict: dict, file:str): + if not isinstance(in_dict, dict): return "" - return paths[0] - -def dict2toml(in_dict: dict, file:str): - if not isinstance(in_dict, dict): - return "" - with open(file, 'w') as f: - toml.dump(in_dict, f) + with open(file, 'w') as f: + toml.dump(in_dict, f) tdCom = TDCom() diff --git a/tests/system-test/0-others/compatibility_coverage.py b/tests/system-test/0-others/compatibility_coverage.py index 7a123739f7..6eccf78c5a 100644 --- a/tests/system-test/0-others/compatibility_coverage.py +++ b/tests/system-test/0-others/compatibility_coverage.py @@ -152,7 +152,7 @@ class TDTestCase: os.system(f"rm -rf {cPath}/../data") print(self.projPath) # this data file is special for coverage test in 192.168.1.96 - os.system("cp -r f{self.projPath}/../comp_testdata/data/ {self.projPath}/sim/dnode1") + os.system(f"cp -r {self.projPath}/../comp_testdata/data/ {self.projPath}/community/sim/dnode1") tdDnodes.stop(1) tdDnodes.start(1) diff --git a/tests/system-test/6-cluster/clusterCommonCreate.py b/tests/system-test/6-cluster/clusterCommonCreate.py index a06c1233d8..cb44710b58 100644 --- a/tests/system-test/6-cluster/clusterCommonCreate.py +++ b/tests/system-test/6-cluster/clusterCommonCreate.py @@ -215,7 +215,10 @@ class ClusterComCreate: return def alterStbMetaData(self,tsql,dbName,stbName,ctbNum,rowsPerTbl,batchNum,startTs=None): + tdLog.debug("alter Stb column ............") + tdLog.debug(f"describe STABLE {dbName}.{stbName} ") + tsql.execute(f"describe STABLE {dbName}.{stbName} ;") tdLog.debug(f"ALTER STABLE {dbName}.{stbName} MODIFY COLUMN c3 binary(20);") tsql.execute(f" ALTER STABLE {dbName}.{stbName} MODIFY COLUMN c3 binary(20);") tdLog.debug(f"ALTER STABLE {dbName}.{stbName} ADD COLUMN c4 DOUBLE;")