test:add special compatibility testcase for code coverage

This commit is contained in:
chenhaoran 2024-01-23 11:35:13 +08:00
parent 897d3f5dba
commit 2dcec8304a
3 changed files with 33 additions and 30 deletions

View File

@ -1862,38 +1862,38 @@ class TDCom:
time.sleep(1) time.sleep(1)
return tbname return tbname
def is_json(msg): def is_json(msg):
if isinstance(msg, str): if isinstance(msg, str):
try: try:
json.loads(msg) json.loads(msg)
return True return True
except: except:
return False
else:
return False return False
else:
return False
def get_path(tool="taosd"): def get_path(tool="taosd"):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath): if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")] projPath = selfPath[:selfPath.find("community")]
else: else:
projPath = selfPath[:selfPath.find("tests")] projPath = selfPath[:selfPath.find("tests")]
paths = [] paths = []
for root, dirs, files in os.walk(projPath): for root, dirs, files in os.walk(projPath):
if ((tool) in files or ("%s.exe"%tool) in files): if ((tool) in files or ("%s.exe"%tool) in files):
rootRealPath = os.path.dirname(os.path.realpath(root)) rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath): if ("packaging" not in rootRealPath):
paths.append(os.path.join(root, tool)) paths.append(os.path.join(root, tool))
break break
if (len(paths) == 0): if (len(paths) == 0):
return ""
return paths[0]
def dict2toml(in_dict: dict, file:str):
if not isinstance(in_dict, dict):
return "" return ""
return paths[0] with open(file, 'w') as f:
toml.dump(in_dict, f)
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)
tdCom = TDCom() tdCom = TDCom()

View File

@ -152,7 +152,7 @@ class TDTestCase:
os.system(f"rm -rf {cPath}/../data") os.system(f"rm -rf {cPath}/../data")
print(self.projPath) print(self.projPath)
# this data file is special for coverage test in 192.168.1.96 # 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.stop(1)
tdDnodes.start(1) tdDnodes.start(1)

View File

@ -215,7 +215,10 @@ class ClusterComCreate:
return return
def alterStbMetaData(self,tsql,dbName,stbName,ctbNum,rowsPerTbl,batchNum,startTs=None): def alterStbMetaData(self,tsql,dbName,stbName,ctbNum,rowsPerTbl,batchNum,startTs=None):
tdLog.debug("alter Stb column ............") 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);") tdLog.debug(f"ALTER STABLE {dbName}.{stbName} MODIFY COLUMN c3 binary(20);")
tsql.execute(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;") tdLog.debug(f"ALTER STABLE {dbName}.{stbName} ADD COLUMN c4 DOUBLE;")