Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
e2911b41
A
avocado
项目概览
openeuler
/
avocado
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
avocado
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e2911b41
编写于
6月 09, 2014
作者:
R
Rudá Moura
提交者:
Rudá Moura
6月 09, 2014
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #94 from avocado-framework/messages
Messages
上级
7df278b5
ad0c1d08
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
77 addition
and
12 deletion
+77
-12
avocado/job.py
avocado/job.py
+2
-3
avocado/plugins/vm.py
avocado/plugins/vm.py
+21
-9
selftests/all/functional/avocado/basic_tests.py
selftests/all/functional/avocado/basic_tests.py
+54
-0
未找到文件。
avocado/job.py
浏览文件 @
e2911b41
...
...
@@ -222,11 +222,10 @@ class Job(object):
self
.
status
=
'PASS'
# Let's clean up test artifacts
if
self
.
args
is
not
None
:
if
self
.
args
.
archive
:
archive
.
create_zip
(
self
.
debugdir
,
self
.
debugdir
)
if
not
self
.
args
.
keep_tmp_files
:
data_dir
.
clean_tmp_files
()
if
self
.
args
.
archive
:
name
=
os
.
path
.
basename
(
self
.
debugdir
)
archive
.
create_zip
(
name
,
self
.
debugdir
)
tests_status
=
not
bool
(
failures
)
if
tests_status
:
...
...
avocado/plugins/vm.py
浏览文件 @
e2911b41
...
...
@@ -52,7 +52,12 @@ class VMTestRunner(TestRunner):
"""
avocado_cmd
=
'avocado --json run --archive "%s"'
%
urls
stdout
=
self
.
result
.
vm
.
remote
.
run
(
avocado_cmd
)
try
:
results
=
json
.
loads
(
stdout
)
except
Exception
,
details
:
raise
ValueError
(
'Error loading JSON '
'(full output below): %s
\n
"""
\n
%s
\n
"""'
%
(
details
,
stdout
))
return
results
def
run
(
self
,
params_list
):
...
...
@@ -74,13 +79,14 @@ class VMTestRunner(TestRunner):
test
=
Test
(
name
=
tst
[
'test'
],
time
=
tst
[
'time'
],
status
=
tst
[
'status'
])
self
.
result
.
start_test
(
test
)
self
.
result
.
check_test
(
test
)
if
not
status
.
mapping
[
test
.
status
]:
failures
.
append
(
test
.
tagged_name
)
self
.
result
.
end_tests
()
local_log_dir
=
os
.
path
.
dirname
(
self
.
result
.
stream
.
debuglog
)
zip_filename
=
os
.
path
.
basename
(
remote_log_dir
)
+
'.zip'
zip_path_filename
=
os
.
path
.
join
(
local_log_dir
,
zip_filename
)
zip_filename
=
remote_log_dir
+
'.zip'
zip_path_filename
=
os
.
path
.
join
(
local_log_dir
,
os
.
path
.
basename
(
zip_filename
)
)
self
.
result
.
vm
.
remote
.
receive_files
(
local_log_dir
,
zip_filename
)
archive
.
uncompress_zip
(
zip_path_filename
,
local_log_dir
)
...
...
@@ -115,13 +121,19 @@ class VMTestResult(TestResult):
def
setup
(
self
):
if
self
.
args
.
vm_domain
is
None
:
self
.
stream
.
error
(
'Please, set Virtual Machine Domain with option --vm-domain.'
)
raise
exceptions
.
TestSetupFail
()
e_msg
=
(
'Please set Virtual Machine Domain with option '
'--vm-domain.'
)
self
.
stream
.
error
(
e_msg
)
raise
exceptions
.
TestSetupFail
(
e_msg
)
if
self
.
args
.
vm_hostname
is
None
:
self
.
stream
.
error
(
'Please, set Virtual Machine hostname with option --vm-hostname.'
)
raise
exceptions
.
TestSetupFail
()
self
.
stream
.
log_header
(
"REMOTE TESTS: Virtual Machine Domain '%s'"
%
self
.
args
.
vm_domain
)
self
.
stream
.
log_header
(
"REMOTE TESTS: Host login '%s@%s'"
%
(
self
.
args
.
vm_username
,
self
.
args
.
vm_hostname
))
e_msg
=
(
'Please set Virtual Machine hostname with option '
'--vm-hostname.'
)
self
.
stream
.
error
(
e_msg
)
raise
exceptions
.
TestSetupFail
(
e_msg
)
self
.
stream
.
log_header
(
"REMOTE TESTS: Virtual Machine Domain '%s'"
%
self
.
args
.
vm_domain
)
self
.
stream
.
log_header
(
"REMOTE TESTS: Host login '%s@%s'"
%
(
self
.
args
.
vm_username
,
self
.
args
.
vm_hostname
))
self
.
vm
=
virt
.
vm_connect
(
self
.
args
.
vm_domain
,
self
.
args
.
vm_hypervisor_uri
)
if
self
.
vm
is
None
:
...
...
selftests/all/functional/avocado/basic_tests.py
浏览文件 @
e2911b41
...
...
@@ -14,6 +14,7 @@
# Copyright: Red Hat Inc. 2013-2014
# Author: Lucas Meneghel Rodrigues <lmr@redhat.com>
import
json
import
unittest
import
os
import
shutil
...
...
@@ -205,5 +206,58 @@ class PluginsXunitTest(PluginsSysinfoTest):
self
.
run_and_check
(
'"sleeptest failtest skiptest errortest"'
,
1
,
4
,
1
,
1
,
1
)
class
ParseJSONError
(
Exception
):
pass
class
PluginsJSONTest
(
PluginsSysinfoTest
):
def
run_and_check
(
self
,
testname
,
e_rc
,
e_ntests
,
e_nerrors
,
e_nfailures
,
e_nskip
):
os
.
chdir
(
basedir
)
cmd_line
=
'./scripts/avocado --json run --archive %s'
%
testname
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
json_output
=
result
.
stdout
self
.
assertEqual
(
result
.
exit_status
,
e_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
e_rc
,
result
))
try
:
json_data
=
json
.
loads
(
json_output
)
except
Exception
,
detail
:
raise
ParseJSONError
(
"Failed to parse content: %s
\n
%s"
%
(
detail
,
json_output
))
self
.
assertTrue
(
json_data
,
"Empty JSON result:
\n
%s"
%
json_output
)
self
.
assertIsInstance
(
json_data
[
'tests'
],
list
,
"JSON result lacks 'tests' list"
)
n_tests
=
len
(
json_data
[
'tests'
])
self
.
assertEqual
(
n_tests
,
e_ntests
,
"Different number of expected tests"
)
n_errors
=
json_data
[
'errors'
]
self
.
assertEqual
(
n_errors
,
e_nerrors
,
"Different number of expected tests"
)
n_failures
=
json_data
[
'failures'
]
self
.
assertEqual
(
n_failures
,
e_nfailures
,
"Different number of expected tests"
)
n_skip
=
json_data
[
'skip'
]
self
.
assertEqual
(
n_skip
,
e_nskip
,
"Different number of skipped tests"
)
def
test_json_plugin_sleeptest
(
self
):
self
.
run_and_check
(
'sleeptest'
,
0
,
1
,
0
,
0
,
0
)
def
test_json_plugin_failtest
(
self
):
self
.
run_and_check
(
'failtest'
,
1
,
1
,
0
,
1
,
0
)
def
test_json_plugin_skiptest
(
self
):
self
.
run_and_check
(
'skiptest'
,
0
,
1
,
0
,
0
,
1
)
def
test_json_plugin_errortest
(
self
):
self
.
run_and_check
(
'errortest'
,
1
,
1
,
1
,
0
,
0
)
def
test_json_plugin_mixedtest
(
self
):
self
.
run_and_check
(
'"sleeptest failtest skiptest errortest"'
,
1
,
4
,
1
,
1
,
1
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录