Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
fd3480b6
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,发现更多精彩内容 >>
提交
fd3480b6
编写于
3月 24, 2020
作者:
X
XuTian
提交者:
Xu Tian
3月 24, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add blockdev backup sync top test
Signed-off-by:
N
XuTian
<
xutian@redhat.com
>
上级
468e4c70
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
63 addition
and
37 deletion
+63
-37
provider/backup_utils.py
provider/backup_utils.py
+2
-3
provider/blockdev_base.py
provider/blockdev_base.py
+3
-2
qemu/tests/blockdev_inc_backup_bitmap_mode_test.py
qemu/tests/blockdev_inc_backup_bitmap_mode_test.py
+52
-32
qemu/tests/cfg/blockdev_inc_backup_bitmap_mode_test.cfg
qemu/tests/cfg/blockdev_inc_backup_bitmap_mode_test.cfg
+6
-0
未找到文件。
provider/backup_utils.py
浏览文件 @
fd3480b6
...
...
@@ -223,9 +223,8 @@ def blockdev_create(vm, **options):
@
fail_on
def
blockdev_snapshot
(
vm
,
source
,
target
,
**
extra_options
):
cmd
,
arguments
=
blockdev_snapshot_qmp_cmd
(
source
,
target
,
**
extra_options
)
timeout
=
int
(
extra_options
.
pop
(
"timeout"
,
600
))
vm
.
monitor
.
cmd
(
cmd
,
arguments
)
job_utils
.
wait_until_block_job_completed
(
vm
,
timeout
)
out
=
vm
.
monitor
.
cmd
(
cmd
,
arguments
)
assert
out
==
{},
'blockdev-snapshot-sync faild: %s'
%
out
@
fail_on
...
...
provider/blockdev_base.py
浏览文件 @
fd3480b6
...
...
@@ -34,7 +34,6 @@ class BlockdevBaseTest(object):
images_dir
=
data_dir
.
get_data_dir
()
image_params
=
params
.
object_params
(
image_name
)
img
=
qemu_storage
.
QemuImg
(
image_params
,
images_dir
,
image_name
)
self
.
trash
.
append
(
img
)
return
img
def
source_disk_define_by_params
(
self
,
params
,
image_name
):
...
...
@@ -68,6 +67,7 @@ class BlockdevBaseTest(object):
cluster_size
)
disk
=
self
.
source_disk_define_by_params
(
params
,
tag
)
disk
.
create
(
params
)
self
.
trash
.
append
(
disk
)
def
prepare_main_vm
(
self
):
for
vm
in
self
.
env
.
get_all_vms
():
...
...
@@ -160,6 +160,7 @@ class BlockdevBaseTest(object):
for
img
in
image_params
.
objects
(
"image_chain"
):
disk
=
self
.
target_disk_define_by_params
(
self
.
params
,
img
)
disk
.
hotplug
(
self
.
main_vm
)
self
.
trash
.
append
(
disk
)
def
prepare_test
(
self
):
self
.
preprocess_data_disks
()
...
...
@@ -200,4 +201,4 @@ class BlockdevBaseTest(object):
try
:
img
.
remove
()
except
Exception
as
e
:
logging
.
warn
ning
(
str
(
e
))
logging
.
warn
(
str
(
e
))
qemu/tests/blockdev_inc_backup_bitmap_mode_test.py
浏览文件 @
fd3480b6
import
logging
from
provider
import
backup_utils
from
provider
import
blockdev_base
from
provider
import
block_dirty_bitmap
...
...
@@ -18,16 +16,18 @@ class BlockdevIncreamentalBackupBitmapTest(blockdev_base.BlockdevBaseTest):
self
.
full_backups
=
[]
self
.
inc_backups
=
[]
self
.
bitmaps
=
[]
for
tag
in
params
.
objects
(
'source_images'
):
image_params
=
params
.
object_params
(
tag
)
self
.
src_img_tags
=
params
.
objects
(
"source_images"
)
self
.
sync_mode
=
params
.
get
(
"sync_mode"
,
"bitmap"
)
self
.
bitmap_mode
=
params
.
get
(
"bitmap_mode"
,
"always"
)
list
(
map
(
self
.
_init_arguments_by_params
,
self
.
src_img_tags
))
def
_init_arguments_by_params
(
self
,
tag
):
image_params
=
self
.
params
.
object_params
(
tag
)
image_chain
=
image_params
.
objects
(
"image_chain"
)
self
.
source_images
.
append
(
"drive_%s"
%
tag
)
self
.
full_backups
.
append
(
"drive_%s"
%
image_chain
[
0
])
self
.
inc_backups
.
append
(
"drive_%s"
%
image_chain
[
1
])
self
.
bitmaps
.
append
(
"bitmap_%s"
%
tag
)
inc_img_tag
=
image_chain
[
-
1
]
inc_img_params
=
params
.
object_params
(
inc_img_tag
)
inc_img_params
[
'image_chain'
]
=
image_params
[
'image_chain'
]
def
do_full_backup
(
self
):
extra_options
=
{
"sync"
:
"full"
,
"auto_disable_bitmap"
:
False
}
...
...
@@ -39,16 +39,13 @@ class BlockdevIncreamentalBackupBitmapTest(blockdev_base.BlockdevBaseTest):
**
extra_options
)
def
generate_inc_files
(
self
):
for
tag
in
self
.
params
.
objects
(
"source_images"
):
self
.
generate_data_file
(
tag
)
return
list
(
map
(
self
.
generate_data_file
,
self
.
src_img_tags
))
def
do_incremental_backup
(
self
):
sync_mode
=
self
.
params
.
get
(
"sync_mode"
,
"bitmap"
)
bitmap_mode
=
self
.
params
.
get
(
"bitmap_mode"
,
"always"
)
extra_options
=
{
'sync'
:
sync_mode
,
'bitmap-mode'
:
bitmap_mode
,
extra_options
=
{
'sync'
:
self
.
sync_mode
,
'auto_disable_bitmap'
:
False
}
logging
.
info
(
"bitmap sync mode: %s"
%
bitmap_mode
)
if
self
.
sync_mode
!=
"top"
:
extra_options
[
"bitmap-mode"
]
=
self
.
bitmap_mode
backup_utils
.
blockdev_batch_backup
(
self
.
main_vm
,
self
.
source_images
,
...
...
@@ -56,6 +53,25 @@ class BlockdevIncreamentalBackupBitmapTest(blockdev_base.BlockdevBaseTest):
self
.
bitmaps
,
**
extra_options
)
def
create_snapshot
(
self
,
source
):
snapshot_options
=
{}
source_node
=
"drive_%s"
%
source
source_params
=
self
.
params
.
object_params
(
source
)
snapshot_tag
=
source_params
[
"snapshot"
]
snapshot_node
=
"drive_%s"
%
snapshot_tag
snapshot_img
=
self
.
target_disk_define_by_params
(
self
.
params
,
snapshot_tag
)
snapshot_img
.
hotplug
(
self
.
main_vm
)
self
.
trash
.
append
(
snapshot_img
)
backup_utils
.
blockdev_snapshot
(
self
.
main_vm
,
source_node
,
snapshot_node
,
**
snapshot_options
)
def
create_snapshots
(
self
):
return
list
(
map
(
self
.
create_snapshot
,
self
.
src_img_tags
))
def
get_bitmaps_info
(
self
):
out
=
[]
for
idx
,
bitmap
in
enumerate
(
self
.
bitmaps
):
...
...
@@ -67,27 +83,31 @@ class BlockdevIncreamentalBackupBitmapTest(blockdev_base.BlockdevBaseTest):
def
do_test
(
self
):
self
.
do_full_backup
()
if
self
.
sync_mode
==
"top"
:
self
.
create_snapshots
()
self
.
generate_inc_files
()
self
.
main_vm
.
pause
()
self
.
do_incremental_backup
()
if
self
.
sync_mode
!=
"top"
:
self
.
check_bitmaps
()
self
.
compare_image
()
self
.
compare_image
s
()
def
check_bitmaps
(
self
):
bitmap_mode
=
self
.
params
.
get
(
"bitmap_mode"
,
"always"
)
for
info
in
self
.
get_bitmaps_info
():
if
bitmap_mode
==
"never"
:
if
self
.
bitmap_mode
==
"never"
:
keyword
=
"is"
condiction
=
info
[
"count"
]
>
0
else
:
keyword
=
"is not"
condiction
=
info
[
"count"
]
==
0
assert
condiction
,
"bitmap '%s' %s clear in '%s' mode:
\n
%s"
%
(
info
[
"name"
],
keyword
,
bitmap_mode
,
info
)
info
[
"name"
],
keyword
,
self
.
bitmap_mode
,
info
)
def
compare_image
(
self
):
def
compare_image
s
(
self
):
self
.
main_vm
.
destroy
()
for
src_tag
in
self
.
params
.
objects
(
"source_images"
):
return
list
(
map
(
self
.
_compare_image
,
self
.
src_img_tags
))
def
_compare_image
(
self
,
src_tag
):
src_params
=
self
.
params
.
object_params
(
src_tag
)
overlay_tag
=
src_params
.
objects
(
"image_chain"
)[
-
1
]
src_img
=
self
.
disk_define_by_params
(
self
.
params
,
src_tag
)
...
...
qemu/tests/cfg/blockdev_inc_backup_bitmap_mode_test.cfg
浏览文件 @
fd3480b6
...
...
@@ -35,3 +35,9 @@
bitmap_mode = never
- bitmap_success:
bitmap_mode = on-success
- bitmap_top:
sync_mode = top
snapshot_data = snapshot
image_format_snapshot = qcow2
image_size_snapshot = 2G
image_name_snapshot = snapshot
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录