Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
60184402
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,发现更多精彩内容 >>
提交
60184402
编写于
2月 28, 2014
作者:
Y
Yiqiao Pu
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19 from humanux/vlan
tests.vlan: some issues fix
上级
c8eea96c
cd6ec285
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
108 addition
and
88 deletion
+108
-88
generic/tests/cfg/vlan.cfg
generic/tests/cfg/vlan.cfg
+4
-0
generic/tests/vlan.py
generic/tests/vlan.py
+104
-88
未找到文件。
generic/tests/cfg/vlan.cfg
浏览文件 @
60184402
...
...
@@ -16,3 +16,7 @@
cmd_type = ip
RHEL.5:
cmd_type = vconfig
variants:
- @vlan_connective_test:
- vlan_scalability_test:
do_maximal_test = yes
generic/tests/vlan.py
浏览文件 @
60184402
...
...
@@ -30,8 +30,8 @@ def run(test, params, env):
Creates a vlan-device on iface by cmd that assigned by cmd_type
now only support 'ip' and 'vconfig'
"""
txt
=
"Create a vlan-device on interface %s with vlan id %s"
%
(
iface
,
v_id
)
vlan_if
=
'%s.%s'
%
(
iface
,
v_id
)
txt
=
"Create vlan interface '%s' on %s"
%
(
vlan_if
,
iface
)
error
.
context
(
txt
,
logging
.
info
)
if
cmd_type
==
"vconfig"
:
cmd
=
"vconfig add %s %s"
%
(
iface
,
v_id
)
...
...
@@ -40,19 +40,19 @@ def run(test, params, env):
cmd
=
"ip link add link %s %s type vlan id %s "
%
(
iface
,
v_name
,
v_id
)
else
:
err_msg
=
"Unexpected vlan operation command: %s"
%
cmd_type
err_msg
=
"Unexpected vlan operation command: %s
,
"
%
cmd_type
err_msg
+=
"only support 'ip' and 'vconfig' now"
raise
error
.
TestError
(
err_msg
)
session
.
cmd
(
cmd
)
def
set_ip_vlan
(
session
,
v_id
,
ip
,
iface
=
"eth0"
):
def
set_ip_vlan
(
session
,
v_id
,
vlan_
ip
,
iface
=
"eth0"
):
"""
Set ip address of vlan interface
"""
iface
=
"%s.%s"
%
(
iface
,
v_id
)
txt
=
"
Set ip to '%s' for interface '%s'"
%
(
iface
,
ip
)
txt
=
"
Assign IP '%s' to vlan interface '%s'"
%
(
vlan_ip
,
iface
)
error
.
context
(
txt
,
logging
.
info
)
session
.
cmd
(
"ifconfig %s %s"
%
(
iface
,
ip
))
session
.
cmd
(
"ifconfig %s %s"
%
(
iface
,
vlan_
ip
))
def
set_arp_ignore
(
session
):
"""
...
...
@@ -73,56 +73,65 @@ def run(test, params, env):
elif
cmd_type
==
"ip"
:
rem_vlan_cmd
=
"ip link delete %s"
%
v_iface
else
:
err_msg
=
"Unexpected vlan operation command: %s"
%
cmd_type
err_msg
=
"Unexpected vlan operation command: %s
,
"
%
cmd_type
err_msg
+=
"only support 'ip' and 'vconfig' now"
raise
error
.
TestError
(
err_msg
)
send_cmd
=
"[ -e /proc/net/vlan/%s ] && %s"
%
(
v_iface
,
rem_vlan_cmd
)
error
.
context
(
"Remove
the vlan-devi
ce '%s'."
%
v_iface
,
logging
.
info
)
error
.
context
(
"Remove
vlan interfa
ce '%s'."
%
v_iface
,
logging
.
info
)
return
session
.
cmd_status
(
send_cmd
)
def
nc_transfer
(
src
,
dst
):
"""
Transfer file by netcat
"""
nc_port
=
utils_misc
.
find_free_port
(
1025
,
5334
,
vm_ip
[
dst
])
listen_cmd
=
params
.
get
(
"listen_cmd"
)
send_cmd
=
params
.
get
(
"send_cmd"
)
#listen in dst
listen_cmd
=
listen_cmd
%
(
nc_port
,
"receive"
)
session
[
dst
].
sendline
(
listen_cmd
)
session
s
[
dst
].
sendline
(
listen_cmd
)
time
.
sleep
(
2
)
# send file from src to dst
send_cmd
=
send_cmd
%
(
vlan_ip
[
dst
],
str
(
nc_port
),
"file"
)
session
[
src
].
cmd
(
send_cmd
,
timeout
=
60
)
session
s
[
src
].
cmd
(
send_cmd
,
timeout
=
60
)
try
:
session
[
dst
].
read_up_to_prompt
(
timeout
=
60
)
session
s
[
dst
].
read_up_to_prompt
(
timeout
=
60
)
except
aexpect
.
ExpectError
:
#kill server
session_ctl
[
dst
].
cmd_output_safe
(
"killall -9 nc"
)
raise
error
.
TestFail
(
"Fail to receive file"
" from vm%s to vm%s"
%
(
src
+
1
,
dst
+
1
))
# check MD5 message digest of receive file in dst
output
=
session
[
dst
].
cmd_output
(
"md5sum receive"
).
strip
()
output
=
session
s
[
dst
].
cmd_output
(
"md5sum receive"
).
strip
()
digest_receive
=
re
.
findall
(
r
'(\w+)'
,
output
)[
0
]
if
digest_receive
==
digest_origin
[
src
]:
logging
.
info
(
"
f
ile succeed received in vm %s"
,
vlan_ip
[
dst
])
logging
.
info
(
"
F
ile succeed received in vm %s"
,
vlan_ip
[
dst
])
else
:
logging
.
info
(
"
d
igest_origin is %s"
,
digest_origin
[
src
])
logging
.
info
(
"
d
igest_receive is %s"
,
digest_receive
)
logging
.
info
(
"
D
igest_origin is %s"
,
digest_origin
[
src
])
logging
.
info
(
"
D
igest_receive is %s"
,
digest_receive
)
raise
error
.
TestFail
(
"File transferred differ from origin"
)
session
[
dst
].
cmd
(
"rm -f receive"
)
session
s
[
dst
].
cmd
(
"rm -f receive"
)
def
flood_ping
(
src
,
dst
):
"""
Flood ping test
# we must use a dedicated session because the aexpect
# does not have the other method to interrupt the process in
# the guest rather than close the session.
error
.
context
(
"Flood ping from %s interface %s to %s"
%
(
vm
[
src
].
name
,
"""
error
.
context
(
"Flood ping from %s interface %s to %s"
%
(
vms
[
src
].
name
,
ifname
[
src
],
vlan_ip
[
dst
]),
logging
.
info
)
session_flood
=
vm
[
src
].
wait_for_login
(
timeout
=
60
)
session_flood
=
vm
s
[
src
].
wait_for_login
(
timeout
=
60
)
utils_test
.
ping
(
vlan_ip
[
dst
],
flood
=
True
,
interface
=
ifname
[
src
],
session
=
session_flood
,
timeout
=
10
)
session_flood
.
close
()
vm
=
[]
session
=
[]
vms
=
[]
sessions
=
[]
session_ctl
=
[]
ifname
=
[]
vm_ip
=
[]
digest_origin
=
[]
...
...
@@ -130,97 +139,104 @@ def run(test, params, env):
ip_unit
=
[
'1'
,
'2'
]
subnet
=
params
.
get
(
"subnet"
,
"192.168"
)
vlan_num
=
int
(
params
.
get
(
"vlan_num"
,
5
))
maximal
=
int
(
params
.
get
(
"maximal"
))
file_size
=
params
.
get
(
"file_size"
,
409
4
)
maximal
=
int
(
params
.
get
(
"maximal"
,
4094
))
file_size
=
params
.
get
(
"file_size"
,
409
6
)
cmd_type
=
params
.
get
(
"cmd_type"
,
"ip"
)
login_timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
vm
.
append
(
env
.
get_vm
(
params
[
"main_vm"
]))
vm
.
append
(
env
.
get_vm
(
"vm2"
))
for
vm_
in
vm
:
vm
s
.
append
(
env
.
get_vm
(
params
[
"main_vm"
]))
vm
s
.
append
(
env
.
get_vm
(
"vm2"
))
for
vm_
in
vm
s
:
vm_
.
verify_alive
()
for
i
in
range
(
2
):
session
.
append
(
vm
[
i
].
wait_for_login
(
timeout
=
login_timeout
))
if
not
session
[
i
]:
raise
error
.
TestError
(
"Could not log into guest %s"
%
vm
[
i
].
name
)
logging
.
info
(
"Logged in %s successful"
%
vm
[
i
].
name
)
ifname
.
append
(
utils_net
.
get_linux_ifname
(
session
[
i
],
vm
[
i
].
get_mac_address
()))
for
vm_index
,
vm
in
enumerate
(
vms
):
error
.
base_context
(
"Prepare test env on %s"
%
vm
.
name
)
session
=
vm
.
wait_for_login
(
timeout
=
login_timeout
)
if
not
session
:
err_msg
=
"Could not log into guest %s"
%
vm
.
name
raise
error
.
TestError
(
err_msg
)
sessions
.
append
(
session
)
logging
.
info
(
"Logged in %s successful"
%
vm
.
name
)
session_ctl
.
append
(
vm
.
wait_for_login
(
timeout
=
login_timeout
))
ifname
.
append
(
utils_net
.
get_linux_ifname
(
session
,
vm
.
get_mac_address
()))
# get guest ip
vm_ip
.
append
(
vm
[
i
].
get_address
())
vm_ip
.
append
(
vm
.
get_address
())
# produce sized file in vm
dd_cmd
=
"dd if=/dev/urandom of=file bs=1
024k
count=%s"
session
[
i
]
.
cmd
(
dd_cmd
%
file_size
)
dd_cmd
=
"dd if=/dev/urandom of=file bs=1
M
count=%s"
session
.
cmd
(
dd_cmd
%
file_size
)
# record MD5 message digest of file
output
=
session
[
i
]
.
cmd
(
"md5sum file"
,
timeout
=
60
)
digest_origin
.
append
(
re
.
findall
(
r
'(\w+)'
,
output
)[
0
])
md5sum_output
=
session
.
cmd
(
"md5sum file"
,
timeout
=
60
)
digest_origin
.
append
(
re
.
findall
(
r
'(\w+)'
,
md5sum_
output
)[
0
])
# stop firewall in vm
session
[
i
].
cmd
(
"service iptables stop; true"
)
session
.
cmd_output_safe
(
"iptables -F; service iptables stop; true"
)
error
.
context
(
"Load 8021q module in guest %s"
%
vm
.
name
,
logging
.
info
)
session
.
cmd_output_safe
(
"modprobe 8021q"
)
error
.
context
(
"
load 8021q module in guest %s"
%
vm
[
i
]
.
name
,
error
.
context
(
"
Setup vlan environment in guest %s"
%
vm
.
name
,
logging
.
info
)
session
[
i
].
cmd
(
"modprobe 8021q"
)
for
vlan_i
in
range
(
1
,
vlan_num
+
1
):
add_vlan
(
session
,
vlan_i
,
ifname
[
vm_index
],
cmd_type
)
v_ip
=
"%s.%s.%s"
%
(
subnet
,
vlan_i
,
ip_unit
[
vm_index
])
set_ip_vlan
(
session
,
vlan_i
,
v_ip
,
ifname
[
vm_index
])
set_arp_ignore
(
session
)
try
:
for
i
in
range
(
2
):
logging
.
info
(
"Setup vlan environment in guest %s"
%
vm
[
i
].
name
)
for
vlan_i
in
range
(
1
,
vlan_num
+
1
):
add_vlan
(
session
[
i
],
vlan_i
,
ifname
[
i
],
cmd_type
)
v_ip
=
"%s.%s.%s"
%
(
subnet
,
vlan_i
,
ip_unit
[
i
])
set_ip_vlan
(
session
[
i
],
vlan_i
,
v_ip
,
ifname
[
i
])
set_arp_ignore
(
session
[
i
])
for
vlan
in
range
(
1
,
vlan_num
+
1
):
error
.
context
(
"Test for vlan %s"
%
vlan
,
logging
.
info
)
error
.
base_context
(
"Test for vlan %s"
%
vlan
,
logging
.
info
)
error
.
context
(
"Ping test between vlans"
,
logging
.
info
)
interface
=
ifname
[
0
]
+
'.'
+
str
(
vlan
)
for
vlan2
in
range
(
1
,
vlan_num
+
1
):
for
i
in
range
(
2
):
interface
=
ifname
[
i
]
+
'.'
+
str
(
vlan
)
dest
=
subnet
+
'.'
+
\
str
(
vlan2
)
+
'.'
+
ip_unit
[(
i
+
1
)
%
2
]
s
,
o
=
utils_test
.
ping
(
dest
,
count
=
2
,
interface
=
interface
,
session
=
session
[
i
],
timeout
=
30
)
if
((
vlan
==
vlan2
)
^
(
s
==
0
)):
raise
error
.
TestFail
(
"%s ping %s unexpected"
%
(
interface
,
dest
))
vlan_ip
[
0
]
=
subnet
+
'.'
+
str
(
vlan
)
+
'.'
+
ip_unit
[
0
]
vlan_ip
[
1
]
=
subnet
+
'.'
+
str
(
vlan
)
+
'.'
+
ip_unit
[
1
]
for
vm_index
,
vm
in
enumerate
(
vms
):
for
vlan2
in
range
(
1
,
vlan_num
+
1
):
interface
=
ifname
[
vm_index
]
+
'.'
+
str
(
vlan
)
dest
=
"."
.
join
((
subnet
,
str
(
vlan2
),
ip_unit
[(
vm_index
+
1
)
%
2
]))
status
,
output
=
utils_test
.
ping
(
dest
,
count
=
2
,
interface
=
interface
,
session
=
sessions
[
vm_index
],
timeout
=
30
)
if
((
vlan
==
vlan2
)
^
(
status
==
0
)):
err_msg
=
"%s ping %s unexpected, "
%
(
interface
,
dest
)
err_msg
+=
"error info: %s"
%
output
raise
error
.
TestFail
(
err_msg
)
error
.
context
(
"Flood ping between vlans"
,
logging
.
info
)
vlan_ip
[
0
]
=
"."
.
join
((
subnet
,
str
(
vlan
),
ip_unit
[
0
]))
vlan_ip
[
1
]
=
"."
.
join
((
subnet
,
str
(
vlan
),
ip_unit
[
1
]))
flood_ping
(
0
,
1
)
flood_ping
(
1
,
0
)
error
.
context
(
"Transferring data through nc"
,
logging
.
info
)
error
.
context
(
"Transferring data between vlans by nc"
,
logging
.
info
)
nc_transfer
(
0
,
1
)
nc_transfer
(
1
,
0
)
finally
:
for
vlan
in
range
(
1
,
vlan_num
+
1
):
logging
.
info
(
"rem vlan: %s"
,
vlan
)
rem_vlan
(
session
[
0
],
vlan
,
ifname
[
0
],
cmd_type
)
rem_vlan
(
session
[
1
],
vlan
,
ifname
[
1
],
cmd_type
)
#If client can not connect the nc server, need kill the server.
for
session
in
session_ctl
:
session
.
cmd_output_safe
(
"killall -9 nc"
)
error
.
base_context
(
"Remove vlan"
)
for
vm_index
,
vm
in
enumerate
(
vms
):
for
vlan
in
range
(
1
,
vlan_num
+
1
):
rem_vlan
(
sessions
[
vm_index
],
vlan
,
ifname
[
vm_index
],
cmd_type
)
# Plumb/unplumb maximal number of vlan interfaces
i
=
1
s
=
0
try
:
error
.
context
(
"Testing the plumb of vlan interface"
,
logging
.
info
)
for
i
in
range
(
1
,
maximal
+
1
):
add_vlan
(
session
[
0
],
i
,
ifname
[
0
],
cmd_type
)
finally
:
for
j
in
range
(
1
,
i
+
1
):
s
=
s
or
rem_vlan
(
session
[
0
],
j
,
ifname
[
0
],
cmd_type
)
if
s
==
0
:
logging
.
info
(
"maximal interface plumb test done"
)
else
:
logging
.
error
(
"maximal interface plumb test failed"
)
session
[
0
].
close
()
session
[
1
].
close
()
if
params
.
get
(
"do_maximal_test"
,
"no"
)
==
"yes"
:
try
:
error
.
base_context
(
"Vlan scalability test"
)
error
.
context
(
"Testing the plumb of vlan interface"
,
logging
.
info
)
for
vlan_index
in
range
(
1
,
maximal
+
1
):
add_vlan
(
sessions
[
0
],
vlan_index
,
ifname
[
0
],
cmd_type
)
vlan_added
=
vlan_index
if
vlan_added
!=
maximal
:
raise
error
.
TestFail
(
"Maximal interface plumb test failed"
)
finally
:
for
vlan_index
in
range
(
1
,
vlan_added
+
1
):
if
not
rem_vlan
(
sessions
[
0
],
vlan_index
,
ifname
[
0
],
cmd_type
):
logging
.
error
(
"Remove vlan %s failed"
%
vlan_index
)
sessions
.
extend
(
session_ctl
)
for
sess
in
sessions
:
if
sess
:
sess
.
close
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录