Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
7603fd2b
M
milvus
项目概览
milvus
/
milvus
9 个月 前同步成功
通知
260
Star
22476
Fork
2472
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
7603fd2b
编写于
7月 25, 2023
作者:
Z
zhuwenxing
提交者:
GitHub
7月 25, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[test]Use pytest assume to assert (#25890)
Signed-off-by:
N
zhuwenxing
<
wenxing.zhu@zilliz.com
>
上级
fc6f7f98
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
17 deletion
+30
-17
tests/python_client/chaos/chaos_commons.py
tests/python_client/chaos/chaos_commons.py
+28
-16
tests/python_client/chaos/testcases/test_single_request_operation_for_rolling_update.py
...cases/test_single_request_operation_for_rolling_update.py
+2
-1
未找到文件。
tests/python_client/chaos/chaos_commons.py
浏览文件 @
7603fd2b
...
@@ -6,15 +6,17 @@ from chaos import constants
...
@@ -6,15 +6,17 @@ from chaos import constants
from
yaml
import
full_load
from
yaml
import
full_load
from
utils.util_log
import
test_log
as
log
from
utils.util_log
import
test_log
as
log
from
delayed_assert
import
expect
from
delayed_assert
import
expect
import
pytest
def
check_config
(
chaos_config
):
def
check_config
(
chaos_config
):
if
not
chaos_config
.
get
(
'kind'
,
None
):
if
not
chaos_config
.
get
(
"kind"
,
None
):
raise
Exception
(
"kind must be specified"
)
raise
Exception
(
"kind must be specified"
)
if
not
chaos_config
.
get
(
'spec'
,
None
):
if
not
chaos_config
.
get
(
"spec"
,
None
):
raise
Exception
(
"spec must be specified"
)
raise
Exception
(
"spec must be specified"
)
if
"action"
not
in
chaos_config
.
get
(
'spec'
,
None
):
if
"action"
not
in
chaos_config
.
get
(
"spec"
,
None
):
raise
Exception
(
"action must be specified in spec"
)
raise
Exception
(
"action must be specified in spec"
)
if
"selector"
not
in
chaos_config
.
get
(
'spec'
,
None
):
if
"selector"
not
in
chaos_config
.
get
(
"spec"
,
None
):
raise
Exception
(
"selector must be specified in spec"
)
raise
Exception
(
"selector must be specified in spec"
)
return
True
return
True
...
@@ -42,7 +44,7 @@ def start_monitor_threads(checkers={}):
...
@@ -42,7 +44,7 @@ def start_monitor_threads(checkers={}):
def
get_env_variable_by_name
(
name
):
def
get_env_variable_by_name
(
name
):
"""
get env variable by name"""
"""get env variable by name"""
try
:
try
:
env_var
=
os
.
environ
[
name
]
env_var
=
os
.
environ
[
name
]
log
.
debug
(
f
"env_variable:
{
env_var
}
"
)
log
.
debug
(
f
"env_variable:
{
env_var
}
"
)
...
@@ -58,7 +60,7 @@ def get_chaos_yamls():
...
@@ -58,7 +60,7 @@ def get_chaos_yamls():
if
chaos_env
is
not
None
:
if
chaos_env
is
not
None
:
if
os
.
path
.
isdir
(
chaos_env
):
if
os
.
path
.
isdir
(
chaos_env
):
log
.
debug
(
f
"chaos_env is a dir:
{
chaos_env
}
"
)
log
.
debug
(
f
"chaos_env is a dir:
{
chaos_env
}
"
)
return
glob
.
glob
(
chaos_env
+
'chaos_*.yaml'
)
return
glob
.
glob
(
chaos_env
+
"chaos_*.yaml"
)
elif
os
.
path
.
isfile
(
chaos_env
):
elif
os
.
path
.
isfile
(
chaos_env
):
log
.
debug
(
f
"chaos_env is a file:
{
chaos_env
}
"
)
log
.
debug
(
f
"chaos_env is a file:
{
chaos_env
}
"
)
return
[
chaos_env
]
return
[
chaos_env
]
...
@@ -69,12 +71,12 @@ def get_chaos_yamls():
...
@@ -69,12 +71,12 @@ def get_chaos_yamls():
return
glob
.
glob
(
constants
.
TESTS_CONFIG_LOCATION
+
constants
.
ALL_CHAOS_YAMLS
)
return
glob
.
glob
(
constants
.
TESTS_CONFIG_LOCATION
+
constants
.
ALL_CHAOS_YAMLS
)
def
reconnect
(
connections
,
alias
=
'default'
,
timeout
=
360
):
def
reconnect
(
connections
,
alias
=
"default"
,
timeout
=
360
):
"""trying to connect by connection alias"""
"""trying to connect by connection alias"""
is_connected
=
False
is_connected
=
False
start
=
time
.
time
()
start
=
time
.
time
()
end
=
time
.
time
()
end
=
time
.
time
()
while
not
is_connected
or
end
-
start
<
timeout
:
while
not
is_connected
or
end
-
start
<
timeout
:
try
:
try
:
connections
.
connect
(
alias
)
connections
.
connect
(
alias
)
is_connected
=
True
is_connected
=
True
...
@@ -87,17 +89,27 @@ def reconnect(connections, alias='default', timeout=360):
...
@@ -87,17 +89,27 @@ def reconnect(connections, alias='default', timeout=360):
return
connections
.
connect
(
alias
)
return
connections
.
connect
(
alias
)
def
assert_statistic
(
checkers
,
expectations
=
{},
succ_rate_threshold
=
0.95
,
fail_rate_threshold
=
0.49
):
def
assert_statistic
(
checkers
,
expectations
=
{},
succ_rate_threshold
=
0.95
,
fail_rate_threshold
=
0.49
):
for
k
in
checkers
.
keys
():
for
k
in
checkers
.
keys
():
# expect succ if no expectations
# expect succ if no expectations
succ_rate
=
checkers
[
k
].
succ_rate
()
succ_rate
=
checkers
[
k
].
succ_rate
()
total
=
checkers
[
k
].
total
()
total
=
checkers
[
k
].
total
()
average_time
=
checkers
[
k
].
average_time
average_time
=
checkers
[
k
].
average_time
if
expectations
.
get
(
k
,
''
)
==
constants
.
FAIL
:
if
expectations
.
get
(
k
,
""
)
==
constants
.
FAIL
:
log
.
info
(
f
"Expect Fail:
{
str
(
k
)
}
succ rate
{
succ_rate
}
, total:
{
total
}
, average time:
{
average_time
:.
4
f
}
"
)
log
.
info
(
expect
(
succ_rate
<
fail_rate_threshold
or
total
<
2
,
f
"Expect Fail:
{
str
(
k
)
}
succ rate
{
succ_rate
}
, total:
{
total
}
, average time:
{
average_time
:.
4
f
}
"
f
"Expect Fail:
{
str
(
k
)
}
succ rate
{
succ_rate
}
, total:
{
total
}
, average time:
{
average_time
:.
4
f
}
"
)
)
pytest
.
assume
(
succ_rate
<
fail_rate_threshold
or
total
<
2
,
f
"Expect Fail:
{
str
(
k
)
}
succ rate
{
succ_rate
}
, total:
{
total
}
, average time:
{
average_time
:.
4
f
}
"
,
)
else
:
else
:
log
.
info
(
f
"Expect Succ:
{
str
(
k
)
}
succ rate
{
succ_rate
}
, total:
{
total
}
, average time:
{
average_time
:.
4
f
}
"
)
log
.
info
(
expect
(
succ_rate
>
succ_rate_threshold
and
total
>
2
,
f
"Expect Succ:
{
str
(
k
)
}
succ rate
{
succ_rate
}
, total:
{
total
}
, average time:
{
average_time
:.
4
f
}
"
f
"Expect Succ:
{
str
(
k
)
}
succ rate
{
succ_rate
}
, total:
{
total
}
, average time:
{
average_time
:.
4
f
}
"
)
)
\ No newline at end of file
pytest
.
assume
(
succ_rate
>
succ_rate_threshold
and
total
>
2
,
f
"Expect Succ:
{
str
(
k
)
}
succ rate
{
succ_rate
}
, total:
{
total
}
, average time:
{
average_time
:.
4
f
}
"
,
)
tests/python_client/chaos/testcases/test_single_request_operation_for_rolling_update.py
浏览文件 @
7603fd2b
...
@@ -84,6 +84,7 @@ class TestOperations(TestBase):
...
@@ -84,6 +84,7 @@ class TestOperations(TestBase):
v
.
pause
()
v
.
pause
()
for
k
,
v
in
self
.
health_checkers
.
items
():
for
k
,
v
in
self
.
health_checkers
.
items
():
v
.
check_result
()
v
.
check_result
()
for
k
,
v
in
self
.
health_checkers
.
items
():
log
.
info
(
f
"
{
k
}
rto:
{
v
.
get_rto
()
}
"
)
log
.
info
(
f
"
{
k
}
rto:
{
v
.
get_rto
()
}
"
)
if
is_check
:
if
is_check
:
assert_statistic
(
self
.
health_checkers
,
succ_rate_threshold
=
0.98
)
assert_statistic
(
self
.
health_checkers
,
succ_rate_threshold
=
0.98
)
...
@@ -92,7 +93,7 @@ class TestOperations(TestBase):
...
@@ -92,7 +93,7 @@ class TestOperations(TestBase):
for
k
,
v
in
self
.
health_checkers
.
items
():
for
k
,
v
in
self
.
health_checkers
.
items
():
log
.
info
(
f
"
{
k
}
rto:
{
v
.
get_rto
()
}
"
)
log
.
info
(
f
"
{
k
}
rto:
{
v
.
get_rto
()
}
"
)
rto
=
v
.
get_rto
()
rto
=
v
.
get_rto
()
assert
rto
<
30
,
f
"expect 30s but get
{
rto
}
s"
# rto should be less than 30s
pytest
.
assume
(
rto
<
30
,
f
"
{
k
}
rto expect 30s but get
{
rto
}
s"
)
# rto should be less than 30s
if
Op
.
insert
in
self
.
health_checkers
:
if
Op
.
insert
in
self
.
health_checkers
:
# verify the no insert data loss
# verify the no insert data loss
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录