Skip to content

Commit

Permalink
Merge pull request #22462 from taosdata/fix/TD-25735-3.0
Browse files Browse the repository at this point in the history
fix: tmq drop/common python script on windows
  • Loading branch information
dapan1121 committed Aug 17, 2023
2 parents f8f8e7a + cf4da46 commit 9cbbbc6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
40 changes: 31 additions & 9 deletions tests/system-test/7-tmq/tmqCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,18 +578,40 @@ def waitSubscriptionExit(self, tsql, topicName):
tdLog.info("wait subscriptions exit for %d s"%wait_cnt)

def killProcesser(self, processerName):
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 = subprocess.check_output(psCmd, shell=True)

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)
except Exception as err:
processID = ""
print('**** warn: ', err)

while processID:
os.system(killCmd)
time.sleep(1)
processID = subprocess.check_output(psCmd, shell=True)
try:
processID = subprocess.check_output(psCmd, shell=True)
except Exception as err:
processID = ""
print('**** warn: ', err)

def startProcess(self, processName, param):
if platform.system().lower() == 'windows':
cmd = f"mintty -h never %s %s > NUL 2>&1" % (processName, param)
else:
cmd = f"nohup %s %s > /dev/null 2>&1 &" % (processName, param)
tdLog.info("%s"%(cmd))
os.system(cmd)

def close(self):
self.cursor.close()
Expand Down
4 changes: 1 addition & 3 deletions tests/system-test/7-tmq/tmqDropConsumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ def tmqCase1(self):

# use taosBenchmark to subscribe
binPath = self.getPath()
cmd = "nohup %s -f ./7-tmq/tmqDropConsumer.json > /dev/null 2>&1 & " % binPath
tdLog.info("%s"%(cmd))
os.system(cmd)
tmqCom.startProcess(binPath, "-f ./7-tmq/tmqDropConsumer.json")

expectTopicNum = len(topicNameList)
consumerThreadNum = 2
Expand Down
4 changes: 1 addition & 3 deletions tests/system-test/7-tmq/tmqMaxGroupIds.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ def tmqCase1(self):

# use taosBenchmark to subscribe
binPath = self.getPath()
cmd = "nohup %s -f ./7-tmq/tmqMaxGroupIds.json > /dev/null 2>&1 & " % binPath
tdLog.info("%s"%(cmd))
os.system(cmd)
tmqCom.startProcess(binPath, "-f ./7-tmq/tmqMaxGroupIds.json")

expectTopicNum = 1
expectConsumerNUm = 99
Expand Down

0 comments on commit 9cbbbc6

Please sign in to comment.