Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
22c42ecd
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,发现更多精彩内容 >>
提交
22c42ecd
编写于
3月 11, 2014
作者:
Y
Yiqiao Pu
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #26 from yumingfei/ksm
Generic.tests: Add test module for ksm services.
上级
6b580804
f435d0f5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
146 addition
and
0 deletion
+146
-0
generic/tests/cfg/ksm_services.cfg
generic/tests/cfg/ksm_services.cfg
+17
-0
generic/tests/ksm_services.py
generic/tests/ksm_services.py
+129
-0
未找到文件。
generic/tests/cfg/ksm_services.cfg
0 → 100644
浏览文件 @
22c42ecd
- ksm_services:
virt_test_type = qemu libvirt
type = ksm_services
vms = ""
main_vm = ""
setup_ksm = "yes"
variants:
- set_params:
ksm_ref = "set_params"
# To avoid same with default, use delta
ksm_run = 1
ksm_value_delta = "10"
- ksmtuned:
ksm_ref = "ksmtuned"
# Use a new path for ksmtuned log
ksmtuned_log_path = "/var/log/test_ksmtuned"
ksmtuned_debug = 1
generic/tests/ksm_services.py
0 → 100644
浏览文件 @
22c42ecd
import
re
import
os
import
logging
import
shutil
from
autotest.client.shared
import
error
from
virttest
import
utils_misc
def
test_setting_params
(
ksmctler
,
params
):
"""
Test setting writable params.
1.Get default values and create new values according delta
2.Set new values
3.Verify result
4.Recover default values
"""
value_delta
=
int
(
params
.
get
(
"ksm_value_delta"
,
10
))
ksm_run
=
int
(
params
.
get
(
"ksm_run"
,
1
))
writable_features
=
ksmctler
.
get_writable_features
()
# Get default value of ksm parameters
default_values
=
{}
for
key
in
writable_features
:
default_values
[
key
]
=
int
(
ksmctler
.
get_ksm_feature
(
key
))
# New value to be set
set_values
=
{}
# Do not support testing of some parameters right now.
# TODO: test parameters in black list
black_list
=
[
"merge_across_nodes"
]
for
key
in
default_values
.
keys
():
if
key
==
"run"
:
set_values
[
key
]
=
ksm_run
elif
key
in
black_list
:
continue
else
:
set_values
[
key
]
=
default_values
[
key
]
+
value_delta
logging
.
debug
(
"
\n
Default parameters:%s
\n
"
"Set parameters:%s"
,
default_values
,
set_values
)
try
:
# Setting new value
try
:
ksmctler
.
set_ksm_feature
(
set_values
)
# Restart ksm service to check
ksmctler
.
restart_ksm
()
except
error
.
CmdError
,
detail
:
raise
error
.
TestFail
(
"Set parameters failed:%s"
%
str
(
detail
))
fail_flag
=
0
for
key
,
value
in
set_values
.
items
():
if
ksmctler
.
get_ksm_feature
(
key
)
!=
str
(
value
):
logging
.
error
(
"Set value do not match:%s - %s"
,
key
,
value
)
fail_flag
=
1
if
fail_flag
:
raise
error
.
TestFail
(
"Set writable parameters failed."
)
finally
:
logging
.
debug
(
"Recover parameters' default value..."
)
ksmctler
.
set_ksm_feature
(
default_values
)
def
test_ksmtuned_service
(
ksmctler
,
params
):
"""
Test if ksmtuned service works well.
1.Set debug options for ksmtuned
2.Check if debug log is created
"""
def
backup_config
(
ksmtuned_conf
):
shutil
.
copy
(
ksmtuned_conf
,
"%s.bak"
%
ksmtuned_conf
)
return
"%s.bak"
%
ksmtuned_conf
def
debug_ksmtuned
(
log_path
,
debug
,
ksmtuned_conf
=
"/etc/ksmtuned.conf"
):
try
:
fd
=
open
(
ksmtuned_conf
,
'r'
)
contents
=
fd
.
readlines
()
fd
.
close
()
except
IOError
,
e
:
raise
error
.
TestFail
(
"Open ksmtuned config file failed:%s"
%
e
)
new_contents
=
[]
for
con
in
contents
:
if
re
.
match
(
"^.*LOGFILE.*"
,
con
):
con
=
"LOGFILE=%s
\n
"
%
log_path
elif
re
.
match
(
"^.*DEBUG.*"
,
con
):
con
=
"DEBUG=%s
\n
"
%
debug
new_contents
.
append
(
con
)
logging
.
debug
(
"
\n
ksmtuned configures:
\n
%s"
,
new_contents
)
try
:
fd
=
open
(
ksmtuned_conf
,
'w'
)
fd
.
writelines
(
new_contents
)
fd
.
close
()
except
IOError
,
e
:
raise
error
.
TestFail
(
"Write options to config file failed:%s"
%
e
)
log_path
=
params
.
get
(
"ksmtuned_log_path"
,
"/var/log/test_ksmtuned"
)
debug
=
params
.
get
(
"ksmtuned_debug"
,
1
)
if
not
ksmctler
.
get_ksmtuned_pid
():
ksmctler
.
start_ksmtuned
()
# Configure file of ksmtuned: /etc/ksmtuned.conf
ksmtuned_conf
=
"/etc/ksmtuned.conf"
try
:
ksmtuned_backup
=
backup_config
(
ksmtuned_conf
)
debug_ksmtuned
(
log_path
,
debug
)
ksmctler
.
restart_ksmtuned
()
if
not
os
.
path
.
isfile
(
log_path
):
raise
error
.
TestFail
(
"Debug file of ksmtuned is not created."
)
finally
:
try
:
shutil
.
move
(
ksmtuned_backup
,
ksmtuned_conf
)
except
OSError
:
pass
try
:
os
.
remove
(
log_path
)
except
OSError
:
pass
# file do not exists
def
run
(
test
,
params
,
env
):
"""
Simple test for ksm services.
"""
ksm_ref
=
params
.
get
(
"ksm_ref"
)
ksmctler
=
utils_misc
.
KSMController
()
if
ksm_ref
==
"set_params"
:
test_setting_params
(
ksmctler
,
params
)
elif
ksm_ref
==
"ksmtuned"
:
test_ksmtuned_service
(
ksmctler
,
params
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录