Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
cf5d845a
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,发现更多精彩内容 >>
提交
cf5d845a
编写于
7月 20, 2017
作者:
Q
Qianqian Zhu
提交者:
qizhu
3月 29, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
block_stream: Add test cases for stress, integrety and hot-unplug
Signed-off-by:
N
Qianqian Zhu
<
qizhu@redhat.com
>
上级
d8542f13
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
152 addition
and
28 deletion
+152
-28
qemu/tests/block_copy.py
qemu/tests/block_copy.py
+69
-28
qemu/tests/block_stream_installation.py
qemu/tests/block_stream_installation.py
+36
-0
qemu/tests/block_stream_simple.py
qemu/tests/block_stream_simple.py
+1
-0
qemu/tests/cfg/block_stream.cfg
qemu/tests/cfg/block_stream.cfg
+46
-0
未找到文件。
qemu/tests/block_copy.py
浏览文件 @
cf5d845a
...
...
@@ -44,6 +44,8 @@ class BlockCopy(object):
self
.
test
=
test
self
.
params
=
params
self
.
vm
=
self
.
get_vm
()
if
self
.
vm
.
monitor
.
protocol
!=
"qmp"
:
self
.
test
.
cancel
(
"hmp is not supported in this test."
)
self
.
data_dir
=
data_dir
.
get_data_dir
()
self
.
device
=
self
.
get_device
()
self
.
image_file
=
self
.
get_image_file
()
...
...
@@ -67,7 +69,8 @@ class BlockCopy(object):
return live vm object;
"""
vm
=
self
.
env
.
get_vm
(
self
.
params
[
"main_vm"
])
vm
.
verify_alive
()
if
self
.
params
.
get
(
"start_vm"
,
"yes"
)
==
"yes"
:
vm
.
verify_alive
()
return
vm
def
get_device
(
self
):
...
...
@@ -121,22 +124,19 @@ class BlockCopy(object):
"""
def
is_cancelled
():
ret
=
not
bool
(
self
.
get_status
())
if
self
.
vm
.
monitor
.
protocol
==
"qmp"
:
ret
&=
bool
(
self
.
vm
.
monitor
.
get_event
(
"BLOCK_JOB_CANCELLED"
))
ret
&=
bool
(
self
.
vm
.
monitor
.
get_event
(
"BLOCK_JOB_CANCELLED"
))
return
ret
error
.
context
(
"cancel block copy job"
,
logging
.
info
)
params
=
self
.
parser_test_args
()
timeout
=
params
.
get
(
"cancel_timeout"
)
if
self
.
vm
.
monitor
.
protocol
==
"qmp"
:
self
.
vm
.
monitor
.
clear_event
(
"BLOCK_JOB_CANCELLED"
)
self
.
vm
.
monitor
.
clear_event
(
"BLOCK_JOB_CANCELLED"
)
self
.
vm
.
cancel_block_job
(
self
.
device
)
cancelled
=
utils_misc
.
wait_for
(
is_cancelled
,
timeout
=
timeout
)
if
not
cancelled
:
msg
=
"Cancel block job timeout in %ss"
%
timeout
raise
error
.
TestFail
(
msg
)
if
self
.
vm
.
monitor
.
protocol
==
"qmp"
:
self
.
vm
.
monitor
.
clear_event
(
"BLOCK_JOB_CANCELLED"
)
self
.
vm
.
monitor
.
clear_event
(
"BLOCK_JOB_CANCELLED"
)
def
is_paused
(
self
):
"""
...
...
@@ -213,19 +213,16 @@ class BlockCopy(object):
session
=
self
.
get_session
()
return
self
.
vm
.
reboot
(
session
=
session
,
timeout
=
timeout
,
method
=
method
)
if
self
.
vm
.
monitor
.
protocol
==
"qmp"
:
error
.
context
(
"reset guest via system_reset"
,
logging
.
info
)
self
.
vm
.
monitor
.
clear_event
(
"RESET"
)
self
.
vm
.
monitor
.
cmd
(
"system_reset"
)
reseted
=
utils_misc
.
wait_for
(
lambda
:
self
.
vm
.
monitor
.
get_event
(
"RESET"
),
timeout
=
timeout
)
if
not
reseted
:
raise
error
.
TestFail
(
"No RESET event received after"
"execute system_reset %ss"
%
timeout
)
self
.
vm
.
monitor
.
clear_event
(
"RESET"
)
else
:
self
.
vm
.
monitor
.
cmd
(
"system_reset"
)
error
.
context
(
"reset guest via system_reset"
,
logging
.
info
)
self
.
vm
.
monitor
.
clear_event
(
"RESET"
)
self
.
vm
.
monitor
.
cmd
(
"system_reset"
)
reseted
=
utils_misc
.
wait_for
(
lambda
:
self
.
vm
.
monitor
.
get_event
(
"RESET"
),
timeout
=
timeout
)
if
not
reseted
:
raise
error
.
TestFail
(
"No RESET event received after"
"execute system_reset %ss"
%
timeout
)
self
.
vm
.
monitor
.
clear_event
(
"RESET"
)
return
None
@
error
.
context_aware
...
...
@@ -328,9 +325,7 @@ class BlockCopy(object):
"""
if
self
.
get_status
():
return
False
if
self
.
vm
.
monitor
.
protocol
==
"qmp"
:
return
bool
(
self
.
vm
.
monitor
.
get_event
(
"BLOCK_JOB_COMPLETED"
))
return
True
return
bool
(
self
.
vm
.
monitor
.
get_event
(
"BLOCK_JOB_COMPLETED"
))
def
wait_for_finished
(
self
):
"""
...
...
@@ -363,9 +358,8 @@ class BlockCopy(object):
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"
))
if
params
.
get
(
"check_event"
,
"no"
)
==
"yes"
:
ret
&=
bool
(
self
.
vm
.
monitor
.
get_event
(
"BLOCK_JOB_READY"
))
return
ret
def
wait_for_steady
(
self
):
...
...
@@ -375,8 +369,7 @@ class BlockCopy(object):
"""
params
=
self
.
parser_test_args
()
timeout
=
params
.
get
(
"wait_timeout"
)
if
self
.
vm
.
monitor
.
protocol
==
"qmp"
:
self
.
vm
.
monitor
.
clear_event
(
"BLOCK_JOB_READY"
)
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
:
...
...
@@ -426,6 +419,7 @@ class BlockCopy(object):
params
=
self
.
params
session
=
self
.
get_session
()
file_create_cmd
=
params
.
get
(
"create_command"
,
"touch FILE"
)
file_create_cmd
=
utils_misc
.
set_winutils_letter
(
session
,
file_create_cmd
)
test_exists_cmd
=
params
.
get
(
"test_exists_cmd"
,
"test -f FILE"
)
if
session
.
cmd_status
(
test_exists_cmd
.
replace
(
"FILE"
,
file_name
)):
session
.
cmd
(
file_create_cmd
.
replace
(
"FILE"
,
file_name
),
timeout
=
200
)
...
...
@@ -456,3 +450,50 @@ class BlockCopy(object):
self
.
params
[
"image_name_%s"
%
self
.
tag
]
=
reopen_image
self
.
vm
.
create
(
params
=
self
.
params
)
self
.
vm
.
verify_alive
()
def
hot_unplug
(
self
):
"""
Host unplug the source image, check if device deleted and block job cancelled
or completed, both results is acceptable per different qemu version.
"""
job_cancelled_events
=
[
"BLOCK_JOB_CANCELLED"
,
"BLOCK_JOB_COMPLETED"
]
device_delete_event
=
[
"DEVICE_DELETED"
]
for
event
in
job_cancelled_events
+
device_delete_event
:
self
.
vm
.
monitor
.
clear_event
(
event
)
def
is_unplugged
():
event_list
=
self
.
vm
.
monitor
.
get_events
()
logging
.
debug
(
"event_list: %s"
%
event_list
)
device_deleted
=
job_cancelled
=
False
for
event_str
in
event_list
:
event
=
event_str
.
get
(
"event"
)
if
event
in
device_delete_event
:
device_deleted
=
True
if
event
in
job_cancelled_events
:
job_cancelled
=
True
return
device_deleted
and
job_cancelled
qdev
=
self
.
vm
.
devices
device
=
qdev
.
get_by_params
({
"drive"
:
self
.
device
})
if
not
device
:
self
.
test
.
fail
(
"Device does not exist."
)
logging
.
info
(
"Hot unplug device %s"
%
self
.
device
)
qdev
.
simple_unplug
(
device
[
0
],
self
.
vm
.
monitor
)
timeout
=
self
.
params
.
get
(
"cancel_timeout"
,
10
)
unplugged
=
utils_misc
.
wait_for
(
is_unplugged
,
timeout
=
timeout
)
if
not
unplugged
:
self
.
test
.
fail
(
"Unplug timeout in %ss"
%
timeout
)
def
create_files
(
self
):
"""
Create files and record m5 values of them.
"""
file_names
=
self
.
params
[
"file_names"
]
map
(
self
.
create_file
,
file_names
.
split
())
def
verify_md5s
(
self
):
"""
Check if the md5 values matches the record ones.
"""
file_names
=
self
.
params
[
"file_names"
]
map
(
self
.
verify_md5
,
file_names
.
split
())
qemu/tests/block_stream_installation.py
0 → 100644
浏览文件 @
cf5d845a
import
time
import
random
from
virttest
import
utils_test
from
virttest
import
utils_misc
from
qemu.tests
import
blk_stream
def
run
(
test
,
params
,
env
):
"""
block_stream_installation test:
1). guest installation
2). live snapshot during guest installation
3). block stream afterwards
:param test: QEMU test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
args
=
(
test
,
params
,
env
)
bg
=
utils_misc
.
InterruptedThread
(
utils_test
.
run_virt_sub_test
,
args
,
{
"sub_type"
:
"unattended_install"
})
bg
.
start
()
utils_misc
.
wait_for
(
bg
.
is_alive
,
timeout
=
10
)
time
.
sleep
(
random
.
uniform
(
60
,
200
))
tag
=
params
[
"source_image"
]
stream_test
=
blk_stream
.
BlockStream
(
test
,
params
,
env
,
tag
)
stream_test
.
trash_files
.
append
(
stream_test
.
image_file
)
try
:
stream_test
.
create_snapshots
()
stream_test
.
start
()
stream_test
.
wait_for_finished
()
bg
.
join
()
finally
:
stream_test
.
clean
()
qemu/tests/block_stream_simple.py
浏览文件 @
cf5d845a
...
...
@@ -34,6 +34,7 @@ def run(test, params, env):
tag
=
params
.
get
(
"source_image"
,
"image1"
)
simple_test
=
BlockStreamSimple
(
test
,
params
,
env
,
tag
)
try
:
simple_test
.
action_before_start
()
simple_test
.
create_snapshots
()
simple_test
.
start
()
simple_test
.
action_when_streaming
()
...
...
qemu/tests/cfg/block_stream.cfg
浏览文件 @
cf5d845a
...
...
@@ -21,6 +21,19 @@
kill_vm = yes
alive_check_cmd = dir
tmp_dir = /tmp
Windows:
create_command = "WIN_UTILS:\coreutils\DummyCMD.exe FILE 1073741824 1"
file_names = "C:\block_stream_test"
test_exists_cmd = "dir FILE"
x86_64:
sync_cmd = "WIN_UTILS:\Sync\sync64.exe /accepteula"
i386, i686:
sync_cmd = "WIN_UTILS:\Sync\sync.exe /accepteula"
Linux:
create_command = "dd if=/dev/urandom of=FILE bs=128k count=100"
file_names = "/home/block_stream_test"
test_exists_cmd = "test -f FILE"
sync_cmd = "sync"
variants:
- @default:
- with_data_plane:
...
...
@@ -108,3 +121,36 @@
when_streaming = "pause_job set_speed resume_job cancel start wait_for_finished"
Host_RHEL.m6:
when_streaming = "set_speed cancel start wait_for_finished"
- with_data_integrity:
type = block_stream_simple
before_start = "create_files stop"
after_finished = "resume verify_md5s"
- with_stop_cont:
type = block_stream_simple
when_streaming = "stop resume stop resume stop resume"
after_finished = "reboot verify_alive"
- with_installation:
type = block_stream_installation
wait_timeout = 36000
default_speed = 10240000
need_install = yes
start_vm = no
images = "stg"
image_name_stg = "images/block_stream_installation"
image_size_stg = 20G
boot_drive_stg = yes
source_image = "stg"
medium = cdrom
force_create_image_stg = yes
image_aio = threads
unattended_delivery_method = cdrom
cdroms += " unattended"
index_enable = no
Linux:
kernel = vmlinuz
initrd = initrd.img
- with_hot_unplug:
type = block_stream_simple
before_start = "create_files"
when_streaming = "hot_unplug"
wait_finished = no
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录