[TD-14331]<fix>: make util/dnodes.py flexible (#11022)

* [TD-14331]<fix>: make util/dnodes.py flexible

for 3.0

* make getPath clear
This commit is contained in:
Shuduo Sang 2022-03-26 22:49:42 +08:00 committed by GitHub
parent 7095e7c644
commit 66f31a0077
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 61 additions and 60 deletions

View File

@ -234,8 +234,7 @@ class TDDnode:
"dnode:%d is deployed and configured by %s" %
(self.index, self.cfgPath))
def getBuildPath(self):
buildPath = ""
def getPath(self, tool="taosd"):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
@ -243,23 +242,22 @@ class TDDnode:
else:
projPath = selfPath[:selfPath.find("tests")]
paths = []
for root, dirs, files in os.walk(projPath):
if (("taosd") in files):
if ((tool) in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root)-len("/build/bin")]
paths.append(os.path.join(root, tool))
break
return buildPath
return paths[0]
def start(self):
buildPath = self.getBuildPath()
binPath = self.getPath()
if (buildPath == ""):
if (binPath == ""):
tdLog.exit("taosd not found!")
else:
tdLog.info("taosd found in %s" % buildPath)
binPath = buildPath + "/build/bin/taosd"
tdLog.info("taosd found: %s" % binPath)
if self.deployed == 0:
tdLog.exit("dnode:%d is not deployed" % (self.index))
@ -290,7 +288,11 @@ class TDDnode:
i += 1
if i > 50:
break
popen = subprocess.Popen('tail -f ' + logFile, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
popen = subprocess.Popen(
'tail -f ' + logFile,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True)
pid = popen.pid
# print('Popen.pid:' + str(pid))
timeout = time.time() + 60 * 2
@ -303,21 +305,20 @@ class TDDnode:
tdLog.exit('wait too long for taosd start')
tdLog.debug("the dnode:%d has been started." % (self.index))
else:
tdLog.debug("wait 10 seconds for the dnode:%d to start." % (self.index))
tdLog.debug(
"wait 10 seconds for the dnode:%d to start." %
(self.index))
time.sleep(10)
# time.sleep(5)
def startWithoutSleep(self):
buildPath = self.getBuildPath()
binPath = self.getPath()
if (buildPath == ""):
if (binPath == ""):
tdLog.exit("taosd not found!")
else:
tdLog.info("taosd found in %s" % buildPath)
binPath = buildPath + "/build/bin/taosd"
tdLog.info("taosd found: %s" % binPath)
if self.deployed == 0:
tdLog.exit("dnode:%d is not deployed" % (self.index))