[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:
parent
7095e7c644
commit
66f31a0077
|
@ -234,8 +234,7 @@ class TDDnode:
|
||||||
"dnode:%d is deployed and configured by %s" %
|
"dnode:%d is deployed and configured by %s" %
|
||||||
(self.index, self.cfgPath))
|
(self.index, self.cfgPath))
|
||||||
|
|
||||||
def getBuildPath(self):
|
def getPath(self, tool="taosd"):
|
||||||
buildPath = ""
|
|
||||||
selfPath = os.path.dirname(os.path.realpath(__file__))
|
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
if ("community" in selfPath):
|
if ("community" in selfPath):
|
||||||
|
@ -243,23 +242,22 @@ class TDDnode:
|
||||||
else:
|
else:
|
||||||
projPath = selfPath[:selfPath.find("tests")]
|
projPath = selfPath[:selfPath.find("tests")]
|
||||||
|
|
||||||
|
paths = []
|
||||||
for root, dirs, files in os.walk(projPath):
|
for root, dirs, files in os.walk(projPath):
|
||||||
if (("taosd") in files):
|
if ((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):
|
||||||
buildPath = root[:len(root)-len("/build/bin")]
|
paths.append(os.path.join(root, tool))
|
||||||
break
|
break
|
||||||
return buildPath
|
return paths[0]
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
buildPath = self.getBuildPath()
|
binPath = self.getPath()
|
||||||
|
|
||||||
if (buildPath == ""):
|
if (binPath == ""):
|
||||||
tdLog.exit("taosd not found!")
|
tdLog.exit("taosd not found!")
|
||||||
else:
|
else:
|
||||||
tdLog.info("taosd found in %s" % buildPath)
|
tdLog.info("taosd found: %s" % binPath)
|
||||||
|
|
||||||
binPath = buildPath + "/build/bin/taosd"
|
|
||||||
|
|
||||||
if self.deployed == 0:
|
if self.deployed == 0:
|
||||||
tdLog.exit("dnode:%d is not deployed" % (self.index))
|
tdLog.exit("dnode:%d is not deployed" % (self.index))
|
||||||
|
@ -290,7 +288,11 @@ class TDDnode:
|
||||||
i += 1
|
i += 1
|
||||||
if i > 50:
|
if i > 50:
|
||||||
break
|
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
|
pid = popen.pid
|
||||||
# print('Popen.pid:' + str(pid))
|
# print('Popen.pid:' + str(pid))
|
||||||
timeout = time.time() + 60 * 2
|
timeout = time.time() + 60 * 2
|
||||||
|
@ -303,21 +305,20 @@ class TDDnode:
|
||||||
tdLog.exit('wait too long for taosd start')
|
tdLog.exit('wait too long for taosd start')
|
||||||
tdLog.debug("the dnode:%d has been started." % (self.index))
|
tdLog.debug("the dnode:%d has been started." % (self.index))
|
||||||
else:
|
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(10)
|
||||||
|
|
||||||
|
|
||||||
# time.sleep(5)
|
# time.sleep(5)
|
||||||
|
|
||||||
def startWithoutSleep(self):
|
def startWithoutSleep(self):
|
||||||
buildPath = self.getBuildPath()
|
binPath = self.getPath()
|
||||||
|
|
||||||
if (buildPath == ""):
|
if (binPath == ""):
|
||||||
tdLog.exit("taosd not found!")
|
tdLog.exit("taosd not found!")
|
||||||
else:
|
else:
|
||||||
tdLog.info("taosd found in %s" % buildPath)
|
tdLog.info("taosd found: %s" % binPath)
|
||||||
|
|
||||||
binPath = buildPath + "/build/bin/taosd"
|
|
||||||
|
|
||||||
if self.deployed == 0:
|
if self.deployed == 0:
|
||||||
tdLog.exit("dnode:%d is not deployed" % (self.index))
|
tdLog.exit("dnode:%d is not deployed" % (self.index))
|
||||||
|
|
Loading…
Reference in New Issue