test:add concurrency test cases for executing the taos -k command line.
This commit is contained in:
parent
d59e3512ee
commit
dd5b547404
|
@ -16,6 +16,9 @@ from util.sql import *
|
||||||
from util.cases import *
|
from util.cases import *
|
||||||
from util.dnodes import *
|
from util.dnodes import *
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
import threading
|
||||||
|
|
||||||
def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key1='', value1=''):
|
def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key1='', value1=''):
|
||||||
if len(key) == 0:
|
if len(key) == 0:
|
||||||
tdLog.exit("taos test key is null!")
|
tdLog.exit("taos test key is null!")
|
||||||
|
@ -129,6 +132,34 @@ class TDTestCase:
|
||||||
buildPath = root[:len(root) - len("/build/bin")]
|
buildPath = root[:len(root) - len("/build/bin")]
|
||||||
break
|
break
|
||||||
return buildPath
|
return buildPath
|
||||||
|
def run_command(self, commands):
|
||||||
|
self.taos_output = []
|
||||||
|
count = 0
|
||||||
|
while count < 2:
|
||||||
|
print(f"count: {count}")
|
||||||
|
value = subprocess.getoutput(f"nohup {commands} &")
|
||||||
|
print(f"value: {value}")
|
||||||
|
self.taos_output.append(value)
|
||||||
|
count += 1
|
||||||
|
return self.taos_output
|
||||||
|
|
||||||
|
def taos_thread_repeat_k(self, run_command, commands, threads_num=10, output=[]):
|
||||||
|
threads = []
|
||||||
|
taos_output = self.taos_output
|
||||||
|
threads_num = 20
|
||||||
|
|
||||||
|
for id in range(threads_num):
|
||||||
|
#threads.append(Process(target=cloud_consumer, args=(id,)))
|
||||||
|
threads.append(threading.Thread(target=run_command, args=(commands,)))
|
||||||
|
for tr in threads:
|
||||||
|
tr.start()
|
||||||
|
for tr in threads:
|
||||||
|
tr.join()
|
||||||
|
|
||||||
|
for value in taos_output:
|
||||||
|
if "crash" in value:
|
||||||
|
print(f"command: {commands} crash")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
|
@ -445,6 +476,12 @@ class TDTestCase:
|
||||||
|
|
||||||
tdSql.query('drop database %s'%newDbName)
|
tdSql.query('drop database %s'%newDbName)
|
||||||
|
|
||||||
|
commands = f"taos -k -c {cfgPath}"
|
||||||
|
output = self.run_command(commands)
|
||||||
|
os.sys
|
||||||
|
self.taos_thread_repeat_k(self.run_command, commands, 10, output)
|
||||||
|
# os.system("python 0-others/repeat_taos_k.py")
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
tdLog.success(f"{__file__} successfully executed")
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
Loading…
Reference in New Issue