Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
dc72a1a6
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
dc72a1a6
编写于
10月 21, 2020
作者:
S
Steven Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Split crash_gen tool into different functional files/modules
上级
e011827f
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
873 addition
and
807 deletion
+873
-807
tests/pytest/crash_gen/crash_gen.py
tests/pytest/crash_gen/crash_gen.py
+107
-807
tests/pytest/crash_gen/misc.py
tests/pytest/crash_gen/misc.py
+133
-0
tests/pytest/crash_gen/service_manager.py
tests/pytest/crash_gen/service_manager.py
+633
-0
未找到文件。
tests/pytest/crash_gen/crash_gen.py
浏览文件 @
dc72a1a6
此差异已折叠。
点击以展开。
tests/pytest/crash_gen/misc.py
0 → 100644
浏览文件 @
dc72a1a6
import
threading
import
random
import
logging
class
CrashGenError
(
Exception
):
def
__init__
(
self
,
msg
=
None
,
errno
=
None
):
self
.
msg
=
msg
self
.
errno
=
errno
def
__str__
(
self
):
return
self
.
msg
class
LoggingFilter
(
logging
.
Filter
):
def
filter
(
self
,
record
:
logging
.
LogRecord
):
if
(
record
.
levelno
>=
logging
.
INFO
):
return
True
# info or above always log
# Commenting out below to adjust...
# if msg.startswith("[TRD]"):
# return False
return
True
class
MyLoggingAdapter
(
logging
.
LoggerAdapter
):
def
process
(
self
,
msg
,
kwargs
):
return
"[{}]{}"
.
format
(
threading
.
get_ident
()
%
10000
,
msg
),
kwargs
# return '[%s] %s' % (self.extra['connid'], msg), kwargs
class
Logging
:
logger
=
None
@
classmethod
def
getLogger
(
cls
):
return
logger
@
classmethod
def
clsInit
(
cls
,
gConfig
):
# TODO: refactor away gConfig
if
cls
.
logger
:
return
# Logging Stuff
# global misc.logger
_logger
=
logging
.
getLogger
(
'CrashGen'
)
# real logger
_logger
.
addFilter
(
LoggingFilter
())
ch
=
logging
.
StreamHandler
()
_logger
.
addHandler
(
ch
)
# Logging adapter, to be used as a logger
print
(
"setting logger variable"
)
# global logger
cls
.
logger
=
MyLoggingAdapter
(
_logger
,
[])
if
(
gConfig
.
debug
):
cls
.
logger
.
setLevel
(
logging
.
DEBUG
)
# default seems to be INFO
else
:
cls
.
logger
.
setLevel
(
logging
.
INFO
)
@
classmethod
def
info
(
cls
,
msg
):
cls
.
logger
.
info
(
msg
)
@
classmethod
def
debug
(
cls
,
msg
):
cls
.
logger
.
debug
(
msg
)
@
classmethod
def
warning
(
cls
,
msg
):
cls
.
logger
.
warning
(
msg
)
class
Status
:
STATUS_STARTING
=
1
STATUS_RUNNING
=
2
STATUS_STOPPING
=
3
STATUS_STOPPED
=
4
# Deterministic random number generator
class
Dice
():
seeded
=
False
# static, uninitialized
@
classmethod
def
seed
(
cls
,
s
):
# static
if
(
cls
.
seeded
):
raise
RuntimeError
(
"Cannot seed the random generator more than once"
)
cls
.
verifyRNG
()
random
.
seed
(
s
)
cls
.
seeded
=
True
# TODO: protect against multi-threading
@
classmethod
def
verifyRNG
(
cls
):
# Verify that the RNG is determinstic
random
.
seed
(
0
)
x1
=
random
.
randrange
(
0
,
1000
)
x2
=
random
.
randrange
(
0
,
1000
)
x3
=
random
.
randrange
(
0
,
1000
)
if
(
x1
!=
864
or
x2
!=
394
or
x3
!=
776
):
raise
RuntimeError
(
"System RNG is not deterministic"
)
@
classmethod
def
throw
(
cls
,
stop
):
# get 0 to stop-1
return
cls
.
throwRange
(
0
,
stop
)
@
classmethod
def
throwRange
(
cls
,
start
,
stop
):
# up to stop-1
if
(
not
cls
.
seeded
):
raise
RuntimeError
(
"Cannot throw dice before seeding it"
)
return
random
.
randrange
(
start
,
stop
)
@
classmethod
def
choice
(
cls
,
cList
):
return
random
.
choice
(
cList
)
class
Helper
:
@
classmethod
def
convertErrno
(
cls
,
errno
):
return
errno
if
(
errno
>
0
)
else
0x80000000
+
errno
class
Progress
:
STEP_BOUNDARY
=
0
BEGIN_THREAD_STEP
=
1
END_THREAD_STEP
=
2
tokens
=
{
STEP_BOUNDARY
:
'.'
,
BEGIN_THREAD_STEP
:
'['
,
END_THREAD_STEP
:
'] '
}
@
classmethod
def
emit
(
cls
,
token
):
print
(
cls
.
tokens
[
token
],
end
=
""
,
flush
=
True
)
tests/pytest/crash_gen/service_manager.py
0 → 100644
浏览文件 @
dc72a1a6
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录