Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fd0c6ade
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
fd0c6ade
编写于
12月 02, 2020
作者:
H
huili
提交者:
GitHub
12月 02, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4407 from taosdata/feature/crash_gen
Refactored crash_gen tool
上级
acf5cc1c
982e6465
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
192 addition
and
108 deletion
+192
-108
tests/pytest/crash_gen/crash_gen_main.py
tests/pytest/crash_gen/crash_gen_main.py
+154
-87
tests/pytest/crash_gen/db.py
tests/pytest/crash_gen/db.py
+5
-4
tests/pytest/crash_gen/misc.py
tests/pytest/crash_gen/misc.py
+15
-7
tests/pytest/crash_gen/service_manager.py
tests/pytest/crash_gen/service_manager.py
+18
-10
未找到文件。
tests/pytest/crash_gen/crash_gen_main.py
浏览文件 @
fd0c6ade
此差异已折叠。
点击以展开。
tests/pytest/crash_gen/db.py
浏览文件 @
fd0c6ade
...
...
@@ -78,7 +78,7 @@ class DbConn:
if
nRows
!=
1
:
raise
taos
.
error
.
ProgrammingError
(
"Unexpected result for query: {}, rows = {}"
.
format
(
sql
,
nRows
),
(
0x991
if
nRows
==
0
else
0x992
)
(
CrashGenError
.
INVALID_EMPTY_RESULT
if
nRows
==
0
else
CrashGenError
.
INVALID_MULTIPLE_RESULT
)
)
if
self
.
getResultRows
()
!=
1
or
self
.
getResultCols
()
!=
1
:
raise
RuntimeError
(
"Unexpected result set for query: {}"
.
format
(
sql
))
...
...
@@ -349,7 +349,8 @@ class DbConnNative(DbConn):
def
execute
(
self
,
sql
):
if
(
not
self
.
isOpen
):
raise
RuntimeError
(
"Cannot execute database commands until connection is open"
)
raise
CrashGenError
(
"Cannot exec SQL unless db connection is open"
,
CrashGenError
.
DB_CONNECTION_NOT_OPEN
)
Logging
.
debug
(
"[SQL] Executing SQL: {}"
.
format
(
sql
))
self
.
_lastSql
=
sql
nRows
=
self
.
_tdSql
.
execute
(
sql
)
...
...
@@ -360,8 +361,8 @@ class DbConnNative(DbConn):
def
query
(
self
,
sql
):
# return rows affected
if
(
not
self
.
isOpen
):
raise
Runtime
Error
(
"Cannot query database until connection is open
"
)
raise
CrashGen
Error
(
"Cannot query database until connection is open
, restarting?"
,
CrashGenError
.
DB_CONNECTION_NOT_OPEN
)
Logging
.
debug
(
"[SQL] Executing SQL: {}"
.
format
(
sql
))
self
.
_lastSql
=
sql
nRows
=
self
.
_tdSql
.
query
(
sql
)
...
...
tests/pytest/crash_gen/misc.py
浏览文件 @
fd0c6ade
...
...
@@ -3,14 +3,20 @@ import random
import
logging
import
os
import
taos
class
CrashGenError
(
Exception
):
def
__init__
(
self
,
msg
=
None
,
errno
=
None
):
self
.
msg
=
msg
self
.
errno
=
errno
def
__str__
(
self
):
return
self
.
msg
class
CrashGenError
(
taos
.
error
.
ProgrammingError
):
INVALID_EMPTY_RESULT
=
0x991
INVALID_MULTIPLE_RESULT
=
0x992
DB_CONNECTION_NOT_OPEN
=
0x993
# def __init__(self, msg=None, errno=None):
# self.msg = msg
# self.errno = errno
# def __str__(self):
# return self.msg
pass
class
LoggingFilter
(
logging
.
Filter
):
...
...
@@ -168,6 +174,7 @@ class Progress:
SERVICE_RECONNECT_FAILURE
=
6
SERVICE_START_NAP
=
7
CREATE_TABLE_ATTEMPT
=
8
QUERY_GROUP_BY
=
9
tokens
=
{
STEP_BOUNDARY
:
'.'
,
...
...
@@ -178,7 +185,8 @@ class Progress:
SERVICE_RECONNECT_SUCCESS
:
'.r>'
,
SERVICE_RECONNECT_FAILURE
:
'.xr>'
,
SERVICE_START_NAP
:
'_zz'
,
CREATE_TABLE_ATTEMPT
:
'_c'
,
CREATE_TABLE_ATTEMPT
:
'c'
,
QUERY_GROUP_BY
:
'g'
,
}
@
classmethod
...
...
tests/pytest/crash_gen/service_manager.py
浏览文件 @
fd0c6ade
...
...
@@ -51,10 +51,12 @@ class TdeInstance():
def
prepareGcovEnv
(
cls
,
env
):
# Ref: https://gcc.gnu.org/onlinedocs/gcc/Cross-profiling.html
bPath
=
cls
.
_getBuildPath
()
# build PATH
numSegments
=
len
(
bPath
.
split
(
'/'
))
-
1
# "/x/TDengine/build" should yield 3
numSegments
=
numSegments
-
1
# DEBUG only
env
[
'GCOV_PREFIX'
]
=
bPath
+
'/svc_gcov'
numSegments
=
len
(
bPath
.
split
(
'/'
))
# "/x/TDengine/build" should yield 3
# numSegments += 2 # cover "/src" after build
# numSegments = numSegments - 1 # DEBUG only
env
[
'GCOV_PREFIX'
]
=
bPath
+
'/src_s'
# Server side source
env
[
'GCOV_PREFIX_STRIP'
]
=
str
(
numSegments
)
# Strip every element, plus, ENV needs strings
# VERY VERY important note: GCOV data collection NOT effective upon SIG_KILL
Logging
.
info
(
"Preparing GCOV environement to strip {} elements and use path: {}"
.
format
(
numSegments
,
env
[
'GCOV_PREFIX'
]
))
...
...
@@ -258,14 +260,15 @@ class TdeSubProcess:
TdeInstance
.
prepareGcovEnv
(
myEnv
)
# print(myEnv)
# print(myEnv.items())
# print(
"Starting TDengine with env: ",
myEnv.items())
# print("Starting TDengine via Shell: {}".format(cmdLineStr))
useShell
=
True
self
.
subProcess
=
subprocess
.
Popen
(
' '
.
join
(
cmdLine
)
if
useShell
else
cmdLine
,
shell
=
useShell
,
# svcCmdSingle, shell=True, # capture core dump?
# ' '.join(cmdLine) if useShell else cmdLine,
# shell=useShell,
' '
.
join
(
cmdLine
),
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
# bufsize=1, # not supported in binary mode
...
...
@@ -273,7 +276,8 @@ class TdeSubProcess:
env
=
myEnv
)
# had text=True, which interferred with reading EOF
STOP_SIGNAL
=
signal
.
SIGKILL
# What signal to use (in kill) to stop a taosd process?
STOP_SIGNAL
=
signal
.
SIGKILL
# signal.SIGKILL/SIGINT # What signal to use (in kill) to stop a taosd process?
SIG_KILL_RETCODE
=
137
# ref: https://stackoverflow.com/questions/43268156/process-finished-with-exit-code-137-in-pycharm
def
stop
(
self
):
"""
...
...
@@ -320,8 +324,12 @@ class TdeSubProcess:
retCode
=
self
.
subProcess
.
returncode
# should always be there
# May throw subprocess.TimeoutExpired exception above, therefore
# The process is guranteed to have ended by now
self
.
subProcess
=
None
if
retCode
!=
0
:
# != (- signal.SIGINT):
self
.
subProcess
=
None
if
retCode
==
self
.
SIG_KILL_RETCODE
:
Logging
.
info
(
"TSP.stop(): sub proc KILLED, as expected"
)
elif
retCode
==
(
-
self
.
STOP_SIGNAL
):
Logging
.
info
(
"TSP.stop(), sub process STOPPED, as expected"
)
elif
retCode
!=
0
:
# != (- signal.SIGINT):
Logging
.
error
(
"TSP.stop(): Failed to stop sub proc properly w/ SIG {}, retCode={}"
.
format
(
self
.
STOP_SIGNAL
,
retCode
))
else
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录