Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
41f8d0d9
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
41f8d0d9
编写于
3月 09, 2016
作者:
C
Cleber Rosa
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'apahim/bug_replay_externalrunner_v5'
上级
ab10314f
affae25d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
108 addition
and
13 deletion
+108
-13
avocado/core/loader.py
avocado/core/loader.py
+4
-4
avocado/core/replay.py
avocado/core/replay.py
+13
-0
avocado/plugins/replay.py
avocado/plugins/replay.py
+21
-1
selftests/functional/test_replay_basic.py
selftests/functional/test_replay_basic.py
+5
-8
selftests/functional/test_replay_external_runner.py
selftests/functional/test_replay_external_runner.py
+65
-0
未找到文件。
avocado/core/loader.py
浏览文件 @
41f8d0d9
...
...
@@ -378,8 +378,8 @@ def add_loader_options(parser):
'where those files are located, use "test" here and '
'specify the test directory with the option '
'"--external-runner-testdir". Defaults to "%(default)s"'
)
arggrp
.
add_argument
(
'--external-runner-chdir'
,
default
=
'off'
,
choices
=
(
'runner'
,
'test'
,
'off'
),
arggrp
.
add_argument
(
'--external-runner-chdir'
,
default
=
None
,
choices
=
(
'runner'
,
'test'
),
help
=
chdir_help
)
arggrp
.
add_argument
(
'--external-runner-testdir'
,
metavar
=
'DIRECTORY'
,
...
...
@@ -725,7 +725,7 @@ class ExternalLoader(TestLoader):
@
staticmethod
def
_process_external_runner
(
args
,
runner
):
""" Enables the external_runner when asked for """
chdir
=
getattr
(
args
,
'external_runner_chdir'
,
'off'
)
chdir
=
getattr
(
args
,
'external_runner_chdir'
,
None
)
test_dir
=
getattr
(
args
,
'external_runner_testdir'
,
None
)
if
runner
:
...
...
@@ -752,7 +752,7 @@ class ExternalLoader(TestLoader):
[
'runner'
,
'chdir'
,
'test_dir'
])
return
cls_external_runner
(
runner
,
chdir
,
test_dir
)
elif
chdir
!=
"off"
:
elif
chdir
:
msg
=
(
'Option "--external-runner-chdir" requires '
'"--external-runner" to be set.'
)
raise
LoaderError
(
msg
)
...
...
avocado/core/replay.py
浏览文件 @
41f8d0d9
...
...
@@ -36,6 +36,7 @@ def record(args, logdir, mux, urls=None):
path_urls
=
os
.
path
.
join
(
replay_dir
,
'urls'
)
path_mux
=
os
.
path
.
join
(
replay_dir
,
'multiplex'
)
path_pwd
=
os
.
path
.
join
(
replay_dir
,
'pwd'
)
path_args
=
os
.
path
.
join
(
replay_dir
,
'args'
)
if
urls
:
with
open
(
path_urls
,
'w'
)
as
f
:
...
...
@@ -50,6 +51,9 @@ def record(args, logdir, mux, urls=None):
with
open
(
path_pwd
,
'w'
)
as
f
:
f
.
write
(
'%s'
%
os
.
getcwd
())
with
open
(
path_args
,
'w'
)
as
f
:
pickle
.
dump
(
args
.
__dict__
,
f
,
pickle
.
HIGHEST_PROTOCOL
)
def
retrieve_pwd
(
resultsdir
):
recorded_pwd
=
os
.
path
.
join
(
resultsdir
,
"replay"
,
"pwd"
)
...
...
@@ -99,6 +103,15 @@ def retrieve_replay_map(resultsdir, replay_filter):
return
replay_map
def
retrieve_args
(
resultsdir
):
pkl_path
=
os
.
path
.
join
(
resultsdir
,
'replay'
,
'args'
)
if
not
os
.
path
.
exists
(
pkl_path
):
return
None
with
open
(
pkl_path
,
'r'
)
as
f
:
return
pickle
.
load
(
f
)
def
get_resultsdir
(
logdir
,
jobid
):
matches
=
0
short_jobid
=
jobid
[:
7
]
...
...
avocado/plugins/replay.py
浏览文件 @
41f8d0d9
...
...
@@ -129,9 +129,29 @@ class Replay(CLI):
%
(
args
.
replay_jobid
,
resultsdir
))
log
.
error
(
msg
)
sys
.
exit
(
exit_codes
.
AVOCADO_JOB_FAIL
)
setattr
(
args
,
'replay_sourcejob'
,
sourcejob
)
replay_args
=
replay
.
retrieve_args
(
resultsdir
)
whitelist
=
[
'loaders'
,
'external_runner'
,
'external_runner_testdir'
,
'external_runner_chdir'
]
if
replay_args
is
None
:
log
.
warn
(
'Source job args data not found. These options will not '
'be loaded in this replay job: %s'
,
', '
.
join
(
whitelist
))
else
:
for
option
in
whitelist
:
optvalue
=
getattr
(
args
,
option
,
None
)
if
optvalue
:
log
.
warn
(
"Overriding the replay %s with the --%s value "
"given on the command line."
,
option
.
replace
(
'_'
,
'-'
),
option
.
replace
(
'_'
,
'-'
))
else
:
setattr
(
args
,
option
,
replay_args
[
option
])
# Keeping this for compatibility.
# TODO: Use replay_args['url'] at some point in the future.
if
getattr
(
args
,
'url'
,
None
):
log
.
warn
(
'Overriding the replay urls with urls provided in '
'command line.'
)
...
...
selftests/functional/test_replay.py
→
selftests/functional/test_replay
_basic
.py
浏览文件 @
41f8d0d9
...
...
@@ -23,13 +23,13 @@ class ReplayTests(unittest.TestCase):
def
setUp
(
self
):
self
.
tmpdir
=
tempfile
.
mkdtemp
(
prefix
=
'avocado_'
+
__name__
)
cmd_line
=
(
'./scripts/avocado run passtest --multiplex '
cmd_line
=
(
'./scripts/avocado run passtest '
'--multiplex '
'examples/tests/sleeptest.py.data/sleeptest.yaml '
'--job-results-dir %s --sysinfo=off'
%
'--job-results-dir %s --sysinfo=off
--json -
'
%
self
.
tmpdir
)
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
self
.
run_and_check
(
cmd_line
,
expected_rc
)
self
.
jobdir
=
''
.
join
(
glob
.
glob
(
os
.
path
.
join
(
self
.
tmpdir
,
'job-*'
)))
idfile
=
''
.
join
(
os
.
path
.
join
(
self
.
jobdir
,
'id'
))
with
open
(
idfile
,
'r'
)
as
f
:
...
...
@@ -51,7 +51,7 @@ class ReplayTests(unittest.TestCase):
self
.
run_and_check
(
cmd_line
,
expected_rc
)
def
test_run_replay_data
(
self
):
file_list
=
[
'multiplex'
,
'config'
,
'urls'
,
'pwd'
]
file_list
=
[
'multiplex'
,
'config'
,
'urls'
,
'pwd'
,
'args'
]
for
filename
in
file_list
:
path
=
os
.
path
.
join
(
self
.
jobdir
,
'replay'
,
filename
)
self
.
assertTrue
(
glob
.
glob
(
path
))
...
...
@@ -106,10 +106,7 @@ class ReplayTests(unittest.TestCase):
'--sysinfo=off'
%
(
self
.
jobid
,
self
.
tmpdir
,
self
.
jobdir
))
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
result
=
self
.
run_and_check
(
cmd_line
,
expected_rc
)
msg
=
'(1/4) passtest.py:PassTest.test.variant1: SKIP
\n
'
\
'(2/4) passtest.py:PassTest.test.variant2: SKIP
\n
'
\
'(3/4) passtest.py:PassTest.test.variant3: SKIP
\n
'
\
'(4/4) passtest.py:PassTest.test.variant4: SKIP'
msg
=
'RESULTS : PASS 0 | ERROR 0 | FAIL 0 | SKIP 4 | WARN 0 | INTERRUPT 0'
self
.
assertIn
(
msg
,
result
.
stdout
)
def
test_run_replay_remotefail
(
self
):
...
...
selftests/functional/test_replay_external_runner.py
0 → 100644
浏览文件 @
41f8d0d9
#!/usr/bin/env python
import
glob
import
os
import
sys
import
tempfile
import
shutil
if
sys
.
version_info
[:
2
]
==
(
2
,
6
):
import
unittest2
as
unittest
else
:
import
unittest
from
avocado.core
import
exit_codes
from
avocado.utils
import
process
from
avocado.utils
import
script
basedir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'..'
,
'..'
)
basedir
=
os
.
path
.
abspath
(
basedir
)
class
ReplayTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
tmpdir
=
tempfile
.
mkdtemp
(
prefix
=
'avocado_'
+
__name__
)
test
=
script
.
make_script
(
os
.
path
.
join
(
self
.
tmpdir
,
'test'
),
'exit 0'
)
cmd_line
=
(
'./scripts/avocado run %s '
'--multiplex '
'examples/tests/sleeptest.py.data/sleeptest.yaml '
'--external-runner /bin/bash '
'--job-results-dir %s --sysinfo=off --json -'
%
(
test
,
self
.
tmpdir
))
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
self
.
run_and_check
(
cmd_line
,
expected_rc
)
self
.
jobdir
=
''
.
join
(
glob
.
glob
(
os
.
path
.
join
(
self
.
tmpdir
,
'job-*'
)))
idfile
=
''
.
join
(
os
.
path
.
join
(
self
.
jobdir
,
'id'
))
with
open
(
idfile
,
'r'
)
as
f
:
self
.
jobid
=
f
.
read
().
strip
(
'
\n
'
)
def
run_and_check
(
self
,
cmd_line
,
expected_rc
):
os
.
chdir
(
basedir
)
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Command %s did not return rc "
"%d:
\n
%s"
%
(
cmd_line
,
expected_rc
,
result
))
return
result
def
test_run_replay_external_runner
(
self
):
cmd_line
=
(
'./scripts/avocado run --replay %s '
'--external-runner /bin/sh '
'--job-results-dir %s --replay-data-dir %s --sysinfo=off'
%
(
self
.
jobid
,
self
.
tmpdir
,
self
.
jobdir
))
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
result
=
self
.
run_and_check
(
cmd_line
,
expected_rc
)
msg
=
"Overriding the replay external-runner with the "
\
"--external-runner value given on the command line."
self
.
assertIn
(
msg
,
result
.
stderr
)
def
tearDown
(
self
):
shutil
.
rmtree
(
self
.
tmpdir
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录