test: format code and add dead-lock return code to crash_gen
This commit is contained in:
parent
2c94844005
commit
1ba0b39582
|
@ -6,15 +6,12 @@ import requests
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os ,sys
|
import os ,sys
|
||||||
import random
|
import random
|
||||||
import argparse
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
|
||||||
import platform
|
|
||||||
|
|
||||||
# valgrind mode ?
|
# valgrind mode ?
|
||||||
valgrind_mode = False
|
valgrind_mode = False
|
||||||
|
|
||||||
msg_dict = {0:"success" , 1:"failed" , 2:"other errors" , 3:"crash occured" , 4:"Invalid read/write" , 5:"memory leak" }
|
msg_dict = {0: "success", 1: "failed", 2: "other errors", 3: "crash occured", 4: "Invalid read/write", 5: "memory leak", 6: "dead locked"}
|
||||||
|
|
||||||
# formal
|
# formal
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
|
@ -276,11 +273,15 @@ def check_status():
|
||||||
os.system("tail -n 50 %s>>%s"%(result_file,exit_status_logs))
|
os.system("tail -n 50 %s>>%s"%(result_file,exit_status_logs))
|
||||||
|
|
||||||
core_check = subprocess.Popen('ls -l %s | grep "^-" | wc -l'%core_path, shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")
|
core_check = subprocess.Popen('ls -l %s | grep "^-" | wc -l'%core_path, shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")
|
||||||
|
dead_lock_check = subprocess.Popen("grep -i 'dead locked' %s "%result_file, shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")
|
||||||
|
|
||||||
if int(core_check.strip().rstrip()) > 0:
|
if int(core_check.strip().rstrip()) > 0:
|
||||||
# it means core files has occured
|
# it means core files has occured
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
|
if dead_lock_check:
|
||||||
|
return 6
|
||||||
|
|
||||||
if "Crash_Gen is now exiting with status code: 1" in run_code:
|
if "Crash_Gen is now exiting with status code: 1" in run_code:
|
||||||
return 1
|
return 1
|
||||||
elif "Crash_Gen is now exiting with status code: 0" in run_code:
|
elif "Crash_Gen is now exiting with status code: 0" in run_code:
|
||||||
|
|
|
@ -9,15 +9,12 @@ import requests
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os ,sys
|
import os ,sys
|
||||||
import random
|
import random
|
||||||
import argparse
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
|
||||||
import platform
|
|
||||||
|
|
||||||
# valgrind mode ?
|
# valgrind mode ?
|
||||||
valgrind_mode = True
|
valgrind_mode = True
|
||||||
|
|
||||||
msg_dict = {0:"success" , 1:"failed" , 2:"other errors" , 3:"crash occured" , 4:"Invalid read/write" , 5:"memory leak" }
|
msg_dict = {0: "success", 1: "failed", 2: "other errors", 3: "crash occured", 4: "Invalid read/write", 5: "memory leak", 6: "dead locked"}
|
||||||
|
|
||||||
# formal
|
# formal
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
|
@ -48,6 +45,7 @@ def send_msg(json):
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
req = requests.post(url=group_url, headers=headers, json=json)
|
req = requests.post(url=group_url, headers=headers, json=json)
|
||||||
inf = req.json()
|
inf = req.json()
|
||||||
if "StatusCode" in inf and inf["StatusCode"] == 0:
|
if "StatusCode" in inf and inf["StatusCode"] == 0:
|
||||||
|
@ -228,7 +226,6 @@ def get_auto_mix_cmds(args_list ,valgrind=valgrind_mode):
|
||||||
|
|
||||||
return crash_gen_cmd
|
return crash_gen_cmd
|
||||||
|
|
||||||
|
|
||||||
def start_taosd():
|
def start_taosd():
|
||||||
build_path = get_path()
|
build_path = get_path()
|
||||||
if repo == "community":
|
if repo == "community":
|
||||||
|
@ -301,6 +298,7 @@ def check_memory():
|
||||||
os.mkdir(back_path)
|
os.mkdir(back_path)
|
||||||
|
|
||||||
stderr_file = os.path.join(crash_gen_path , "valgrind.err")
|
stderr_file = os.path.join(crash_gen_path , "valgrind.err")
|
||||||
|
stdout_file = os.path.join(crash_gen_path, 'valgrind.out')
|
||||||
|
|
||||||
status = 0
|
status = 0
|
||||||
|
|
||||||
|
@ -319,8 +317,10 @@ def check_memory():
|
||||||
grep_res = subprocess.Popen("grep -i 'taosMemoryMalloc' %s "%stderr_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")
|
grep_res = subprocess.Popen("grep -i 'taosMemoryMalloc' %s "%stderr_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")
|
||||||
|
|
||||||
if grep_res:
|
if grep_res:
|
||||||
|
# mem-leak can be also occure when exit normally when dead lock
|
||||||
# os.system("cp %s %s"%(stderr_file , back_path))
|
# os.system("cp %s %s"%(stderr_file , back_path))
|
||||||
status = 5
|
dead_lock_res = subprocess.Popen("grep -i 'dead locked' %s "%stdout_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")
|
||||||
|
status = 6 if dead_lock_res else 5
|
||||||
|
|
||||||
return status
|
return status
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,17 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import os ,sys
|
import os ,sys
|
||||||
import random
|
import random
|
||||||
import argparse
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
|
||||||
import platform
|
|
||||||
|
|
||||||
# valgrind mode ?
|
# valgrind mode ?
|
||||||
valgrind_mode = True
|
valgrind_mode = True
|
||||||
|
|
||||||
msg_dict = {0:"success" , 1:"failed" , 2:"other errors" , 3:"crash occured" , 4:"Invalid read/write" , 5:"memory leak" }
|
msg_dict = {0: "success", 1: "failed", 2: "other errors", 3: "crash occured", 4: "Invalid read/write", 5: "memory leak", 6: "dead locked"}
|
||||||
|
|
||||||
# formal
|
# formal
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
|
@ -131,7 +125,6 @@ def random_args(args_list):
|
||||||
args_list["--num-threads"]=random.sample(threads,1)[0] #$ debug
|
args_list["--num-threads"]=random.sample(threads,1)[0] #$ debug
|
||||||
# args_list["--ignore-errors"]=[] ## can add error codes for detail
|
# args_list["--ignore-errors"]=[] ## can add error codes for detail
|
||||||
|
|
||||||
|
|
||||||
args_list["--run-tdengine"]= False
|
args_list["--run-tdengine"]= False
|
||||||
args_list["--use-shadow-db"]= False
|
args_list["--use-shadow-db"]= False
|
||||||
args_list["--dynamic-db-table-names"]= True
|
args_list["--dynamic-db-table-names"]= True
|
||||||
|
@ -190,7 +183,6 @@ def limits(args_list):
|
||||||
|
|
||||||
# else:
|
# else:
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
return args_list
|
return args_list
|
||||||
|
|
||||||
def get_auto_mix_cmds(args_list ,valgrind=valgrind_mode):
|
def get_auto_mix_cmds(args_list ,valgrind=valgrind_mode):
|
||||||
|
@ -219,16 +211,11 @@ def get_auto_mix_cmds(args_list ,valgrind=valgrind_mode):
|
||||||
arguments+=(k+"="+str(v)+" ")
|
arguments+=(k+"="+str(v)+" ")
|
||||||
|
|
||||||
if valgrind :
|
if valgrind :
|
||||||
|
|
||||||
crash_gen_cmd = 'cd %s && ./crash_gen.sh --valgrind -i 3 %s -g 0x32c,0x32d,0x3d3,0x18,0x2501,0x369,0x388,0x061a,0x2550,0x0707,0x0203,0x4012 '%(crash_gen_path ,arguments)
|
crash_gen_cmd = 'cd %s && ./crash_gen.sh --valgrind -i 3 %s -g 0x32c,0x32d,0x3d3,0x18,0x2501,0x369,0x388,0x061a,0x2550,0x0707,0x0203,0x4012 '%(crash_gen_path ,arguments)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
crash_gen_cmd = 'cd %s && ./crash_gen.sh -i 3 %s -g 0x32c,0x32d,0x3d3,0x18,0x2501,0x369,0x388,0x061a,0x2550,0x0014,0x0707,0x0203,0x4012'%(crash_gen_path ,arguments)
|
crash_gen_cmd = 'cd %s && ./crash_gen.sh -i 3 %s -g 0x32c,0x32d,0x3d3,0x18,0x2501,0x369,0x388,0x061a,0x2550,0x0014,0x0707,0x0203,0x4012'%(crash_gen_path ,arguments)
|
||||||
|
|
||||||
return crash_gen_cmd
|
return crash_gen_cmd
|
||||||
|
|
||||||
|
|
||||||
def start_taosd():
|
def start_taosd():
|
||||||
build_path = get_path()
|
build_path = get_path()
|
||||||
if repo == "community":
|
if repo == "community":
|
||||||
|
@ -283,7 +270,6 @@ def check_status():
|
||||||
else:
|
else:
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
|
|
||||||
def check_memory():
|
def check_memory():
|
||||||
|
|
||||||
build_path = get_path()
|
build_path = get_path()
|
||||||
|
@ -301,7 +287,7 @@ def check_memory():
|
||||||
os.mkdir(back_path)
|
os.mkdir(back_path)
|
||||||
|
|
||||||
stderr_file = os.path.join(crash_gen_path , "valgrind.err")
|
stderr_file = os.path.join(crash_gen_path , "valgrind.err")
|
||||||
|
stdout_file = os.path.join(crash_gen_path, 'valgrind.out')
|
||||||
status = 0
|
status = 0
|
||||||
|
|
||||||
grep_res = subprocess.Popen("grep -i 'Invalid read' %s "%stderr_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")
|
grep_res = subprocess.Popen("grep -i 'Invalid read' %s "%stderr_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")
|
||||||
|
@ -319,13 +305,14 @@ def check_memory():
|
||||||
grep_res = subprocess.Popen("grep -i 'taosMemoryMalloc' %s "%stderr_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")
|
grep_res = subprocess.Popen("grep -i 'taosMemoryMalloc' %s "%stderr_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")
|
||||||
|
|
||||||
if grep_res:
|
if grep_res:
|
||||||
|
# mem-leak can be also occure when exit normally when dead lock
|
||||||
# os.system("cp %s %s"%(stderr_file , back_path))
|
# os.system("cp %s %s"%(stderr_file , back_path))
|
||||||
status = 5
|
dead_lock_res = subprocess.Popen("grep -i 'dead locked' %s "%stdout_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")
|
||||||
|
status = 6 if dead_lock_res else 5
|
||||||
|
|
||||||
return status
|
return status
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
args_list = {"--auto-start-service":False ,"--max-dbs":0,"--connector-type":"native","--debug":False,"--run-tdengine":False,"--ignore-errors":[],
|
args_list = {"--auto-start-service":False ,"--max-dbs":0,"--connector-type":"native","--debug":False,"--run-tdengine":False,"--ignore-errors":[],
|
||||||
"--track-memory-leaks":False , "--larger-data":False, "--mix-oos-data":False, "--dynamic-db-table-names":False,
|
"--track-memory-leaks":False , "--larger-data":False, "--mix-oos-data":False, "--dynamic-db-table-names":False,
|
||||||
"--per-thread-db-connection":False , "--record-ops":False , "--max-steps":100, "--num-threads":10, "--verify-data":False,"--use-shadow-db":False ,
|
"--per-thread-db-connection":False , "--record-ops":False , "--max-steps":100, "--num-threads":10, "--verify-data":False,"--use-shadow-db":False ,
|
||||||
|
@ -405,7 +392,6 @@ def main():
|
||||||
print("exception:", e)
|
print("exception:", e)
|
||||||
exit(status)
|
exit(status)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue