Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
40cdd82e
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,发现更多精彩内容 >>
提交
40cdd82e
编写于
7月 17, 2013
作者:
C
Chris Evich
提交者:
Lucas Meneghel Rodrigues
9月 02, 2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
virt-sandbox: Implement date test
Signed-off-by:
N
Chris Evich
<
cevich@redhat.com
>
上级
3dad115d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
101 addition
and
16 deletion
+101
-16
sandbox/tests/cfg/sandbox_date.cfg
sandbox/tests/cfg/sandbox_date.cfg
+0
-3
sandbox/tests/cfg/virt_sandbox_date.cfg
sandbox/tests/cfg/virt_sandbox_date.cfg
+25
-0
sandbox/tests/src/sandbox_date.py
sandbox/tests/src/sandbox_date.py
+0
-13
sandbox/tests/src/virt_sandbox_date.py
sandbox/tests/src/virt_sandbox_date.py
+76
-0
未找到文件。
sandbox/tests/cfg/sandbox_date.cfg
已删除
100644 → 0
浏览文件 @
3dad115d
- sandbox_date:
type = sandbox_date
virt_test_type = sandbox
sandbox/tests/cfg/virt_sandbox_date.cfg
0 → 100644
浏览文件 @
40cdd82e
- virt_sandbox_date:
type = virt_sandbox_date
virt_test_type = sandbox
status_error = 'no'
# Common key used by all TestSandboxes subclasses
sandbox_command = '/usr/bin/date +%s.%N'
variants:
- positive_testing:
variants:
- one_sandbox:
# Default parameters at work here
- two_sandboxes:
# Can override the default
sandbox_count = 2
- three_sandboxes:
# Can override TestSandboxes subclass instance param
sandbox_count_TestSimpleSandboxes = 3
- negative_testing:
status_error = 'yes'
variants:
- broken_sandbox:
# The command can be changed per-class also
sandbox_command_TestSimpleSandboxes = '/bin/false'
- broken_date:
sandbox_command = '/usr/bin/date +9%s.%N'
sandbox/tests/src/sandbox_date.py
已删除
100644 → 0
浏览文件 @
3dad115d
import
logging
,
datetime
from
autotest.client.shared
import
error
,
utils
def
run_sandbox_date
(
test
,
params
,
env
):
cmdresult
=
utils
.
run
(
'virt-sandbox -c lxc:/// -- /usr/bin/date +%s'
)
test_dt
=
datetime
.
datetime
.
fromtimestamp
(
float
(
cmdresult
.
stdout
))
local_dt
=
datetime
.
datetime
.
now
()
delta
=
local_dt
-
test_dt
if
delta
.
days
<
0
:
delta
=
test_dt
-
local_dt
tenseconds
=
datetime
.
timedelta
(
seconds
=
5
)
if
delta
>
tenseconds
:
raise
error
.
TestFail
(
"Time difference greater than %s"
%
tenseconds
)
sandbox/tests/src/virt_sandbox_date.py
0 → 100644
浏览文件 @
40cdd82e
"""
Simple test that executes date command in a sanbox and verifies it is correct
"""
import
datetime
from
autotest.client.shared
import
error
from
virttest.sandbox
import
make_sandboxes
def
verify_datetime
(
start_time
,
stop_time
,
result_list
):
"""
Return the number of sandboxes which reported incorrect date
"""
bad_dt
=
0
for
results
in
result_list
:
# list of aggregate managers
for
result
in
results
:
# list of sandbox stdouts
try
:
test_dt
=
datetime
.
datetime
.
fromtimestamp
(
float
(
result
.
strip
()))
except
(
TypeError
,
ValueError
):
bad_dt
+=
1
else
:
if
test_dt
>=
start_time
and
test_dt
<=
stop_time
:
continue
# good result, check next
else
:
bad_dt
+=
1
return
bad_dt
def
some_failed
(
failed_list
):
"""
Return True if any single sandbox reported a non-zero exit code
"""
for
failed
in
failed_list
:
# list of sandboxes w/ non-zero exit codes
if
failed
>
0
:
return
True
return
False
def
run_virt_sandbox_date
(
test
,
params
,
env
):
"""
Executes date command in a sanbox and verifies it is correct
1) Gather parameters
2) Create configured sandbox aggregater(s)
3) Run and stop all sandboxes in all agregators
4) Handle results
"""
# Record time for comparison when finished
start_time
=
datetime
.
datetime
.
now
()
status_error
=
bool
(
'yes'
==
params
.
get
(
'status_error'
,
'no'
))
# list of sandbox agregate managers (containing list of sandboxes)
sb_agg_list
=
make_sandboxes
(
params
,
env
)
# Number of sandboxes for each aggregate type
agg_count
=
[
agg
.
count
for
agg
in
sb_agg_list
]
# Run all sandboxes until timeout or finished w/ output
# store list of stdout's for each sandbox in each agregate type
result_list
=
[
agg
.
results
()
for
agg
in
sb_agg_list
]
# Timeouts throw SandboxException, if normal exit, record ending time
stop_time
=
datetime
.
datetime
.
now
()
# Number of sandboxs with non-zero exit codes for each aggregate type
failed_list
=
[
agg
.
are_failed
()
for
agg
in
sb_agg_list
]
# handle results
if
status_error
:
# Negative test
if
not
some_failed
(
failed_list
)
and
verify_datetime
(
start_time
,
stop_time
,
result_list
)
<
1
:
raise
error
.
TestFail
(
"Error test failed on only %s of %s sandboxes"
%
(
failed_list
,
agg_count
))
else
:
# Positive test
if
some_failed
(
failed_list
):
raise
error
.
TestFail
(
"Some sandboxes had non-zero exit codes"
)
if
verify_datetime
(
start_time
,
stop_time
,
result_list
)
>
0
:
raise
error
.
TestFail
(
"Some sandboxes reported invalid date/time"
)
# Otherwise test passed
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录