Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test:modify method of stopall function #22778

Merged
merged 3 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
71 changes: 37 additions & 34 deletions tests/pytest/util/dnodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ def __init__(self):
self.testCluster = False
self.valgrind = 0
self.asan = False
self.killValgrind = 1
self.killValgrind = 0

def init(self, path, remoteIP = ""):
binPath = self.dnodes[0].getPath() + "/../../../"
Expand Down Expand Up @@ -775,9 +775,41 @@ def StopAllSigint(self):
tdLog.info("execute finished")
return

def killProcesser(self, processerName):
if platform.system().lower() == 'windows':
killCmd = ("wmic process where name=\"%s.exe\" call terminate > NUL 2>&1" % processerName)
psCmd = ("wmic process where name=\"%s.exe\" | findstr \"%s.exe\"" % (processerName, processerName))
else:
killCmd = (
"ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1"
% processerName
)
psCmd = ("ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % processerName)

processID = ""

try:
processID = subprocess.check_output(psCmd, shell=True)
while processID:
os.system(killCmd)
time.sleep(1)
try:
processID = subprocess.check_output(psCmd, shell=True)
except Exception as err:
processID = ""
tdLog.debug('**** kill pid warn: {err}')
except Exception as err:
processID = ""
tdLog.debug(f'**** find pid warn: {err}')



def stopAll(self):
tdLog.info("stop all dnodes, asan:%d" % self.asan)
distro_id = distro.id()
if platform.system().lower() != 'windows':
distro_id = distro.id()
else:
distro_id = "not alpine"
if self.asan and distro_id != "alpine":
tdLog.info("execute script: %s" % self.stopDnodesPath)
os.system(self.stopDnodesPath)
Expand All @@ -792,7 +824,6 @@ def stopAll(self):


if (distro_id == "alpine"):
print(distro_id)
psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep| grep -v defunct | awk '{print $2}' | xargs"
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip()
while(processID):
Expand All @@ -803,36 +834,9 @@ def stopAll(self):
processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8").strip()
elif platform.system().lower() == 'windows':
psCmd = "for /f %a in ('wmic process where \"name='taosd.exe'\" get processId ^| xargs echo ^| awk '{print $2}' ^&^& echo aa') do @(ps | grep %a | awk '{print $1}' | xargs)"
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip()
while(processID):
print(f"pid of taosd.exe:{processID}")
killCmd = "kill -9 %s > nul 2>&1" % processID
os.system(killCmd)
time.sleep(1)
processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8").strip()

psCmd = "for /f %a in ('wmic process where \"name='tmq_sim.exe'\" get processId ^| xargs echo ^| awk '{print $2}' ^&^& echo aa') do @(ps | grep %a | awk '{print $1}' | xargs)"
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip()
while(processID):
print(f"pid of tmq_sim.exe:{processID}")
killCmd = "kill -9 %s > nul 2>&1" % processID
os.system(killCmd)
time.sleep(1)
processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8").strip()

psCmd = "for /f %a in ('wmic process where \"name='taosBenchmark.exe'\" get processId ^| xargs echo ^| awk '{print $2}' ^&^& echo aa') do @(ps | grep %a | awk '{print $1}' | xargs)"
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip()
while(processID):
print(f"pid of taosBenchmark.exe:{processID}")
killCmd = "kill -9 %s > nul 2>&1" % processID
os.system(killCmd)
time.sleep(1)
processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8").strip()

self.killProcesser("taosd")
self.killProcesser("tmq_sim")
self.killProcesser("taosBenchmark")
else:
psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep| grep -v defunct | awk '{print $2}' | xargs"
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip()
Expand All @@ -849,7 +853,6 @@ def stopAll(self):
time.sleep(1)
processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8").strip()

if self.killValgrind == 1:
psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}' | xargs"
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip()
Expand Down
2 changes: 1 addition & 1 deletion tests/system-test/0-others/splitVGroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def checkExpect(self, sql, expectVal):

# init
def init(self, conn, logSql, replicaVar=1):
seed = time.clock_gettime(time.CLOCK_REALTIME)
seed = time.time() % 10000
random.seed(seed)
self.replicaVar = int(replicaVar)
tdLog.debug(f"start to excute {__file__}")
Expand Down
2 changes: 1 addition & 1 deletion tests/system-test/0-others/timeRangeWise.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def checkExpect(self, sql, expectVal):

# init
def init(self, conn, logSql, replicaVar=1):
seed = time.clock_gettime(time.CLOCK_REALTIME)
seed = time.time() % 10000
random.seed(seed)
self.replicaVar = int(replicaVar)
tdLog.debug(f"start to excute {__file__}")
Expand Down
2 changes: 1 addition & 1 deletion tests/system-test/1-insert/precisionUS.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def checkTimeMacro(self):

# init
def init(self, conn, logSql, replicaVar=1):
seed = time.clock_gettime(time.CLOCK_REALTIME)
seed = time.time() % 10000
random.seed(seed)
self.replicaVar = int(replicaVar)
tdLog.debug(f"start to excute {__file__}")
Expand Down
2 changes: 1 addition & 1 deletion tests/system-test/2-query/orderBy.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def queryResultSame(self, sql1, sql2):

# init
def init(self, conn, logSql, replicaVar=1):
seed = time.clock_gettime(time.CLOCK_REALTIME)
seed = time.time() % 10000
random.seed(seed)
self.replicaVar = int(replicaVar)
tdLog.debug(f"start to excute {__file__}")
Expand Down
2 changes: 1 addition & 1 deletion tests/system-test/2-query/smaBasic.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def checkPerformance(self):

# init
def init(self, conn, logSql, replicaVar=1):
seed = time.clock_gettime(time.CLOCK_REALTIME)
seed = time.time() % 10000
random.seed(seed)
self.replicaVar = int(replicaVar)
tdLog.debug(f"start to excute {__file__}")
Expand Down
10 changes: 5 additions & 5 deletions tests/system-test/6-cluster/5dnode3mnodeStop2Follower.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ def fiveDnodeThreeMnode(self,dnodenumbers,mnodeNums,restartNumber):
# restart all taosd
tdDnodes=cluster.dnodes

tdDnodes[1].stoptaosd()
# tdDnodes[1].stoptaosd()
tdDnodes[2].stoptaosd()

tdLog.info("check whether 2 mnode status is offline")
clusterComCheck.check3mnode2off()
tdLog.info("check whether 1 mnode status is offline")
clusterComCheck.check3mnodeoff(3)
# tdSql.error("create user user1 pass '123';")

tdLog.info("start two follower")
tdDnodes[1].starttaosd()
tdLog.info("start follower")
# tdDnodes[1].starttaosd()
tdDnodes[2].starttaosd()

clusterComCheck.checkMnodeStatus(mnodeNums)
Expand Down
2 changes: 1 addition & 1 deletion tests/system-test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def runOnPreviousCluster(host, config, fileName):
sys.exit(0)

if key in ['-k', '--killValgrind']:
killValgrind = 0
killValgrind = 1

if key in ['-e', '--execCmd']:
try:
Expand Down