Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
d6e89d5e
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,发现更多精彩内容 >>
提交
d6e89d5e
编写于
1月 31, 2014
作者:
L
Lucas Meneghel Rodrigues
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6 from FengYang/netstress_kill_guest
Fix and update for netstress_kill_guest.py
上级
bbe84c56
7a2bd27b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
77 addition
and
45 deletion
+77
-45
generic/tests/netstress_kill_guest.py
generic/tests/netstress_kill_guest.py
+77
-45
未找到文件。
generic/tests/netstress_kill_guest.py
浏览文件 @
d6e89d5e
...
...
@@ -5,30 +5,31 @@ import re
import
time
from
autotest.client.shared
import
error
from
autotest.client
import
utils
from
virttest
import
aexpec
t
from
virttest
import
utils_misc
,
data_dir
,
utils_ne
t
@
error
.
context_aware
def
run
(
test
,
params
,
env
):
"""
Try stop network interface in VM when other VM try to communicate.
Try to kill the guest after/during network stress in guest.
1) Boot up VM and log VM with serial.
For driver mode test:
2) Unload network driver(s).
3) Load network driver(s) again.
4) Repeat step 2 and 3 for 50 times.
5) Check that we can kill VM with signal 0.
For load mode test:
2) Stop iptables in guest and host.
3) Setup run netperf server in host and guest.
4) Start heavy network load host <=> guest by running netperf
client in host and guest.
5) During netperf running, Check that we can kill VM with signal 0.
6) Clean up netperf server in host and guest.(guest may already killed)
:param test: QEMU test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
def
get_corespond_ip
(
ip
):
"""
Get local ip address which is used for contact ip.
:param ip: Remote ip
:return: Local corespond IP.
"""
result
=
utils
.
run
(
"ip route get %s"
%
(
ip
)).
stdout
ip
=
re
.
search
(
"src (.+)"
,
result
)
if
ip
is
not
None
:
ip
=
ip
.
groups
()[
0
]
return
ip
def
get_ethernet_driver
(
session
):
"""
Get driver of network cards.
...
...
@@ -53,73 +54,104 @@ def run(test, params, env):
logging
.
error
(
"VM is not dead"
)
raise
error
.
TestFail
(
"VM is not dead after sending signal 0 to it"
)
except
OSError
:
logging
.
info
(
"VM is dead"
)
logging
.
info
(
"VM is dead
as expected
"
)
def
netload_kill_problem
(
session_serial
):
netperf_dir
=
os
.
path
.
join
(
os
.
environ
[
'AUTODIR'
],
"tests/netperf2"
)
setup_cmd
=
params
.
get
(
"setup_cmd"
)
clean_cmd
=
params
.
get
(
"clean_cmd"
)
firewall_flush
=
"iptables -F"
firewall_flush
=
params
.
get
(
"firewall_flush"
,
"service iptables stop"
)
error
.
context
(
"Stop firewall in guest and host."
,
logging
.
info
)
try
:
utils
.
run
(
firewall_flush
)
except
Exception
:
logging
.
warning
(
"Could not
flush firewall rules o
n host"
)
logging
.
warning
(
"Could not
stop firewall i
n host"
)
try
:
session_serial
.
cmd
(
firewall_flush
)
except
aexpect
.
ShellError
:
logging
.
warning
(
"Could not flush firewall rules on guest"
)
for
i
in
params
.
get
(
"netperf_files"
).
split
():
vm
.
copy_files_to
(
os
.
path
.
join
(
netperf_dir
,
i
),
"/tmp"
)
except
Exception
:
logging
.
warning
(
"Could not stop firewall in guest"
)
netperf_links
=
params
[
"netperf_links"
].
split
()
remote_dir
=
params
.
get
(
"remote_dir"
,
"/var/tmp"
)
# netperf_links support multi links. In case we need apply patchs to
# netperf or need copy other files.
for
netperf_link
in
netperf_links
:
if
utils
.
is_url
(
netperf_link
):
download_dir
=
data_dir
.
get_download_dir
()
netperf_link
=
utils
.
unmap_url_cache
(
download_dir
,
netperf_link
)
netperf_dir
=
download_dir
elif
netperf_link
:
netperf_link
=
utils_misc
.
get_path
(
data_dir
.
get_deps_dir
(),
netperf_link
)
vm
.
copy_files_to
(
netperf_link
,
remote_dir
)
utils
.
force_copy
(
netperf_link
,
remote_dir
)
guest_ip
=
vm
.
get_address
(
0
)
server_ip
=
get_co
respond_ip
(
guest_ip
)
server_ip
=
utils_net
.
get_cor
respond_ip
(
guest_ip
)
logging
.
info
(
"Setup and run netperf on host and guest"
)
session_serial
.
cmd
(
setup_cmd
%
"/tmp"
,
timeout
=
200
)
utils
.
run
(
setup_cmd
%
netperf_dir
)
error
.
context
(
"Setup and run netperf server in host and guest"
,
logging
.
info
)
session_serial
.
cmd
(
setup_cmd
%
remote_dir
,
timeout
=
200
)
utils
.
run
(
setup_cmd
%
remote_dir
,
timeout
=
200
)
try
:
session_serial
.
cmd
(
clean_cmd
)
except
Exception
:
pass
session_serial
.
cmd
(
params
.
get
(
"netserver_cmd"
)
%
"/tmp"
)
session_serial
.
cmd
(
params
.
get
(
"netserver_cmd"
)
%
remote_dir
)
utils
.
run
(
clean_cmd
,
ignore_status
=
True
)
utils
.
run
(
params
.
get
(
"netserver_cmd"
)
%
netperf
_dir
)
server_netperf_cmd
=
params
.
get
(
"netperf_cmd"
)
%
(
netperf_dir
,
"TCP_STREAM"
,
guest_ip
,
params
.
get
(
"packet_size"
,
"1500"
))
guest_netperf_cmd
=
params
.
get
(
"netperf_cmd"
)
%
(
"/tmp"
,
"TCP_STREAM"
,
server_ip
,
params
.
get
(
"packet_size"
,
"1500"
))
env
.
stop_tcpdump
()
utils
.
run
(
params
.
get
(
"netserver_cmd"
)
%
remote
_dir
)
p_size
=
params
.
get
(
"packet_size"
,
"1500"
)
host_netperf_cmd
=
params
.
get
(
"netperf_cmd"
)
%
(
remote_dir
,
"TCP_STREAM"
,
guest_ip
,
p_size
)
guest_netperf_cmd
=
params
.
get
(
"netperf_cmd"
)
%
(
remote_dir
,
"TCP_STREAM"
,
server_ip
,
p_size
)
try
:
logging
.
info
(
"Start heavy network load host <=> guest."
)
error
.
context
(
"Start heavy network load host <=> guest."
,
logging
.
info
)
session_serial
.
sendline
(
guest_netperf_cmd
)
utils
.
BgJob
(
server
_netperf_cmd
)
utils
.
BgJob
(
host
_netperf_cmd
)
# Wait for create big network usage.
time
.
sleep
(
10
)
msg
=
"During netperf running, Check that we can kill VM with signal 0"
error
.
context
(
msg
,
logging
.
info
)
kill_and_check
(
vm
)
finally
:
error
.
context
(
"Clean up netperf server in host and guest."
,
logging
.
info
)
utils
.
run
(
clean_cmd
,
ignore_status
=
True
)
env
.
start_tcpdump
()
try
:
session_serial
.
cmd
(
clean_cmd
)
except
Exception
:
pass
def
netdriver_kill_problem
(
session_serial
):
r_time
=
int
(
params
.
get
(
"repeat_times"
,
50
))
modules
=
get_ethernet_driver
(
session_serial
)
logging
.
debug
(
modules
)
for
_
in
range
(
50
):
logging
.
debug
(
"Guest network driver(s): %s"
%
modules
)
msg
=
"Repeatedly load/unload network driver(s) for %s times."
%
r_time
error
.
context
(
msg
,
logging
.
info
)
for
round
in
range
(
r_time
):
for
module
in
modules
:
error
.
context
(
"Unload driver %s. Repeat: %s/%s"
%
(
module
,
round
,
r_time
))
session_serial
.
cmd_output_safe
(
"rmmod %s"
%
module
)
for
module
in
modules
:
error
.
context
(
"Load driver %s. Repeat: %s/%s"
%
(
module
,
round
,
r_time
))
session_serial
.
cmd_output_safe
(
"modprobe %s"
%
module
)
error
.
context
(
"Check that we can kill VM with signal 0."
,
logging
.
info
)
kill_and_check
(
vm
)
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录