Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
76880bc7
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,发现更多精彩内容 >>
提交
76880bc7
编写于
2月 09, 2015
作者:
F
Feng Yang
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #240 from spcui/migration_multi_host
qemu.tests: Improve migration_multi_host
上级
07553b14
bccc1f87
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
83 addition
and
36 deletion
+83
-36
qemu/tests/migration_multi_host.py
qemu/tests/migration_multi_host.py
+83
-36
未找到文件。
qemu/tests/migration_multi_host.py
浏览文件 @
76880bc7
import
logging
import
os
import
time
from
autotest.client.shared
import
error
from
virttest
import
utils_test
,
remote
,
virt_vm
,
utils_misc
from
virttest
import
utils_test
@
error
.
context_aware
...
...
@@ -21,12 +21,6 @@ def run(test, params, env):
:param params: Dictionary with test parameters.
:param env: Dictionary with the test environment.
"""
login_timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
pre_sub_test
=
params
.
get
(
"pre_sub_test"
)
post_sub_test
=
params
.
get
(
"post_sub_test"
)
pre_sub_test_timeout
=
int
(
params
.
get
(
"pre_sub_test_timeout"
,
"240"
))
login_before_pre_tests
=
params
.
get
(
"login_before_pre_tests"
,
"no"
)
mig_protocol
=
params
.
get
(
"mig_protocol"
,
"tcp"
)
mig_type
=
utils_test
.
qemu
.
MultihostMigration
if
mig_protocol
==
"fd"
:
...
...
@@ -34,31 +28,84 @@ def run(test, params, env):
if
mig_protocol
==
"exec"
:
mig_type
=
utils_test
.
qemu
.
MultihostMigrationExec
vms
=
params
.
get
(
"vms"
).
split
(
" "
)
srchost
=
params
[
"hosts"
][
0
]
dsthost
=
params
[
"hosts"
][
1
]
is_src
=
params
[
"hostid"
]
==
srchost
if
is_src
:
# is destination
if
pre_sub_test
:
if
login_before_pre_tests
==
"yes"
:
vm
=
env
.
get_vm
(
vms
[
0
])
vm
.
wait_for_login
(
timeout
=
login_timeout
)
error
.
context
(
"Run sub test '%s' before migration on src"
%
pre_sub_test
,
logging
.
info
)
utils_test
.
run_virt_sub_test
(
test
,
params
,
env
,
pre_sub_test
)
if
params
.
get
(
"check_vm_before_migration"
,
"yes"
)
==
"no"
:
params
[
'check_vm_needs_restart'
]
=
"no"
mig
=
mig_type
(
test
,
params
,
env
,
False
)
mig
.
_hosts_barrier
([
srchost
,
dsthost
],
{
'src'
:
srchost
,
'dst'
:
dsthost
,
"vms"
:
vms
[
0
]},
"sync"
,
pre_sub_test_timeout
)
mig
.
migrate_wait
([
vms
[
0
]],
srchost
,
dsthost
)
if
not
is_src
:
# is destination
if
post_sub_test
:
error
.
context
(
"Run sub test '%s' after migration on dst"
%
post_sub_test
,
logging
.
info
)
utils_test
.
run_virt_sub_test
(
test
,
params
,
env
,
post_sub_test
)
class
TestMultihostMigration
(
mig_type
):
def
__init__
(
self
,
test
,
params
,
env
):
super
(
TestMultihostMigration
,
self
).
__init__
(
test
,
params
,
env
)
self
.
srchost
=
self
.
params
.
get
(
"hosts"
)[
0
]
self
.
dsthost
=
self
.
params
.
get
(
"hosts"
)[
1
]
self
.
is_src
=
params
[
"hostid"
]
==
self
.
srchost
self
.
vms
=
params
[
"vms"
].
split
()
self
.
vm
=
params
[
"vms"
].
split
()[
0
]
self
.
login_timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
self
.
pre_sub_test
=
params
.
get
(
"pre_sub_test"
)
self
.
post_sub_test
=
params
.
get
(
"post_sub_test"
)
self
.
login_before_pre_tests
=
params
.
get
(
"login_before_pre_tests"
,
"no"
)
self
.
mig_bg_command
=
params
.
get
(
"migration_bg_command"
,
"cd /tmp; nohup ping localhost &"
)
self
.
mig_bg_check_command
=
params
.
get
(
"migration_bg_check_command"
,
"pgrep ping"
)
self
.
mig_bg_kill_command
=
params
.
get
(
"migration_bg_kill_command"
,
"pkill -9 ping"
)
self
.
need_to_login
=
params
.
get
(
"need_to_login"
,
"no"
)
def
run_pre_sub_test
(
self
):
# is source host
if
self
.
is_src
:
if
self
.
pre_sub_test
:
if
self
.
login_before_pre_tests
==
"yes"
:
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
.
wait_for_login
(
timeout
=
self
.
login_timeout
)
error
.
context
(
"Run sub test '%s' before migration on src"
%
self
.
pre_sub_test
,
logging
.
info
)
utils_test
.
run_virt_sub_test
(
test
,
params
,
env
,
self
.
pre_sub_test
)
def
run_post_sub_test
(
self
):
# is destination host
if
not
self
.
is_src
:
if
self
.
post_sub_test
:
error
.
context
(
"Run sub test '%s' after migration on dst"
%
self
.
post_sub_test
,
logging
.
info
)
utils_test
.
run_virt_sub_test
(
test
,
params
,
env
,
self
.
post_sub_test
)
def
migration_scenario
(
self
,
worker
=
None
):
def
start_worker
(
mig_data
):
logging
.
info
(
"Try to login guest before migration test."
)
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
session
=
vm
.
wait_for_login
(
timeout
=
self
.
login_timeout
)
session
.
sendline
(
self
.
mig_bg_command
)
time
.
sleep
(
5
)
def
check_worker
(
mig_data
):
if
not
self
.
is_src
:
logging
.
info
(
"Try to login guest after migration test."
)
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
session
=
vm
.
wait_for_login
(
timeout
=
self
.
login_timeout
)
logging
.
info
(
"Check the background command in the guest."
)
s
,
o
=
session
.
cmd_status_output
(
self
.
mig_bg_check_command
)
if
s
:
raise
error
.
TestFail
(
"Background command not found,"
" Migration failed."
)
logging
.
info
(
"Kill the background command in the guest."
)
session
.
sendline
(
self
.
mig_bg_kill_command
)
session
.
close
()
if
params
.
get
(
"check_vm_before_migration"
,
"yes"
)
==
"no"
:
params
[
"check_vm_needs_restart"
]
=
"no"
self
.
run_pre_sub_test
()
if
self
.
need_to_login
==
"yes"
:
self
.
migrate_wait
([
self
.
vm
],
self
.
srchost
,
self
.
dsthost
,
start_work
=
start_worker
,
check_work
=
check_worker
)
else
:
self
.
migrate_wait
([
self
.
vm
],
self
.
srchost
,
self
.
dsthost
)
self
.
run_post_sub_test
()
mig
=
TestMultihostMigration
(
test
,
params
,
env
)
mig
.
run
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录