Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
67c4dfbe
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,发现更多精彩内容 >>
未验证
提交
67c4dfbe
编写于
8月 11, 2020
作者:
Y
YongxueHong
提交者:
GitHub
8月 11, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2279 from zhencliu/curl_access
Curl image access test
上级
adad139d
76de6b70
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
203 addition
and
0 deletion
+203
-0
qemu/tests/boot_with_remote_readonly_image.py
qemu/tests/boot_with_remote_readonly_image.py
+43
-0
qemu/tests/cfg/remote_readonly_storage.cfg
qemu/tests/cfg/remote_readonly_storage.cfg
+53
-0
qemu/tests/curl_cookie_with_secret.py
qemu/tests/curl_cookie_with_secret.py
+70
-0
qemu/tests/remote_image_qemu_info_access.py
qemu/tests/remote_image_qemu_info_access.py
+37
-0
未找到文件。
qemu/tests/boot_with_remote_readonly_image.py
0 → 100644
浏览文件 @
67c4dfbe
from
virttest
import
qemu_storage
from
virttest
import
data_dir
from
virttest
import
utils_misc
from
virttest
import
utils_test
from
avocado
import
fail_on
from
avocado.utils
import
process
from
provider
import
qemu_img_utils
as
img_utils
def
run
(
test
,
params
,
env
):
"""
1) Convert remote readonly system image to the local image
2) Start VM from the local image,
with the remote iso image as its cdrom
3) Log into VM
4) Check readable cdrom
"""
def
_convert_image
():
source
=
params
[
'images'
].
split
()[
0
]
target
=
params
[
'convert_target'
]
source_params
=
params
.
object_params
(
source
)
target_params
=
params
.
object_params
(
target
)
source_image
=
qemu_storage
.
QemuImg
(
source_params
,
None
,
source
)
# Convert source to target
fail_on
((
process
.
CmdError
,))(
source_image
.
convert
)(
target_params
,
data_dir
.
get_data_dir
())
_convert_image
()
vm
=
img_utils
.
boot_vm_with_images
(
test
,
params
,
env
,
(
params
[
'convert_target'
],))
session
=
vm
.
wait_for_login
(
timeout
=
params
.
get_numeric
(
"login_timeout"
,
360
))
cdroms
=
utils_misc
.
wait_for
(
lambda
:
(
utils_test
.
get_readable_cdroms
(
params
,
session
)),
timeout
=
params
.
get_numeric
(
"timeout"
,
10
)
)
session
.
close
()
if
not
cdroms
:
test
.
fail
(
"None readable cdrom found in vm."
)
qemu/tests/cfg/remote_readonly_storage.cfg
0 → 100644
浏览文件 @
67c4dfbe
# Network storage backends:
# libcurl
# The following testing scenarios are covered:
# - boot_with_readonly_image
# boot vm with an iso image from https server
# - access_with_qemu_info
# access image with qemu-img info
# - cookie_with_secret_object
# check cookie data in tcpdump output
- remote_readonly_storage:
only libcurl
virt_test_type = qemu
start_vm = 'no'
# cd1 is the libcurl iso image
remote_image_tag = 'cd1'
cdroms = "${remote_image_tag}"
cdrom_cd1 = Fedora-Server-dvd-x86_64-30-1.2.iso
image_format_cd1 = 'raw'
curl_server_cd1 = archives.fedoraproject.org
curl_protocol_cd1 = https
curl_path_cd1 = pub/archive/fedora/linux/releases/30/Server/x86_64/iso/Fedora-Server-dvd-x86_64-30-1.2.iso
curl_sslverify_cd1 = ''
curl_username_cd1 = ''
curl_password_cd1 = ''
curl_cookie_secret_cd1 = ''
curl_timeout_cd1 = 30
variants:
- cookie_with_secret_object:
only Linux
type = curl_cookie_with_secret
tcpdump_cmd = 'tcpdump -U -c 5 -A host {server} -w {dump_file} &'
curl_protocol_cd1 = http
curl_cookie_secret_cd1 = 'curl_cookie_data=redhat'
- boot_with_readonly_image:
only Linux
type = boot_with_remote_readonly_image
kill_vm = 'yes'
# stg0 is the local image, where VM starts
convert_target = 'stg0'
bootindex_stg0 = 0
image_name_stg0 = images/stg0
images += ' ${convert_target}'
enable_curl_stg0 = 'no'
storage_type_stg0 ='filesystem'
remove_image_stg0 = 'yes'
image_readonly_stg0 = 'no'
- access_with_qemu_info:
type = remote_image_qemu_info_access
ascii_symbol = '%5f'
replace_symbol = '_'
qemu/tests/curl_cookie_with_secret.py
0 → 100644
浏览文件 @
67c4dfbe
import
os
import
signal
import
logging
from
virttest
import
utils_misc
from
virttest
import
qemu_storage
from
virttest
import
error_context
from
avocado.utils
import
process
@
error_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
1) Start tcpdump to capture the request
2) Access libcurl image by qemu-img
3) Wait till tcpdump finished
4) tcpdump should catch the cookie data
:param test: QEMU test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
def
_get_tcpdump_pid
(
dump_file
):
cmd
=
(
"ps -ef|grep tcpdump|grep %s|grep -v grep|awk '{print $2}'"
%
dump_file
)
return
process
.
system_output
(
cmd
,
shell
=
True
,
ignore_status
=
True
).
strip
()
def
_wait_for_tcpdump_done
(
dump_file
):
response_timeout
=
params
.
get_numeric
(
'response_timeout'
,
10
)
if
not
utils_misc
.
wait_for
(
lambda
:
not
_get_tcpdump_pid
(
dump_file
),
response_timeout
,
0
,
1
):
test
.
fail
(
'tcpdump is running unexpectedly'
)
def
_cleanup
(
dump_file
):
if
os
.
path
.
exists
(
dump_file
):
os
.
unlink
(
dump_file
)
pid
=
_get_tcpdump_pid
(
dump_file
)
if
pid
:
os
.
kill
(
int
(
pid
),
signal
.
SIGKILL
)
tag
=
params
[
'remote_image_tag'
]
img_params
=
params
.
object_params
(
tag
)
img_obj
=
qemu_storage
.
QemuImg
(
img_params
,
None
,
tag
)
dump_file
=
utils_misc
.
generate_tmp_file_name
(
'%s_access_tcpdump'
%
tag
,
'out'
)
logging
.
info
(
'start tcpdump, save packets in %s'
%
dump_file
)
process
.
system
(
params
[
'tcpdump_cmd'
].
format
(
server
=
img_params
[
'curl_server'
],
dump_file
=
dump_file
),
shell
=
True
,
ignore_status
=
True
,
ignore_bg_processes
=
True
)
try
:
img_obj
.
info
()
_wait_for_tcpdump_done
(
dump_file
)
with
open
(
dump_file
,
'rb'
)
as
fd
:
for
line
in
fd
:
line
=
line
.
decode
(
'utf-8'
,
'ignore'
)
if
'Cookie: %s'
%
img_params
[
'curl_cookie_secret'
]
in
line
:
logging
.
info
(
'get "%s" from "%s"'
%
(
img_params
[
'curl_cookie_secret'
],
line
))
break
else
:
test
.
fail
(
'Failed to get cookie data from tcpdump output'
)
finally
:
_cleanup
(
dump_file
)
qemu/tests/remote_image_qemu_info_access.py
0 → 100644
浏览文件 @
67c4dfbe
import
logging
from
virttest
import
qemu_storage
from
virttest
import
error_context
@
error_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
1) Access remote image by qemu-img info
2) Check url in output for libcurl backend
3) Replace '_' with '%5f' in image name,
access image
4) Check url in output for libcurl backend
:param test: QEMU test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
img_params
=
params
.
object_params
(
params
[
'remote_image_tag'
])
image_name_list
=
[
img_params
[
'curl_path'
],
img_params
[
'curl_path'
].
replace
(
params
[
'replace_symbol'
],
params
[
'ascii_symbol'
])
]
for
image_name
in
image_name_list
:
img_params
[
'curl_path'
]
=
image_name
img_obj
=
qemu_storage
.
QemuImg
(
img_params
,
None
,
params
[
'remote_image_tag'
])
logging
.
info
(
'Access image: %s'
%
img_obj
.
image_filename
)
out
=
img_obj
.
info
()
if
img_obj
.
image_filename
not
in
out
:
test
.
fail
(
'Failed to get url(%s) from output(%s)'
%
(
img_obj
.
image_filename
,
out
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录