Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
ea2f299a
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,发现更多精彩内容 >>
提交
ea2f299a
编写于
7月 28, 2017
作者:
X
Xu Han
提交者:
GitHub
7月 28, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #958 from vivianQizhu/live_backup
live_backup: Add test case for live backup.
上级
a05c15ee
a81a177e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
66 addition
and
16 deletion
+66
-16
qemu/tests/block_copy.py
qemu/tests/block_copy.py
+3
-0
qemu/tests/cfg/live_backup.cfg
qemu/tests/cfg/live_backup.cfg
+12
-3
qemu/tests/live_backup_base.py
qemu/tests/live_backup_base.py
+51
-13
未找到文件。
qemu/tests/block_copy.py
浏览文件 @
ea2f299a
...
...
@@ -323,12 +323,15 @@ class BlockCopy(object):
"""
waiting until block job finished
"""
time_start
=
time
.
time
()
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
)
time_end
=
time
.
time
()
logging
.
info
(
"Block job done."
)
return
time_end
-
time_start
def
action_after_finished
(
self
):
"""
...
...
qemu/tests/cfg/live_backup.cfg
浏览文件 @
ea2f299a
...
...
@@ -14,14 +14,14 @@
image_name_incremental0 = "images/incremental0"
clean_cmd = rm -f
before_full_backup = "stop"
after_full_backup = "
wait_for_finished
resume"
after_full_backup = "resume"
before_incremental = "stop"
after_incremental = "
wait_for_finished verify_job_info
"
after_incremental = "
verify_job_info reopen
"
check_params = ""
variants:
- @default:
before_full_backup = "create_files reboot stop"
after_incremental += "
reopen verify_md5s
"
after_incremental += "
verify_md5s verify_efficiency
"
Linux:
create_cmd = "dd if=/dev/urandom of=FILE bs=128k count=100"
file_names = "/home/test"
...
...
@@ -38,3 +38,12 @@
granularity = 32768
- 131072:
granularity = 131072
- with_data_plane:
only Host_RHEL.m7
only virtio_blk virtio_scsi
iothreads = iothread0
virtio_blk:
blk_extra_params_image1 = "iothread=iothread0"
virtio_scsi:
no Host_RHEL.m7.u0, Host_RHEL.m7.u1, Host_RHEL.m7.u2
bus_extra_params_image1 = "iothread=iothread0"
qemu/tests/live_backup_base.py
浏览文件 @
ea2f299a
import
re
import
time
import
logging
from
avocado.core
import
exceptions
from
virttest
import
utils_misc
from
virttest
import
qemu_storage
from
virttest
import
error_context
from
virttest.staging
import
utils_memory
from
qemu.tests
import
block_copy
...
...
@@ -35,6 +33,8 @@ class LiveBackup(block_copy.BlockCopy):
self
.
backup_index
=
1
self
.
backup_format
=
self
.
params
.
get
(
"backup_format"
)
self
.
generate_backup_params
()
self
.
full_backup_time
=
0
self
.
incremental_backup_time
=
0
def
generate_backup_params
(
self
):
"""
...
...
@@ -58,7 +58,7 @@ class LiveBackup(block_copy.BlockCopy):
backup_params
[
"base_format"
]
=
self
.
params
.
get
(
"format"
)
qemu_image
=
qemu_storage
.
QemuImg
(
backup_params
,
self
.
data_dir
,
backup_image
)
error_context
.
context
(
"create backup image for %s"
%
backup_image
,
logging
.
info
)
logging
.
info
(
"create backup image for %s"
%
backup_image
)
backup_image_name
,
_
=
qemu_image
.
create
(
backup_params
)
self
.
backup_index
+=
1
self
.
trash_files
.
append
(
backup_image_name
)
...
...
@@ -95,22 +95,22 @@ class LiveBackup(block_copy.BlockCopy):
"mode"
:
mode
,
"speed"
:
speed
}
self
.
transaction_add
(
args_list
,
"drive-backup"
,
backup_args
)
error_context
.
context
(
"Create bitmap and drive-backup with transaction "
"for %s"
%
drive_name
,
logging
.
info
)
logging
.
info
(
"Create bitmap and drive-backup with transaction "
"for %s"
%
drive_name
)
self
.
vm
.
monitor
.
transaction
(
args_list
)
if
not
self
.
get_status
():
raise
exceptions
.
TestF
ail
(
"full backup job not found"
)
self
.
test
.
f
ail
(
"full backup job not found"
)
return
None
error_context
.
context
(
"Create bitmap for %s"
%
drive_name
,
logging
.
info
)
logging
.
info
(
"Create bitmap for %s"
%
drive_name
)
self
.
vm
.
monitor
.
operate_dirty_bitmap
(
"add"
,
drive_name
,
bitmap_name
,
granularity
)
if
not
backup_image_name
:
raise
exceptions
.
TestE
rror
(
"No backup target provided."
)
error_context
.
context
(
"Create %s backup for %s"
%
(
sync
,
drive_name
),
logging
.
info
)
self
.
test
.
e
rror
(
"No backup target provided."
)
logging
.
info
(
"Create %s backup for %s"
%
(
sync
,
drive_name
)
)
self
.
vm
.
monitor
.
drive_backup
(
drive_name
,
backup_image_name
,
backup_format
,
sync
,
speed
,
mode
,
bitmap_name
)
if
not
self
.
get_status
():
raise
exceptions
.
TestF
ail
(
"%s backup job not found"
%
sync
)
self
.
test
.
f
ail
(
"%s backup job not found"
%
sync
)
utils_memory
.
drop_caches
()
def
transaction_add
(
self
,
args_list
,
type
,
data
):
...
...
@@ -139,6 +139,22 @@ class LiveBackup(block_copy.BlockCopy):
source_image
=
qemu_storage
.
storage
.
get_image_filename
(
params
,
data_dir
)
qemu_image
.
compare_images
(
compare_image
,
source_image
)
def
get_image_size
(
self
,
image
):
"""
Get image size for given image.
:param image: image file.
:return: image size.
"""
params
=
self
.
params
.
object_params
(
image
)
qemu_image
=
qemu_storage
.
QemuImg
(
params
,
self
.
data_dir
,
image
)
image_info
=
qemu_image
.
info
()
if
not
image_info
:
self
.
test
.
error
(
"Get image info failed."
)
image_size
=
re
.
findall
(
"disk size: (\d\.?\d*?.*)"
,
image_info
)[
0
]
image_size
=
int
(
float
(
utils_misc
.
normalize_data_size
(
image_size
,
"B"
)))
logging
.
info
(
"Image size of %s is %s"
%
(
image
,
image_size
))
return
image_size
def
reopen
(
self
):
"""
Closing the vm and reboot it with the backup image.
...
...
@@ -170,13 +186,17 @@ class LiveBackup(block_copy.BlockCopy):
"""
Run steps after create full backup.
"""
self
.
full_backup_time
=
self
.
wait_for_finished
()
self
.
do_steps
(
"after_full_backup"
)
time
.
sleep
(
120
)
logging
.
info
(
"Sleep for guest data generation."
)
incremental_time
=
self
.
params
.
get
(
"incremental_time"
,
120
)
time
.
sleep
(
incremental_time
)
def
after_incremental
(
self
):
"""
Run steps after create incremental backup.
"""
self
.
incremental_backup_time
=
self
.
wait_for_finished
()
return
self
.
do_steps
(
"after_incremental"
)
def
verify_job_info
(
self
):
...
...
@@ -196,7 +216,7 @@ class LiveBackup(block_copy.BlockCopy):
else
:
value
=
info
.
get
(
check_param
,
""
)
if
str
(
value
)
!=
target_value
:
raise
exceptions
.
TestF
ail
(
self
.
test
.
f
ail
(
"%s unmatched. Target is %s, result is %s"
%
(
check_param
,
target_value
,
value
))
...
...
@@ -213,3 +233,21 @@ class LiveBackup(block_copy.BlockCopy):
"""
file_names
=
self
.
params
[
"file_names"
]
return
map
(
self
.
verify_md5
,
file_names
.
split
())
def
verify_efficiency
(
self
):
"""
Verify time and space efficiency for incremental backup.
"""
if
not
self
.
incremental_backup_time
<
self
.
full_backup_time
:
self
.
test
.
fail
(
"incremental backup time %s, "
"larger than full backup time %s "
%
(
self
.
incremental_backup_time
,
self
.
full_backup_time
))
logging
.
info
(
"Incremental backup time efficiency check passed."
)
full_size
=
self
.
get_image_size
(
self
.
image_chain
[
0
])
incre_size
=
self
.
get_image_size
(
self
.
image_chain
[
1
])
if
incre_size
>
full_size
:
self
.
test
.
fail
(
"incremental backup image size %s, "
"larger than full backup image size %s "
%
(
incre_size
,
full_size
))
logging
.
info
(
"Incremental backup space efficiency check passed."
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录