fix: replace getPath() function

This commit is contained in:
Alex Duan 2024-12-24 14:57:46 +08:00
parent 5cb8a5de3c
commit f4e00a2483
12 changed files with 20 additions and 92 deletions

View File

@ -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

View File

@ -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)

View File

@ -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])

View File

@ -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)

View File

@ -33,18 +33,6 @@ class TDTestCase(TBase):
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__)

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -53,16 +53,13 @@ class TDTestCase:
case1<sdsang>: [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: