Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
a7c9ac65
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,发现更多精彩内容 >>
未验证
提交
a7c9ac65
编写于
11月 30, 2018
作者:
C
Caio Carrara
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'clebergnu/lv_utils_selftest'
Signed-off-by:
N
Caio Carrara
<
ccarrara@redhat.com
>
上级
1cedd550
952ecd24
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
40 deletion
+37
-40
selftests/functional/test_lv_utils.py
selftests/functional/test_lv_utils.py
+37
-40
未找到文件。
selftests/functional/test_lv_utils.py
浏览文件 @
a7c9ac65
...
...
@@ -3,18 +3,20 @@ avocado.utils.lv_utils selftests
:author: Lukas Doktor <ldoktor@redhat.com>
:copyright: 2016 Red Hat, Inc
"""
from
__future__
import
print_function
import
glob
import
os
import
sys
import
shutil
import
tempfile
import
time
import
unittest
from
six.moves
import
xrange
as
range
from
avocado.utils
import
process
,
lv_utils
from
avocado.utils
import
process
from
avocado.utils
import
lv_utils
from
avocado.utils
import
linux_modules
class
LVUtilsTest
(
unittest
.
TestCase
):
...
...
@@ -38,43 +40,6 @@ class LVUtilsTest(unittest.TestCase):
for
vg_name
in
self
.
vgs
:
lv_utils
.
vg_remove
(
vg_name
)
@
unittest
.
skipIf
(
sys
.
platform
.
startswith
(
'darwin'
),
'macOS does not support LVM'
)
@
unittest
.
skipIf
(
process
.
system
(
"modinfo scsi_debug"
,
shell
=
True
,
ignore_status
=
True
),
"Kernel mod 'scsi_debug' not available."
)
@
unittest
.
skipIf
(
process
.
system
(
"lsmod | grep -q scsi_debug; [ $? -ne 0 ]"
,
shell
=
True
,
ignore_status
=
True
),
"Kernel mod 'scsi_debug' is already loaded."
)
def
test_get_diskspace
(
self
):
"""
Use scsi_debug device to check disk size
"""
pre
=
glob
.
glob
(
"/dev/sd*"
)
try
:
process
.
system
(
"modprobe scsi_debug"
,
sudo
=
True
)
disks
=
set
(
glob
.
glob
(
"/dev/sd*"
)).
difference
(
pre
)
self
.
assertEqual
(
len
(
disks
),
1
,
"pre: %s
\n
post: %s"
%
(
disks
,
glob
.
glob
(
"/dev/sd*"
)))
disk
=
disks
.
pop
()
self
.
assertEqual
(
lv_utils
.
get_diskspace
(
disk
),
"8388608"
)
except
BaseException
:
for
_
in
range
(
10
):
res
=
process
.
run
(
"rmmod scsi_debug"
,
ignore_status
=
True
,
sudo
=
True
)
if
not
res
.
exit_status
:
print
(
"scsi_debug removed"
)
break
else
:
print
(
"Fail to remove scsi_debug: %s"
%
res
)
for
_
in
range
(
10
):
res
=
process
.
run
(
"rmmod scsi_debug"
,
ignore_status
=
True
,
sudo
=
True
)
if
not
res
.
exit_status
:
break
else
:
self
.
fail
(
"Fail to remove scsi_debug after testing: %s"
%
res
)
@
unittest
.
skipIf
(
sys
.
platform
.
startswith
(
'darwin'
),
'macOS does not support LVM'
)
@
unittest
.
skipIf
(
process
.
system
(
"vgs --all | grep -q avocado_testing_vg_"
...
...
@@ -141,7 +106,39 @@ class LVUtilsTest(unittest.TestCase):
vg_name
,
loop_device
)
except
BaseException
as
details
:
print
(
"Fail to cleanup vg_ramdisk: %s"
%
details
)
raise
class
DiskSpace
(
unittest
.
TestCase
):
@
unittest
.
skipIf
(
process
.
system
(
"modinfo scsi_debug"
,
shell
=
True
,
ignore_status
=
True
),
"Kernel mod 'scsi_debug' not available."
)
@
unittest
.
skipIf
(
linux_modules
.
module_is_loaded
(
"scsi_debug"
),
"Kernel mod 'scsi_debug' is already loaded."
)
@
unittest
.
skipIf
(
sys
.
platform
.
startswith
(
'darwin'
),
'macOS does not support scsi_debug module'
)
@
unittest
.
skipIf
(
not
process
.
can_sudo
(),
"This test requires root or "
"passwordless sudo configured."
)
def
test_get_diskspace
(
self
):
"""
Use scsi_debug device to check disk size
"""
pre
=
glob
.
glob
(
"/dev/sd*"
)
process
.
system
(
"modprobe scsi_debug"
,
sudo
=
True
)
disks
=
set
(
glob
.
glob
(
"/dev/sd*"
)).
difference
(
pre
)
self
.
assertEqual
(
len
(
disks
),
1
,
"pre: %s
\n
post: %s"
%
(
disks
,
glob
.
glob
(
"/dev/sd*"
)))
disk
=
disks
.
pop
()
self
.
assertEqual
(
lv_utils
.
get_diskspace
(
disk
),
"8388608"
)
def
tearDown
(
self
):
for
_
in
range
(
10
):
if
process
.
run
(
"modprobe -r scsi_debug"
,
ignore_status
=
True
,
sudo
=
True
).
exit_status
==
0
:
return
time
.
sleep
(
0.05
)
raise
RuntimeError
(
"Failed to remove scsi_debug after testing"
)
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录