Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
0272620c
T
tp-qemu
项目概览
openeuler
/
tp-qemu
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
tp-qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0272620c
编写于
1月 12, 2017
作者:
Q
Qianqian Zhu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
block_copy: Add wait for and after job finished function.
Signed-off-by:
N
Qianqian Zhu
<
qizhu@redhat.com
>
上级
eeeadfb8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
72 addition
and
86 deletion
+72
-86
qemu/tests/blk_stream.py
qemu/tests/blk_stream.py
+0
-31
qemu/tests/block_copy.py
qemu/tests/block_copy.py
+71
-0
qemu/tests/drive_mirror.py
qemu/tests/drive_mirror.py
+1
-55
未找到文件。
qemu/tests/blk_stream.py
浏览文件 @
0272620c
...
...
@@ -61,39 +61,8 @@ class BlockStream(block_copy.BlockCopy):
raise
error
.
TestFail
(
"create snapshot '%s' fail"
%
snapshot
)
self
.
trash_files
.
append
(
snapshot
)
def
job_finished
(
self
):
"""
check if streaming job finished;
"""
if
self
.
get_status
():
return
False
if
self
.
vm
.
monitor
.
protocol
==
"qmp"
:
return
bool
(
self
.
vm
.
monitor
.
get_event
(
"BLOCK_JOB_COMPLETED"
))
return
True
def
wait_for_finished
(
self
):
"""
waiting until block stream job finished
"""
params
=
self
.
parser_test_args
()
timeout
=
params
.
get
(
"wait_timeout"
)
finished
=
utils_misc
.
wait_for
(
self
.
job_finished
,
timeout
=
timeout
)
if
not
finished
:
raise
error
.
TestFail
(
"Job not finished in %s seconds"
%
timeout
)
logging
.
info
(
"Block stream job done."
)
def
action_when_streaming
(
self
):
"""
run steps when job in steaming;
"""
return
self
.
do_steps
(
"when_streaming"
)
def
action_after_finished
(
self
):
"""
run steps after streaming done;
"""
params
=
self
.
parser_test_args
()
# if block job cancelled, no need to wait it;
if
params
[
"wait_finished"
]
==
"yes"
:
self
.
wait_for_finished
()
return
self
.
do_steps
(
"after_finished"
)
qemu/tests/block_copy.py
浏览文件 @
0272620c
...
...
@@ -300,6 +300,77 @@ class BlockCopy(object):
if
bg
.
isAlive
():
self
.
processes
.
append
(
bg
)
def
job_finished
(
self
):
"""
check if block job finished;
"""
if
self
.
get_status
():
return
False
if
self
.
vm
.
monitor
.
protocol
==
"qmp"
:
return
bool
(
self
.
vm
.
monitor
.
get_event
(
"BLOCK_JOB_COMPLETED"
))
return
True
def
wait_for_finished
(
self
):
"""
waiting until block job finished
"""
params
=
self
.
parser_test_args
()
timeout
=
params
.
get
(
"wait_timeout"
)
finished
=
utils_misc
.
wait_for
(
self
.
job_finished
,
timeout
=
timeout
)
if
not
finished
:
raise
error
.
TestFail
(
"Job not finished in %s seconds"
%
timeout
)
logging
.
info
(
"Block job done."
)
def
action_after_finished
(
self
):
"""
run steps after block job done;
"""
params
=
self
.
parser_test_args
()
# if block job cancelled, no need to wait it;
if
params
[
"wait_finished"
]
==
"yes"
:
self
.
wait_for_finished
()
return
self
.
do_steps
(
"after_finished"
)
def
is_steady
(
self
):
"""
check block job is steady status or not;
"""
params
=
self
.
parser_test_args
()
info
=
self
.
get_status
()
ret
=
bool
(
info
and
info
[
"len"
]
==
info
[
"offset"
])
if
self
.
vm
.
monitor
.
protocol
==
"qmp"
:
if
params
.
get
(
"check_event"
,
"no"
)
==
"yes"
:
ret
&=
bool
(
self
.
vm
.
monitor
.
get_event
(
"BLOCK_JOB_READY"
))
return
ret
def
wait_for_steady
(
self
):
"""
check block job status, utils timeout; if still not go
into steady status, raise TestFail exception;
"""
params
=
self
.
parser_test_args
()
timeout
=
params
.
get
(
"wait_timeout"
)
if
self
.
vm
.
monitor
.
protocol
==
"qmp"
:
self
.
vm
.
monitor
.
clear_event
(
"BLOCK_JOB_READY"
)
steady
=
utils_misc
.
wait_for
(
self
.
is_steady
,
first
=
3.0
,
step
=
3.0
,
timeout
=
timeout
)
if
not
steady
:
raise
error
.
TestFail
(
"Wait mirroring job ready "
"timeout in %ss"
%
timeout
)
def
action_before_steady
(
self
):
"""
run steps before job in steady status;
"""
return
self
.
do_steps
(
"before_steady"
)
def
action_when_steady
(
self
):
"""
run steps when job in steady status;
"""
self
.
wait_for_steady
()
return
self
.
do_steps
(
"when_steady"
)
def
action_before_cleanup
(
self
):
"""
run steps before job in steady status;
...
...
qemu/tests/drive_mirror.py
浏览文件 @
0272620c
...
...
@@ -134,65 +134,11 @@ class DriveMirror(block_copy.BlockCopy):
params
=
self
.
parser_test_args
()
target_format
=
params
[
"image_format"
]
timeout
=
params
[
"reopen_timeout"
]
def
is_opened
():
try
:
device
=
self
.
vm
.
get_block
({
"file"
:
self
.
target_image
})
ret
=
(
device
==
self
.
device
)
if
self
.
vm
.
monitor
.
protocol
==
"qmp"
:
ret
&=
bool
(
self
.
vm
.
monitor
.
get_event
(
"BLOCK_JOB_COMPLETED"
))
return
ret
except
Exception
:
return
False
error
.
context
(
"reopen new target image"
,
logging
.
info
)
if
self
.
vm
.
monitor
.
protocol
==
"qmp"
:
self
.
vm
.
monitor
.
clear_event
(
"BLOCK_JOB_COMPLETED"
)
self
.
vm
.
block_reopen
(
self
.
device
,
self
.
target_image
,
target_format
)
opened
=
utils_misc
.
wait_for
(
is_opened
,
first
=
3.0
,
timeout
=
timeout
)
if
not
opened
:
msg
=
"Target image not used,wait timeout in %ss"
%
timeout
raise
error
.
TestFail
(
msg
)
def
is_steady
(
self
):
"""
check block device mirroring job is steady status or not;
"""
params
=
self
.
parser_test_args
()
info
=
self
.
get_status
()
ret
=
bool
(
info
and
info
[
"len"
]
==
info
[
"offset"
])
if
self
.
vm
.
monitor
.
protocol
==
"qmp"
:
if
params
.
get
(
"check_event"
,
"no"
)
==
"yes"
:
ret
&=
bool
(
self
.
vm
.
monitor
.
get_event
(
"BLOCK_JOB_READY"
))
return
ret
def
wait_for_steady
(
self
):
"""
check block device mirroring status, utils timeout; if still not go
into steady status, raise TestFail exception;
"""
params
=
self
.
parser_test_args
()
timeout
=
params
.
get
(
"wait_timeout"
)
if
self
.
vm
.
monitor
.
protocol
==
"qmp"
:
self
.
vm
.
monitor
.
clear_event
(
"BLOCK_JOB_READY"
)
steady
=
utils_misc
.
wait_for
(
self
.
is_steady
,
first
=
3.0
,
step
=
3.0
,
timeout
=
timeout
)
if
not
steady
:
raise
error
.
TestFail
(
"Wait mirroring job ready "
"timeout in %ss"
%
timeout
)
def
action_before_steady
(
self
):
"""
run steps before job in steady status;
"""
return
self
.
do_steps
(
"before_steady"
)
def
action_when_steady
(
self
):
"""
run steps when job in steady status;
"""
self
.
wait_for_steady
()
return
self
.
do_steps
(
"when_steady"
)
self
.
wait_for_finished
()
def
action_after_reopen
(
self
):
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录