Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
syscontainer-tools
提交
58cdc83a
S
syscontainer-tools
项目概览
openeuler
/
syscontainer-tools
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
syscontainer-tools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
58cdc83a
编写于
1月 21, 2020
作者:
Z
zhangsong34
提交者:
Grooooot
1月 21, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
isulad-tools: replace lcrd to isulad
Signed-off-by:
N
zhangsong34
<
zhangsong34@huawei.com
>
上级
1b87b173
变更
17
显示空白变更内容
内联
并排
Showing
17 changed file
with
150 addition
and
147 deletion
+150
-147
CHANGELOG
CHANGELOG
+2
-2
container/container.go
container/container.go
+21
-18
hack/install.sh
hack/install.sh
+1
-1
hack/isulad-tools.spec
hack/isulad-tools.spec
+8
-8
hooks/isulad-hooks/README.md
hooks/isulad-hooks/README.md
+4
-4
hooks/isulad-hooks/example/hookspec.json
hooks/isulad-hooks/example/hookspec.json
+3
-3
hooks/isulad-hooks/prestart.go
hooks/isulad-hooks/prestart.go
+1
-1
relabel.go
relabel.go
+2
-2
test/devices_many_test.sh
test/devices_many_test.sh
+17
-17
test/devices_test.sh
test/devices_test.sh
+23
-23
test/main.sh
test/main.sh
+5
-5
test/network_test.sh
test/network_test.sh
+6
-6
test/path_many_test.sh
test/path_many_test.sh
+23
-23
test/path_test.sh
test/path_test.sh
+27
-27
test/route_test.sh
test/route_test.sh
+4
-4
test/tools.sh
test/tools.sh
+1
-1
utils/hooks.go
utils/hooks.go
+2
-2
未找到文件。
CHANGELOG
浏览文件 @
58cdc83a
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
### general
### general
* reorginzed the isulad-tools code (MR: #75)
* reorginzed the isulad-tools code (MR: #75)
* use`isulad-tools` in `isulad-tools_wrapper` instead of `
lcrc
exec` (MR: #76)
* use`isulad-tools` in `isulad-tools_wrapper` instead of `
isula
exec` (MR: #76)
* fix filelock can't lock accross the process issue (MR: #78)
* fix filelock can't lock accross the process issue (MR: #78)
### hooks
### hooks
...
@@ -99,7 +99,7 @@
...
@@ -99,7 +99,7 @@
### isulad-tools
### isulad-tools
* use device-hook instead of "
lcrc
update" to keep resource persistent in container.
* use device-hook instead of "
isula
update" to keep resource persistent in container.
* add syslog support, all log will be written to syslog.
* add syslog support, all log will be written to syslog.
* add "make rpm" support in Makefile.
* add "make rpm" support in Makefile.
...
...
container/container.go
浏览文件 @
58cdc83a
...
@@ -55,23 +55,23 @@ func New(name string) (*Container, error) {
...
@@ -55,23 +55,23 @@ func New(name string) (*Container, error) {
return
nil
,
fmt
.
Errorf
(
"Invalid container name (%s), only %s are allowed"
,
name
,
restrictedNameChars
)
return
nil
,
fmt
.
Errorf
(
"Invalid container name (%s), only %s are allowed"
,
name
,
restrictedNameChars
)
}
}
graphDriverPath
,
err
:=
get
Lcr
dGraphDriverPath
()
graphDriverPath
,
err
:=
get
Isula
dGraphDriverPath
()
var
id
,
storagePath
string
var
id
,
storagePath
string
var
pid
int
var
pid
int
var
spec
*
specs
.
Spec
var
spec
*
specs
.
Spec
storagePath
=
filepath
.
Join
(
graphDriverPath
,
"engines"
,
"lcr"
)
storagePath
=
filepath
.
Join
(
graphDriverPath
,
"engines"
,
"lcr"
)
id
,
err
=
get
Lcr
dContainerID
(
name
)
id
,
err
=
get
Isula
dContainerID
(
name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
pid
,
err
=
get
Lcr
dContainerPid
(
name
)
pid
,
err
=
get
Isula
dContainerPid
(
name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
spec
,
err
=
get
Lcr
dContainerSpec
(
id
)
spec
,
err
=
get
Isula
dContainerSpec
(
id
)
if
err
!=
nil
{
if
err
!=
nil
{
logrus
.
Warnf
(
"fail to get
lcr
d container %v spec: %v"
,
id
,
err
)
logrus
.
Warnf
(
"fail to get
isula
d container %v spec: %v"
,
id
,
err
)
}
}
container
:=
&
Container
{
container
:=
&
Container
{
...
@@ -141,12 +141,15 @@ func (c *Container) Unlock() error {
...
@@ -141,12 +141,15 @@ func (c *Container) Unlock() error {
// GetCgroupPath returns the cgroup-parent segment of the container.
// GetCgroupPath returns the cgroup-parent segment of the container.
// For isulad container, it is a configurable segment.
// For isulad container, it is a configurable segment.
func
(
c
*
Container
)
GetCgroupPath
()
(
string
,
error
)
{
func
(
c
*
Container
)
GetCgroupPath
()
(
string
,
error
)
{
cmd
:=
exec
.
Command
(
"
lcrc
"
,
"inspect"
,
"-f"
,
"{{json .HostConfig.CgroupParent}}"
,
c
.
name
)
cmd
:=
exec
.
Command
(
"
isula
"
,
"inspect"
,
"-f"
,
"{{json .HostConfig.CgroupParent}}"
,
c
.
name
)
out
,
err
:=
cmd
.
CombinedOutput
()
out
,
err
:=
cmd
.
CombinedOutput
()
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"%s: %v"
,
string
(
out
),
err
)
return
""
,
fmt
.
Errorf
(
"%s: %v"
,
string
(
out
),
err
)
}
}
cgroupPath
:=
strings
.
Trim
(
string
(
out
),
"
\n
"
)
cgroupPath
:=
strings
.
Trim
(
string
(
out
),
"
\n
"
)
if
len
(
cgroupPath
)
>=
2
{
cgroupPath
=
cgroupPath
[
1
:
len
(
cgroupPath
)
-
1
]
}
if
cgroupPath
==
""
{
if
cgroupPath
==
""
{
// by default, the cgroup path is "/lxc/<id>"
// by default, the cgroup path is "/lxc/<id>"
cgroupPath
=
"/lxc"
cgroupPath
=
"/lxc"
...
@@ -161,9 +164,9 @@ func (c *Container) GetSpec() *specs.Spec {
...
@@ -161,9 +164,9 @@ func (c *Container) GetSpec() *specs.Spec {
return
c
.
spec
return
c
.
spec
}
}
// get
LcrdContainerID returns the lcr
d container ID via the container name
// get
IsuladContainerID returns the isula
d container ID via the container name
func
get
Lcr
dContainerID
(
name
string
)
(
string
,
error
)
{
func
get
Isula
dContainerID
(
name
string
)
(
string
,
error
)
{
cmd
:=
exec
.
Command
(
"
lcrc
"
,
"inspect"
,
"-f"
,
"{{json .Id}}"
,
name
)
cmd
:=
exec
.
Command
(
"
isula
"
,
"inspect"
,
"-f"
,
"{{json .Id}}"
,
name
)
out
,
err
:=
cmd
.
CombinedOutput
()
out
,
err
:=
cmd
.
CombinedOutput
()
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"%s: %v"
,
string
(
out
),
err
)
return
""
,
fmt
.
Errorf
(
"%s: %v"
,
string
(
out
),
err
)
...
@@ -171,9 +174,9 @@ func getLcrdContainerID(name string) (string, error) {
...
@@ -171,9 +174,9 @@ func getLcrdContainerID(name string) (string, error) {
return
strings
.
Trim
(
strings
.
Trim
(
string
(
out
),
"
\n
"
),
"
\"
"
),
nil
return
strings
.
Trim
(
strings
.
Trim
(
string
(
out
),
"
\n
"
),
"
\"
"
),
nil
}
}
// get
LcrdContainerPid returns the lcr
d container process id via the container name
// get
IsuladContainerPid returns the isula
d container process id via the container name
func
get
Lcr
dContainerPid
(
name
string
)
(
int
,
error
)
{
func
get
Isula
dContainerPid
(
name
string
)
(
int
,
error
)
{
cmd
:=
exec
.
Command
(
"
lcrc
"
,
"inspect"
,
"-f"
,
"{{json .State.Pid}}"
,
name
)
cmd
:=
exec
.
Command
(
"
isula
"
,
"inspect"
,
"-f"
,
"{{json .State.Pid}}"
,
name
)
out
,
err
:=
cmd
.
CombinedOutput
()
out
,
err
:=
cmd
.
CombinedOutput
()
if
err
!=
nil
{
if
err
!=
nil
{
return
-
1
,
fmt
.
Errorf
(
"%s: %v"
,
string
(
out
),
err
)
return
-
1
,
fmt
.
Errorf
(
"%s: %v"
,
string
(
out
),
err
)
...
@@ -186,8 +189,8 @@ func getLcrdContainerPid(name string) (int, error) {
...
@@ -186,8 +189,8 @@ func getLcrdContainerPid(name string) (int, error) {
return
pid
,
nil
return
pid
,
nil
}
}
func
get
Lcr
dContainerSpec
(
id
string
)
(
spec
*
specs
.
Spec
,
err
error
)
{
func
get
Isula
dContainerSpec
(
id
string
)
(
spec
*
specs
.
Spec
,
err
error
)
{
graphDriverPath
,
err
:=
get
Lcr
dGraphDriverPath
()
graphDriverPath
,
err
:=
get
Isula
dGraphDriverPath
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -210,11 +213,11 @@ func getLcrdContainerSpec(id string) (spec *specs.Spec, err error) {
...
@@ -210,11 +213,11 @@ func getLcrdContainerSpec(id string) (spec *specs.Spec, err error) {
return
spec
,
nil
return
spec
,
nil
}
}
func
get
Lcr
dGraphDriverPath
()
(
string
,
error
)
{
func
get
Isula
dGraphDriverPath
()
(
string
,
error
)
{
cmd
:=
exec
.
Command
(
"
lcrc
"
,
"info"
)
cmd
:=
exec
.
Command
(
"
isula
"
,
"info"
)
out
,
err
:=
cmd
.
CombinedOutput
()
out
,
err
:=
cmd
.
CombinedOutput
()
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"Exec
lcrc
info failed: %v"
,
err
)
return
""
,
fmt
.
Errorf
(
"Exec
isula
info failed: %v"
,
err
)
}
}
// Find "iSulad Root Dir: /xx/xx" line. and out is still has the rest characters.
// Find "iSulad Root Dir: /xx/xx" line. and out is still has the rest characters.
if
index
:=
strings
.
Index
(
string
(
out
),
"iSulad Root Dir:"
);
index
!=
-
1
{
if
index
:=
strings
.
Index
(
string
(
out
),
"iSulad Root Dir:"
);
index
!=
-
1
{
...
@@ -228,7 +231,7 @@ func getLcrdGraphDriverPath() (string, error) {
...
@@ -228,7 +231,7 @@ func getLcrdGraphDriverPath() (string, error) {
return
rootdir
,
nil
return
rootdir
,
nil
}
}
}
}
return
""
,
fmt
.
Errorf
(
"Faild to parse
lcrc
info, no
\"
iSulad Root Dir:
\"
found"
)
return
""
,
fmt
.
Errorf
(
"Faild to parse
isula
info, no
\"
iSulad Root Dir:
\"
found"
)
}
}
// SetContainerPath set container path
// SetContainerPath set container path
...
...
hack/install.sh
浏览文件 @
58cdc83a
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
#!/bin/bash
#!/bin/bash
HOOK_DIR
=
/var/lib/
lcr
d/hooks
HOOK_DIR
=
/var/lib/
isula
d/hooks
ISULAD_TOOLS_DIR
=
/usr/local/bin
ISULAD_TOOLS_DIR
=
/usr/local/bin
ISULAD_TOOLS_WRAPPER
=
"/lib/udev"
ISULAD_TOOLS_WRAPPER
=
"/lib/udev"
HOOK_SPEC
=
"/etc/isulad-tools"
HOOK_SPEC
=
"/etc/isulad-tools"
...
...
hack/isulad-tools.spec
浏览文件 @
58cdc83a
...
@@ -28,7 +28,7 @@ This is isulad tools, to make it work, you need a isulad and util-linux
...
@@ -28,7 +28,7 @@ This is isulad tools, to make it work, you need a isulad and util-linux
make init && make
make init && make
%install
%install
HOOK_DIR=$RPM_BUILD_ROOT/var/lib/
lcr
d/hooks
HOOK_DIR=$RPM_BUILD_ROOT/var/lib/
isula
d/hooks
ISULAD_TOOLS_DIR=$RPM_BUILD_ROOT/usr/local/bin
ISULAD_TOOLS_DIR=$RPM_BUILD_ROOT/usr/local/bin
ISULAD_TOOLS_WRAPPER=$RPM_BUILD_ROOT/lib/udev
ISULAD_TOOLS_WRAPPER=$RPM_BUILD_ROOT/lib/udev
...
@@ -46,18 +46,18 @@ install -m 0750 hack/isulad-tools_wrapper ${ISULAD_TOOLS_WRAPPER}/isulad-tools_
...
@@ -46,18 +46,18 @@ install -m 0750 hack/isulad-tools_wrapper ${ISULAD_TOOLS_WRAPPER}/isulad-tools_
%preun
%preun
%post
%post
GRAPH=`
lcrc
info | grep -Eo "iSulad Root Dir:.+" | grep -Eo "\/.*"`
GRAPH=`
isula
info | grep -Eo "iSulad Root Dir:.+" | grep -Eo "\/.*"`
if [ "$GRAPH" == "" ]; then
if [ "$GRAPH" == "" ]; then
GRAPH="/var/lib/
lcr
d"
GRAPH="/var/lib/
isula
d"
fi
fi
if [[ "$GRAPH" != "/var/lib/
lcr
d" ]]; then
if [[ "$GRAPH" != "/var/lib/
isula
d" ]]; then
mkdir -p -m 0550 $GRAPH/hooks
mkdir -p -m 0550 $GRAPH/hooks
install -m 0550 -p /var/lib/
lcr
d/hooks/isulad-hooks $GRAPH/hooks
install -m 0550 -p /var/lib/
isula
d/hooks/isulad-hooks $GRAPH/hooks
echo
echo
echo "=================== WARNING! ================================================"
echo "=================== WARNING! ================================================"
echo " 'iSulad Root Dir' is $GRAPH, move /var/lib/
lcr
d/hooks/isulad-hooks to $GRAPH/hooks"
echo " 'iSulad Root Dir' is $GRAPH, move /var/lib/
isula
d/hooks/isulad-hooks to $GRAPH/hooks"
echo "============================================================================="
echo "============================================================================="
echo
echo
fi
fi
...
@@ -98,8 +98,8 @@ chmod 0640 ${HOOK_SPEC}/hookspec.json
...
@@ -98,8 +98,8 @@ chmod 0640 ${HOOK_SPEC}/hookspec.json
%files
%files
%defattr(0550,root,root,0550)
%defattr(0550,root,root,0550)
/usr/local/bin/isulad-tools
/usr/local/bin/isulad-tools
%attr(0550,root,root) /var/lib/
lcr
d/hooks
%attr(0550,root,root) /var/lib/
isula
d/hooks
%attr(0550,root,root) /var/lib/
lcr
d/hooks/isulad-hooks
%attr(0550,root,root) /var/lib/
isula
d/hooks/isulad-hooks
%attr(0550,root,root) /lib/udev/isulad-tools_wrapper
%attr(0550,root,root) /lib/udev/isulad-tools_wrapper
...
...
hooks/isulad-hooks/README.md
浏览文件 @
58cdc83a
...
@@ -50,13 +50,13 @@ Full hook config:
...
@@ -50,13 +50,13 @@ Full hook config:
## Try it!
## Try it!
First you need an enhanced
`
lcrc
`
with newly added
`--hook-spec`
flag,
First you need an enhanced
`
isula
`
with newly added
`--hook-spec`
flag,
after that, you can run it like this:
after that, you can run it like this:
1.
run isulad container with hook spec in
`example`
directory
1.
run isulad container with hook spec in
`example`
directory
```
```
$
lcrc
run -d --name test_device --hook-spec $PWD/example/hookspec.json busybox sleep 20000
$
isula
run -d --name test_device --hook-spec $PWD/example/hookspec.json busybox sleep 20000
```
```
2.
use isulad-tools to add device or binds to container
2.
use isulad-tools to add device or binds to container
...
@@ -67,7 +67,7 @@ isulad-tools add-device test_device /dev/zero:/dev/test_zero:rwm /dev/zero:/dev/
...
@@ -67,7 +67,7 @@ isulad-tools add-device test_device /dev/zero:/dev/test_zero:rwm /dev/zero:/dev/
3.
restart the container. to check the device is still in container.
3.
restart the container. to check the device is still in container.
```
```
lcrc
restart test_device
isula
restart test_device
```
```
Let's check the
[
`hookspec.json`
](
example/hookspec.json
)
file:
Let's check the
[
`hookspec.json`
](
example/hookspec.json
)
file:
...
@@ -76,7 +76,7 @@ Let's check the [`hookspec.json`](example/hookspec.json) file:
...
@@ -76,7 +76,7 @@ Let's check the [`hookspec.json`](example/hookspec.json) file:
{
{
"prestart": [
"prestart": [
{
{
"path": "/var/lib/
lcr
d/hooks/device-hook",
"path": "/var/lib/
isula
d/hooks/device-hook",
"args": ["device-hook"],
"args": ["device-hook"],
"env": []
"env": []
}
}
...
...
hooks/isulad-hooks/example/hookspec.json
浏览文件 @
58cdc83a
{
{
"prestart"
:
[
"prestart"
:
[
{
{
"path"
:
"/var/lib/
lcr
d/hooks/isulad-hooks"
,
"path"
:
"/var/lib/
isula
d/hooks/isulad-hooks"
,
"args"
:
[
"isulad-hooks"
,
"--state"
,
"prestart"
,
"--log"
,
"/var/log/device-hook.log"
],
"args"
:
[
"isulad-hooks"
,
"--state"
,
"prestart"
,
"--log"
,
"/var/log/device-hook.log"
],
"env"
:
[]
"env"
:
[]
}
}
],
],
"poststart"
:[
"poststart"
:[
{
{
"path"
:
"/var/lib/
lcr
d/hooks/isulad-hooks"
,
"path"
:
"/var/lib/
isula
d/hooks/isulad-hooks"
,
"args"
:
[
"isulad-hooks"
,
"--state"
,
"prestart"
,
"--log"
,
"/var/log/device-hook.log"
],
"args"
:
[
"isulad-hooks"
,
"--state"
,
"prestart"
,
"--log"
,
"/var/log/device-hook.log"
],
"env"
:
[]
"env"
:
[]
}
}
],
],
"poststop"
:[
"poststop"
:[
{
{
"path"
:
"/var/lib/
lcr
d/hooks/isulad-hooks"
,
"path"
:
"/var/lib/
isula
d/hooks/isulad-hooks"
,
"args"
:
[
"isulad-hooks"
,
"--state"
,
"poststop"
,
"--log"
,
"/var/log/device-hook.log"
],
"args"
:
[
"isulad-hooks"
,
"--state"
,
"poststop"
,
"--log"
,
"/var/log/device-hook.log"
],
"env"
:
[]
"env"
:
[]
}
}
...
...
hooks/isulad-hooks/prestart.go
浏览文件 @
58cdc83a
...
@@ -347,7 +347,7 @@ func AdjustUserns(state *configs.HookState, hookConfig *hconfig.ContainerHookCon
...
@@ -347,7 +347,7 @@ func AdjustUserns(state *configs.HookState, hookConfig *hconfig.ContainerHookCon
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
strings
.
Contains
(
containerStoragePath
,
"
lcr
d"
)
{
if
strings
.
Contains
(
containerStoragePath
,
"
isula
d"
)
{
return
nil
return
nil
}
}
...
...
relabel.go
浏览文件 @
58cdc83a
...
@@ -51,7 +51,7 @@ func relabelIsuladBinary(path, bin string) error {
...
@@ -51,7 +51,7 @@ func relabelIsuladBinary(path, bin string) error {
}
}
func
restartIsulad
()
error
{
func
restartIsulad
()
error
{
restart
:=
selinuxCommand
{
"systemctl"
,
[]
string
{
"restart"
,
"
lcr
d"
}}
restart
:=
selinuxCommand
{
"systemctl"
,
[]
string
{
"restart"
,
"
isula
d"
}}
cmd
:=
exec
.
Command
(
restart
.
cmd
,
restart
.
argv
...
)
cmd
:=
exec
.
Command
(
restart
.
cmd
,
restart
.
argv
...
)
logrus
.
Infof
(
"%s %v"
,
restart
.
cmd
,
restart
.
argv
)
logrus
.
Infof
(
"%s %v"
,
restart
.
cmd
,
restart
.
argv
)
if
err
:=
cmd
.
Run
();
err
!=
nil
{
if
err
:=
cmd
.
Run
();
err
!=
nil
{
...
@@ -94,7 +94,7 @@ func relabel(path string) error {
...
@@ -94,7 +94,7 @@ func relabel(path string) error {
return
nil
return
nil
}
}
modifyContexts
:=
[]
selinuxContext
{
modifyContexts
:=
[]
selinuxContext
{
{
"init_exec_t"
,
path
+
"/
lcr
d"
},
{
"init_exec_t"
,
path
+
"/
isula
d"
},
}
}
con
:=
utils
.
NewContext
(
attr
)
con
:=
utils
.
NewContext
(
attr
)
for
_
,
context
:=
range
modifyContexts
{
for
_
,
context
:=
range
modifyContexts
{
...
...
test/devices_many_test.sh
浏览文件 @
58cdc83a
...
@@ -19,21 +19,21 @@
...
@@ -19,21 +19,21 @@
TEST_NAME
=
"test_devices_many"
TEST_NAME
=
"test_devices_many"
test_001
(){
test_001
(){
container_ID
=
`
lcrc run
--name
one
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 10000"
`
container_ID
=
`
isula run
--name
one
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 10000"
`
container_status
$container_ID
container_status
$container_ID
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
fail
$TEST_NAME
"01:FAIL"
fail
$TEST_NAME
"01:FAIL"
fi
fi
container_ID
=
`
lcrc
ps |
grep
one |
awk
'{print $1}'
`
container_ID
=
`
isula
ps |
grep
one |
awk
'{print $1}'
`
$ISULAD_TOOLS
add-device
$container_ID
$DEV_SDA1
:/dev/sda1:rw
$DEV_SDA2
:/dev/sda2:rw
>
/dev/null
$ISULAD_TOOLS
add-device
$container_ID
$DEV_SDA1
:/dev/sda1:rw
$DEV_SDA2
:/dev/sda2:rw
>
/dev/null
out
=
`
lcrc
exec
one bash
-c
"ls /dev/sda1"
`
out
=
`
isula
exec
one bash
-c
"ls /dev/sda1"
`
if
[
"
$out
"
==
"/dev/sda1"
]
;
then
if
[
"
$out
"
==
"/dev/sda1"
]
;
then
success
$TEST_NAME
"01-1:PASS"
success
$TEST_NAME
"01-1:PASS"
else
else
fail
$TEST_NAME
"01-1:FAIL"
fail
$TEST_NAME
"01-1:FAIL"
fi
fi
out
=
`
lcrc
exec
one bash
-c
"ls /dev/sda2"
`
out
=
`
isula
exec
one bash
-c
"ls /dev/sda2"
`
if
[
"
$out
"
==
"/dev/sda2"
]
;
then
if
[
"
$out
"
==
"/dev/sda2"
]
;
then
success
$TEST_NAME
"01-2:PASS"
success
$TEST_NAME
"01-2:PASS"
else
else
...
@@ -41,7 +41,7 @@ test_001(){
...
@@ -41,7 +41,7 @@ test_001(){
fi
fi
#test remove-device
#test remove-device
$ISULAD_TOOLS
remove-device
$container_ID
$DEV_SDA1
:/dev/sda1:rw /dev/zero:/dev/sda2:rw
>
/dev/null
$ISULAD_TOOLS
remove-device
$container_ID
$DEV_SDA1
:/dev/sda1:rw /dev/zero:/dev/sda2:rw
>
/dev/null
lcrc
exec
one bash
-c
"ls /dev/sda1 && /dev/sda2"
>
&
$TEST_FOLDER
/ab.txt
isula
exec
one bash
-c
"ls /dev/sda1 && /dev/sda2"
>
&
$TEST_FOLDER
/ab.txt
out
=
`
cat
$TEST_FOLDER
/ab.txt
`
out
=
`
cat
$TEST_FOLDER
/ab.txt
`
out
=
${
out
##*
:
}
out
=
${
out
##*
:
}
out
=
${
out
%%or*
}
out
=
${
out
%%or*
}
...
@@ -59,24 +59,24 @@ test_001(){
...
@@ -59,24 +59,24 @@ test_001(){
else
else
fail
$TEST_NAME
"01-4:FAIL"
fail
$TEST_NAME
"01-4:FAIL"
fi
fi
lcrc
rm
-f
one
>
/dev/null
isula
rm
-f
one
>
/dev/null
}
}
test_002
(){
test_002
(){
#test Multiple container mount the same direct
#test Multiple container mount the same direct
container_ID1
=
`
lcrc run
--name
one
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 10000"
`
container_ID1
=
`
isula run
--name
one
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 10000"
`
container_status
$container_ID1
container_status
$container_ID1
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
fail
$TEST_NAME
"02:FAIL"
fail
$TEST_NAME
"02:FAIL"
fi
fi
container_ID2
=
`
lcrc run
--name
two
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 10000"
`
container_ID2
=
`
isula run
--name
two
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 10000"
`
container_status
$container_ID2
container_status
$container_ID2
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
fail
$TEST_NAME
"021:FAIL"
fail
$TEST_NAME
"021:FAIL"
fi
fi
out
=
`
$ISULAD_TOOLS
add-device
$container_ID1
$DEV_SDA1
:/dev/sda1:rw
>
/dev/null
`
out
=
`
$ISULAD_TOOLS
add-device
$container_ID1
$DEV_SDA1
:/dev/sda1:rw
>
/dev/null
`
out
=
`
lcrc
exec
one bash
-c
"ls /dev/sda1"
`
out
=
`
isula
exec
one bash
-c
"ls /dev/sda1"
`
if
[
"
$out
"
!=
"/dev/sda1"
]
;
then
if
[
"
$out
"
!=
"/dev/sda1"
]
;
then
fail
$TEST_NAME
"02-1:FAIL"
fail
$TEST_NAME
"02-1:FAIL"
else
else
...
@@ -84,7 +84,7 @@ test_002(){
...
@@ -84,7 +84,7 @@ test_002(){
fi
fi
out
=
`
$ISULAD_TOOLS
add-device
$container_ID2
$DEV_SDA1
:/dev/sda1:rw
>
/dev/null
`
out
=
`
$ISULAD_TOOLS
add-device
$container_ID2
$DEV_SDA1
:/dev/sda1:rw
>
/dev/null
`
out1
=
`
lcrc
exec
two bash
-c
"ls /dev/sda1"
`
out1
=
`
isula
exec
two bash
-c
"ls /dev/sda1"
`
if
[
"
$out1
"
!=
"/dev/sda1"
]
;
then
if
[
"
$out1
"
!=
"/dev/sda1"
]
;
then
fail
$TEST_NAME
"02-2:FAIL"
fail
$TEST_NAME
"02-2:FAIL"
else
else
...
@@ -92,7 +92,7 @@ test_002(){
...
@@ -92,7 +92,7 @@ test_002(){
fi
fi
$ISULAD_TOOLS
remove-device
$container_ID1
$DEV_SDA1
:/dev/sda1:rw
>
/dev/null
$ISULAD_TOOLS
remove-device
$container_ID1
$DEV_SDA1
:/dev/sda1:rw
>
/dev/null
lcrc
exec
$container_ID1
bash
-c
"ls /dev/sda1"
>
/dev/null 2>&1
isula
exec
$container_ID1
bash
-c
"ls /dev/sda1"
>
/dev/null 2>&1
out
=
`
echo
$?
`
out
=
`
echo
$?
`
if
[
$out
-eq
0
]
;
then
if
[
$out
-eq
0
]
;
then
fail
$TEST_NAME
"02-3:FAIL"
fail
$TEST_NAME
"02-3:FAIL"
...
@@ -100,7 +100,7 @@ test_002(){
...
@@ -100,7 +100,7 @@ test_002(){
success
$TEST_NAME
"02-3:PASS"
success
$TEST_NAME
"02-3:PASS"
fi
fi
out1
=
`
lcrc
exec
two bash
-c
"ls /dev/sda1"
`
out1
=
`
isula
exec
two bash
-c
"ls /dev/sda1"
`
if
[
"
$out1
"
==
"/dev/sda1"
]
;
then
if
[
"
$out1
"
==
"/dev/sda1"
]
;
then
success
$TEST_NAME
"02-4:PASS"
success
$TEST_NAME
"02-4:PASS"
else
else
...
@@ -108,24 +108,24 @@ test_002(){
...
@@ -108,24 +108,24 @@ test_002(){
fi
fi
#test stop start
#test stop start
lcrc
stop two
>
/dev/null
isula
stop two
>
/dev/null
container_status
$container_ID2
container_status
$container_ID2
if
[
"
${
status
}
x"
!=
"exitedx"
]
;
then
if
[
"
${
status
}
x"
!=
"exitedx"
]
;
then
fail
$TEST_NAME
"02-5:FAIL"
fail
$TEST_NAME
"02-5:FAIL"
fi
fi
lcrc
start two
>
/dev/null
isula
start two
>
/dev/null
container_status
$container_ID2
container_status
$container_ID2
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
fail
$TEST_NAME
"02-6:FAIL"
fail
$TEST_NAME
"02-6:FAIL"
fi
fi
out1
=
`
lcrc
exec
two bash
-c
"ls /dev/sda1"
`
out1
=
`
isula
exec
two bash
-c
"ls /dev/sda1"
`
if
[
"
$out1
"
==
"/dev/sda1"
]
;
then
if
[
"
$out1
"
==
"/dev/sda1"
]
;
then
success
$TEST_NAME
"02-7:PASS"
success
$TEST_NAME
"02-7:PASS"
else
else
fail
$TEST_NAME
"02-7:FAIL"
fail
$TEST_NAME
"02-7:FAIL"
fi
fi
lcrc
rm
-f
one
>
/dev/null
isula
rm
-f
one
>
/dev/null
lcrc
rm
-f
two
>
/dev/null
isula
rm
-f
two
>
/dev/null
}
}
...
...
test/devices_test.sh
浏览文件 @
58cdc83a
...
@@ -20,14 +20,14 @@ TEST_NAME="test_devices"
...
@@ -20,14 +20,14 @@ TEST_NAME="test_devices"
test_001
(){
test_001
(){
# test add-device.
# test add-device.
out
=
`
lcrc run
--name
one
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 100000"
`
out
=
`
isula run
--name
one
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 100000"
`
container_status
$out
container_status
$out
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
fail
$TEST_NAME
"01:FAIL"
fail
$TEST_NAME
"01:FAIL"
fi
fi
$ISULAD_TOOLS
add-device
$out
$DEV_SDA1
:/dev/sda1:rw> /dev/null
$ISULAD_TOOLS
add-device
$out
$DEV_SDA1
:/dev/sda1:rw> /dev/null
out1
=
`
lcrc
exec
one sh
-c
"ls /dev/sda1"
`
out1
=
`
isula
exec
one sh
-c
"ls /dev/sda1"
`
if
[
"
$out1
"
==
"/dev/sda1"
]
;
then
if
[
"
$out1
"
==
"/dev/sda1"
]
;
then
success
$TEST_NAME
"01-1:PASS"
success
$TEST_NAME
"01-1:PASS"
else
else
...
@@ -36,19 +36,19 @@ test_001(){
...
@@ -36,19 +36,19 @@ test_001(){
#test remove-device
#test remove-device
$ISULAD_TOOLS
remove-device
$out
$DEV_SDA1
:/dev/sda1:rwm
>
/dev/null
$ISULAD_TOOLS
remove-device
$out
$DEV_SDA1
:/dev/sda1:rwm
>
/dev/null
out1
=
`
lcrc
exec
one sh
-c
"ls -l /dev/sda1"
>
/dev/null 2>&1
`
out1
=
`
isula
exec
one sh
-c
"ls -l /dev/sda1"
>
/dev/null 2>&1
`
if
[
"
$out1
"
==
""
]
;
then
if
[
"
$out1
"
==
""
]
;
then
success
$TEST_NAME
"01-2:PASS"
success
$TEST_NAME
"01-2:PASS"
else
else
fail
$TEST_NAME
"01-2:FAIL"
fail
$TEST_NAME
"01-2:FAIL"
fi
fi
lcrc
rm
-f
one
>
/dev/null
isula
rm
-f
one
>
/dev/null
}
}
test_002
(){
test_002
(){
#test exited container
#test exited container
out
=
`
lcrc run
--name
one
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
`
out
=
`
isula run
--name
one
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
`
sleep
3
sleep
3
container_status
$out
container_status
$out
if
[
"
${
status
}
x"
!=
"exitedx"
]
;
then
if
[
"
${
status
}
x"
!=
"exitedx"
]
;
then
...
@@ -61,13 +61,13 @@ test_002(){
...
@@ -61,13 +61,13 @@ test_002(){
else
else
fail
$TEST_NAME
"02-1:FAIL"
fail
$TEST_NAME
"02-1:FAIL"
fi
fi
lcrc
rm
one
>
/dev/null
isula
rm
one
>
/dev/null
rm
-f
ab.txt
>
/dev/null
rm
-f
ab.txt
>
/dev/null
}
}
test_003
(){
test_003
(){
#test created container
#test created container
out
=
`
lcrc create
--name
one
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-ti
$UBUNTU_IMAGE
`
out
=
`
isula create
--name
one
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-ti
$UBUNTU_IMAGE
`
container_status
$out
container_status
$out
if
[
"
${
status
}
x"
!=
"createdx"
]
;
then
if
[
"
${
status
}
x"
!=
"createdx"
]
;
then
fail
$TEST_NAME
"03:FAIL"
fail
$TEST_NAME
"03:FAIL"
...
@@ -82,36 +82,36 @@ test_003(){
...
@@ -82,36 +82,36 @@ test_003(){
rm
-f
ab.txt
>
/dev/null
rm
-f
ab.txt
>
/dev/null
#created->up container
#created->up container
lcrc
start one
>
/dev/null
isula
start one
>
/dev/null
out
=
`
lcrc
ps |
grep
one |
awk
'{print $1}'
`
out
=
`
isula
ps |
grep
one |
awk
'{print $1}'
`
out1
=
`
$ISULAD_TOOLS
add-device
$out
$DEV_SDA1
:/dev/sda1:rwm
`
out1
=
`
$ISULAD_TOOLS
add-device
$out
$DEV_SDA1
:/dev/sda1:rwm
`
out1
=
`
lcrc
exec
one sh
-c
"ls /dev/sda1"
`
out1
=
`
isula
exec
one sh
-c
"ls /dev/sda1"
`
if
[
"
$out1
"
==
"/dev/sda1"
]
;
then
if
[
"
$out1
"
==
"/dev/sda1"
]
;
then
success
$TEST_NAME
"03-2:PASS"
success
$TEST_NAME
"03-2:PASS"
else
else
fail
$TEST_NAME
"03-2:FAIL"
fail
$TEST_NAME
"03-2:FAIL"
fi
fi
lcrc
rm
-f
one
>
/dev/null
isula
rm
-f
one
>
/dev/null
}
}
test_004
(){
test_004
(){
#test r
#test r
out
=
`
lcrc run
--name
one
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 10000"
`
out
=
`
isula run
--name
one
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 10000"
`
container_status
$out
container_status
$out
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
fail
$TEST_NAME
"04:FAIL"
fail
$TEST_NAME
"04:FAIL"
fi
fi
$ISULAD_TOOLS
add-device
$out
$DEV_SDA1
:/dev/sda1:r
>
/dev/null
$ISULAD_TOOLS
add-device
$out
$DEV_SDA1
:/dev/sda1:r
>
/dev/null
out1
=
`
lcrc
exec
one sh
-c
"ls /dev/sda1"
`
out1
=
`
isula
exec
one sh
-c
"ls /dev/sda1"
`
if
[
"
$out1
"
!=
"/dev/sda1"
]
;
then
if
[
"
$out1
"
!=
"/dev/sda1"
]
;
then
fail
$TEST_NAME
"04-1:FAIL"
fail
$TEST_NAME
"04-1:FAIL"
else
else
success
$TEST_NAME
"04-1:PASS"
success
$TEST_NAME
"04-1:PASS"
fi
fi
$ISULAD_TOOLS
remove-device
$out
$DEV_SDA1
:/dev/sda1:r
>
/dev/null
$ISULAD_TOOLS
remove-device
$out
$DEV_SDA1
:/dev/sda1:r
>
/dev/null
out
=
`
lcrc
exec
one sh
-c
"ls /dev/sda1"
>
/dev/null 2>&1
`
out
=
`
isula
exec
one sh
-c
"ls /dev/sda1"
>
/dev/null 2>&1
`
if
[
"
$out
"
==
""
]
;
then
if
[
"
$out
"
==
""
]
;
then
success
$TEST_NAME
"04-2:PASS"
success
$TEST_NAME
"04-2:PASS"
else
else
...
@@ -120,15 +120,15 @@ test_004(){
...
@@ -120,15 +120,15 @@ test_004(){
rm
-rf
ab.txt
>
/dev/null
rm
-rf
ab.txt
>
/dev/null
#test rw
#test rw
out
=
`
lcrc
ps |
grep
one |
awk
'{print $1}'
`
out
=
`
isula
ps |
grep
one |
awk
'{print $1}'
`
$ISULAD_TOOLS
add-device
$out
$DEV_SDA1
:/dev/sda1:rw
>
/dev/null
$ISULAD_TOOLS
add-device
$out
$DEV_SDA1
:/dev/sda1:rw
>
/dev/null
out
=
`
lcrc
exec
one sh
-c
"ls /dev/sda1"
`
out
=
`
isula
exec
one sh
-c
"ls /dev/sda1"
`
if
[
"
$out
"
!=
"/dev/sda1"
]
;
then
if
[
"
$out
"
!=
"/dev/sda1"
]
;
then
fail
$TEST_NAME
"04-3:FAIL"
fail
$TEST_NAME
"04-3:FAIL"
else
else
success
$TEST_NAME
"04-3:PASS"
success
$TEST_NAME
"04-3:PASS"
fi
fi
lcrc
exec
one bash
-c
"dd if=/dev/sda1 of=/dev/null bs=1M count=10"
>
&
`
pwd
`
/ab.txt
isula
exec
one bash
-c
"dd if=/dev/sda1 of=/dev/null bs=1M count=10"
>
&
`
pwd
`
/ab.txt
out
=
`
cat
ab.txt |
awk
-F
','
'END{print $1}'
`
out
=
`
cat
ab.txt |
awk
-F
','
'END{print $1}'
`
out
=
`
echo
$out
|
awk
-F
' '
'{print $1}'
`
out
=
`
echo
$out
|
awk
-F
' '
'{print $1}'
`
if
[
"
$out
"
==
"10485760"
]
;
then
if
[
"
$out
"
==
"10485760"
]
;
then
...
@@ -136,13 +136,13 @@ test_004(){
...
@@ -136,13 +136,13 @@ test_004(){
else
else
fail
$TEST_NAME
"04-4:FAIL"
fail
$TEST_NAME
"04-4:FAIL"
fi
fi
lcrc
rm
-f
one
>
/dev/null
isula
rm
-f
one
>
/dev/null
rm
-f
ab.txt
>
/dev/null
rm
-f
ab.txt
>
/dev/null
}
}
test_006
(){
test_006
(){
#test not exist device
#test not exist device
out
=
`
lcrc run
--name
one
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 100000"
`
out
=
`
isula run
--name
one
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 100000"
`
container_status
$out
container_status
$out
if
[
"
${
status
}
x"
==
"runningx"
]
;
then
if
[
"
${
status
}
x"
==
"runningx"
]
;
then
success
$TEST_NAME
"06:PASS"
success
$TEST_NAME
"06:PASS"
...
@@ -157,10 +157,10 @@ test_006(){
...
@@ -157,10 +157,10 @@ test_006(){
fail
$TEST_NAME
"06-1:FAIL"
fail
$TEST_NAME
"06-1:FAIL"
fi
fi
rm
-f
ab.txt
>
/dev/null
rm
-f
ab.txt
>
/dev/null
lcrc
rm
-f
one
>
/dev/null
isula
rm
-f
one
>
/dev/null
#test no r w
#test no r w
out
=
`
lcrc run
--name
one
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 100000"
`
out
=
`
isula run
--name
one
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 100000"
`
container_status
$out
container_status
$out
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
fail
$TEST_NAME
"06-2:FAIL"
fail
$TEST_NAME
"06-2:FAIL"
...
@@ -168,7 +168,7 @@ test_006(){
...
@@ -168,7 +168,7 @@ test_006(){
success
$TEST_NAME
"06-2:PASS"
success
$TEST_NAME
"06-2:PASS"
fi
fi
$ISULAD_TOOLS
add-device
$out
$DEV_SDA
:/dev/sda
>
/dev/null
$ISULAD_TOOLS
add-device
$out
$DEV_SDA
:/dev/sda
>
/dev/null
lcrc
exec
one bash
-c
"dd if=/dev/sda of=/dev/null bs=1M count=10"
>
&
$TMP
/ab.txt
isula
exec
one bash
-c
"dd if=/dev/sda of=/dev/null bs=1M count=10"
>
&
$TMP
/ab.txt
out
=
`
cat
$TMP
/ab.txt |
awk
-F
','
'END{print $1}'
`
out
=
`
cat
$TMP
/ab.txt |
awk
-F
','
'END{print $1}'
`
out
=
`
echo
$out
|
awk
-F
' '
'{print $1}'
`
out
=
`
echo
$out
|
awk
-F
' '
'{print $1}'
`
if
[
"
$out
"
==
"10485760"
]
;
then
if
[
"
$out
"
==
"10485760"
]
;
then
...
@@ -176,7 +176,7 @@ test_006(){
...
@@ -176,7 +176,7 @@ test_006(){
else
else
fail
$TEST_NAME
"06-3:FAIL"
fail
$TEST_NAME
"06-3:FAIL"
fi
fi
lcrc
rm
-f
one
>
/dev/null
isula
rm
-f
one
>
/dev/null
}
}
...
...
test/main.sh
浏览文件 @
58cdc83a
...
@@ -29,10 +29,10 @@ setupImage(){
...
@@ -29,10 +29,10 @@ setupImage(){
declare
-a
Images
=(
$UBUNTU_IMAGE
$BUSYBOX_IMAGE
)
declare
-a
Images
=(
$UBUNTU_IMAGE
$BUSYBOX_IMAGE
)
for
img
in
"
${
Images
[@]
}
"
;
for
img
in
"
${
Images
[@]
}
"
;
do
do
out
=
`
lcrc
images |
grep
$img
`
out
=
`
isula
images |
grep
$img
`
if
[
"x
$out
"
=
"x"
]
;
then
if
[
"x
$out
"
=
"x"
]
;
then
echo
"Image ["
$img
"] does not exist, pull it from hub."
echo
"Image ["
$img
"] does not exist, pull it from hub."
lcrc
pull
$img
isula
pull
$img
fi
fi
done
done
...
@@ -40,9 +40,9 @@ setupImage(){
...
@@ -40,9 +40,9 @@ setupImage(){
setup_device_hook
(){
setup_device_hook
(){
mkdir
-p
/var/lib/
lcr
d/hooks
mkdir
-p
/var/lib/
isula
d/hooks
cp
$CUR
/../hooks/isulad-hooks/example/hookspec.json /var/lib/
lcr
d/hooks/
cp
$CUR
/../hooks/isulad-hooks/example/hookspec.json /var/lib/
isula
d/hooks/
cp
$CUR
/../build/isulad-hooks /var/lib/
lcr
d/hooks/
cp
$CUR
/../build/isulad-hooks /var/lib/
isula
d/hooks/
}
}
main_test
(){
main_test
(){
...
...
test/network_test.sh
浏览文件 @
58cdc83a
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
test_001
(){
test_001
(){
#testcase01
#testcase01
CONTAINER_ID
=
`
lcrc
run
-d
$BUSYBOX_IMAGE
top
`
CONTAINER_ID
=
`
isula
run
-d
$BUSYBOX_IMAGE
top
`
$ISULAD_TOOLS
--debug
--log
$TMP
/isulad-tools.log add-nic
\
$ISULAD_TOOLS
--debug
--log
$TMP
/isulad-tools.log add-nic
\
--type
veth
--name
eth10
--ip
192.168.182.2/24
\
--type
veth
--name
eth10
--ip
192.168.182.2/24
\
--mac
"aa:bb:cc:dd:ee:aa"
--bridge
"docker0"
--mtu
1350
\
--mac
"aa:bb:cc:dd:ee:aa"
--bridge
"docker0"
--mtu
1350
\
...
@@ -34,7 +34,7 @@ test_001(){
...
@@ -34,7 +34,7 @@ test_001(){
success
$TEST_NAME
"01-1:PASS"
success
$TEST_NAME
"01-1:PASS"
fi
fi
out
=
`
lcrc
exec
$CONTAINER_ID
ip a s eth10
`
out
=
`
isula
exec
$CONTAINER_ID
ip a s eth10
`
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
fail
$TEST_NAME
"01-2:FAIL"
fail
$TEST_NAME
"01-2:FAIL"
else
else
...
@@ -69,7 +69,7 @@ test_001(){
...
@@ -69,7 +69,7 @@ test_001(){
else
else
success
$TEST_NAME
"01-6:PASS"
success
$TEST_NAME
"01-6:PASS"
fi
fi
lcrc
rm
-f
$CONTAINER_ID
>
/dev/null 2>&1
isula
rm
-f
$CONTAINER_ID
>
/dev/null 2>&1
}
}
test_002
(){
test_002
(){
...
@@ -82,7 +82,7 @@ test_002(){
...
@@ -82,7 +82,7 @@ test_002(){
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
fail
"02-1:FAIL"
fail
"02-1:FAIL"
fi
fi
CONTAINER_ID
=
`
lcrc
run
-d
$BUSYBOX_IMAGE
top
`
CONTAINER_ID
=
`
isula
run
-d
$BUSYBOX_IMAGE
top
`
$ISULAD_TOOLS
--debug
--log
$TMP
/isulad-tools.log add-nic
\
$ISULAD_TOOLS
--debug
--log
$TMP
/isulad-tools.log add-nic
\
--type
veth
--name
eth11
--ip
192.168.182.2/24
\
--type
veth
--name
eth11
--ip
192.168.182.2/24
\
--mac
"aa:bb:cc:dd:ee:aa"
--bridge
$OVS_BR
--mtu
1350
\
--mac
"aa:bb:cc:dd:ee:aa"
--bridge
$OVS_BR
--mtu
1350
\
...
@@ -93,7 +93,7 @@ test_002(){
...
@@ -93,7 +93,7 @@ test_002(){
success
$TEST_NAME
"02-1:PASS"
success
$TEST_NAME
"02-1:PASS"
fi
fi
out
=
`
lcrc
exec
$CONTAINER_ID
ip a s eth11
`
out
=
`
isula
exec
$CONTAINER_ID
ip a s eth11
`
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
fail
$TEST_NAME
"02-2:FAIL"
fail
$TEST_NAME
"02-2:FAIL"
else
else
...
@@ -108,7 +108,7 @@ test_002(){
...
@@ -108,7 +108,7 @@ test_002(){
else
else
success
$TEST_NAME
"02-3:PASS"
success
$TEST_NAME
"02-3:PASS"
fi
fi
lcrc
rm
-f
$CONTAINER_ID
>
/dev/null 2>&1
isula
rm
-f
$CONTAINER_ID
>
/dev/null 2>&1
ovs-vsctl
--if-exists
del-br
$OVS_BR
ovs-vsctl
--if-exists
del-br
$OVS_BR
}
}
...
...
test/path_many_test.sh
浏览文件 @
58cdc83a
...
@@ -20,13 +20,13 @@
...
@@ -20,13 +20,13 @@
TEST_NAME
=
"test_path_many"
TEST_NAME
=
"test_path_many"
test_001
(){
test_001
(){
container_ID
=
`
lcrc run
--name
one
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 10000"
`
container_ID
=
`
isula run
--name
one
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 10000"
`
container_status
$container_ID
container_status
$container_ID
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
fail
$TEST_NAME
"01:FAIL"
fail
$TEST_NAME
"01:FAIL"
fi
fi
container_ID
=
`
lcrc
ps |
grep
one |
awk
'{print $1}'
`
container_ID
=
`
isula
ps |
grep
one |
awk
'{print $1}'
`
TEST_FOLDER1
=
$TMP
/
$TEST_NAME
/001/test1
TEST_FOLDER1
=
$TMP
/
$TEST_NAME
/001/test1
TEST_FOLDER2
=
$TMP
/
$TEST_NAME
/001/test2
TEST_FOLDER2
=
$TMP
/
$TEST_NAME
/001/test2
...
@@ -44,14 +44,14 @@ test_001(){
...
@@ -44,14 +44,14 @@ test_001(){
else
else
success
$TEST_NAME
"01-1:PASS"
success
$TEST_NAME
"01-1:PASS"
fi
fi
out
=
`
lcrc
exec
one bash
-c
"cat /tmp/c.txt"
`
out
=
`
isula
exec
one bash
-c
"cat /tmp/c.txt"
`
if
[
"
$out
"
==
"cc"
]
;
then
if
[
"
$out
"
==
"cc"
]
;
then
success
$TEST_NAME
"01-2:PASS"
success
$TEST_NAME
"01-2:PASS"
else
else
fail
$TEST_NAME
"01-2:FAIL"
fail
$TEST_NAME
"01-2:FAIL"
fi
fi
out
=
`
lcrc
exec
one bash
-c
"cat /home/b.txt"
`
out
=
`
isula
exec
one bash
-c
"cat /home/b.txt"
`
if
[
"
$out
"
==
"hello"
]
;
then
if
[
"
$out
"
==
"hello"
]
;
then
success
$TEST_NAME
"01-3:PASS"
success
$TEST_NAME
"01-3:PASS"
else
else
...
@@ -60,7 +60,7 @@ test_001(){
...
@@ -60,7 +60,7 @@ test_001(){
#test remove-path
#test remove-path
$ISULAD_TOOLS
remove-path
$container_ID
$TEST_FOLDER2
:/tmp:rw
$TEST_FOLDER1
:/home:rw
>
/dev/null
$ISULAD_TOOLS
remove-path
$container_ID
$TEST_FOLDER2
:/tmp:rw
$TEST_FOLDER1
:/home:rw
>
/dev/null
out
=
`
lcrc
exec
one bash
-c
"ls /tmp && ls /home"
`
out
=
`
isula
exec
one bash
-c
"ls /tmp && ls /home"
`
if
[
"
$out
"
==
""
]
;
then
if
[
"
$out
"
==
""
]
;
then
success
$TEST_NAME
"01-4:PASS"
success
$TEST_NAME
"01-4:PASS"
else
else
...
@@ -74,24 +74,24 @@ test_001(){
...
@@ -74,24 +74,24 @@ test_001(){
else
else
success
$TEST_NAME
"01-6:PASS"
success
$TEST_NAME
"01-6:PASS"
fi
fi
out
=
`
lcrc
exec
$container_ID
bash
-c
"ls /tmp"
`
out
=
`
isula
exec
$container_ID
bash
-c
"ls /tmp"
`
if
[
"
$out
"
==
"b.txt"
]
;
then
if
[
"
$out
"
==
"b.txt"
]
;
then
success
$TEST_NAME
"01-7:PASS"
success
$TEST_NAME
"01-7:PASS"
else
else
fail
$TEST_NAME
"01-7:FAIL"
fail
$TEST_NAME
"01-7:FAIL"
fi
fi
lcrc
rm
-f
one
>
/dev/null
isula
rm
-f
one
>
/dev/null
}
}
test_002
(){
test_002
(){
#test Multiple container mount the same direct
#test Multiple container mount the same direct
container_ID1
=
`
lcrc run
--name
one1
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 1000"
`
container_ID1
=
`
isula run
--name
one1
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 1000"
`
container_status
$container_ID1
container_status
$container_ID1
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
fail
$TEST_NAME
"02:FAIL"
fail
$TEST_NAME
"02:FAIL"
fi
fi
container_ID2
=
`
lcrc run
--name
two
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 1000"
`
container_ID2
=
`
isula run
--name
two
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 1000"
`
container_status
$container_ID2
container_status
$container_ID2
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
fail
$TEST_NAME
"021:FAIL"
fail
$TEST_NAME
"021:FAIL"
...
@@ -101,7 +101,7 @@ test_002(){
...
@@ -101,7 +101,7 @@ test_002(){
echo
hello
>
$TEST_FOLDER1
/b.txt
echo
hello
>
$TEST_FOLDER1
/b.txt
$ISULAD_TOOLS
add-path
$container_ID1
$TEST_FOLDER1
:/tmp:rw
>
/dev/null
$ISULAD_TOOLS
add-path
$container_ID1
$TEST_FOLDER1
:/tmp:rw
>
/dev/null
out
=
`
lcrc
exec
one1 sh
-c
"ls /tmp"
`
out
=
`
isula
exec
one1 sh
-c
"ls /tmp"
`
if
[
"
$out
"
!=
"b.txt"
]
;
then
if
[
"
$out
"
!=
"b.txt"
]
;
then
fail
$TEST_NAME
"02-1:FAIL"
fail
$TEST_NAME
"02-1:FAIL"
else
else
...
@@ -109,7 +109,7 @@ test_002(){
...
@@ -109,7 +109,7 @@ test_002(){
fi
fi
$ISULAD_TOOLS
add-path
$container_ID2
$TEST_FOLDER1
:/tmp:rw
>
/dev/null
$ISULAD_TOOLS
add-path
$container_ID2
$TEST_FOLDER1
:/tmp:rw
>
/dev/null
out1
=
`
lcrc
exec
two sh
-c
"cd tmp && ls"
`
out1
=
`
isula
exec
two sh
-c
"cd tmp && ls"
`
if
[
"
$out1
"
!=
"b.txt"
]
;
then
if
[
"
$out1
"
!=
"b.txt"
]
;
then
fail
$TEST_NAME
"02-2:FAIL"
fail
$TEST_NAME
"02-2:FAIL"
else
else
...
@@ -123,7 +123,7 @@ test_002(){
...
@@ -123,7 +123,7 @@ test_002(){
success
$TEST_NAME
"02-3:PASS"
success
$TEST_NAME
"02-3:PASS"
fi
fi
out1
=
`
lcrc
exec
two sh
-c
"cd tmp && ls"
`
out1
=
`
isula
exec
two sh
-c
"cd tmp && ls"
`
if
[
"
$out1
"
==
"b.txt"
]
;
then
if
[
"
$out1
"
==
"b.txt"
]
;
then
success
$TEST_NAME
"02-4:PASS"
success
$TEST_NAME
"02-4:PASS"
else
else
...
@@ -131,29 +131,29 @@ test_002(){
...
@@ -131,29 +131,29 @@ test_002(){
fi
fi
#test stop start
#test stop start
lcrc
stop two
>
/dev/null
isula
stop two
>
/dev/null
container_status
$container_ID2
container_status
$container_ID2
if
[
"
${
status
}
x"
!=
"exitedx"
]
;
then
if
[
"
${
status
}
x"
!=
"exitedx"
]
;
then
fail
$TEST_NAME
"02-5:FAIL"
fail
$TEST_NAME
"02-5:FAIL"
fi
fi
lcrc
start two
>
/dev/null
isula
start two
>
/dev/null
container_status
$container_ID2
container_status
$container_ID2
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
fail
$TEST_NAME
"02-6:FAIL"
fail
$TEST_NAME
"02-6:FAIL"
fi
fi
out1
=
`
lcrc
exec
two sh
-c
"cd tmp && ls"
`
out1
=
`
isula
exec
two sh
-c
"cd tmp && ls"
`
if
[
"
$out1
"
==
"b.txt"
]
;
then
if
[
"
$out1
"
==
"b.txt"
]
;
then
success
$TEST_NAME
"02-7:PASS"
success
$TEST_NAME
"02-7:PASS"
else
else
fail
$TEST_NAME
"02-7:FAIL"
fail
$TEST_NAME
"02-7:FAIL"
fi
fi
lcrc
rm
-f
one1
>
/dev/null
isula
rm
-f
one1
>
/dev/null
lcrc
rm
-f
two
>
/dev/null
isula
rm
-f
two
>
/dev/null
}
}
test_003
(){
test_003
(){
#test one direct is ro ,the other is direct is rw
#test one direct is ro ,the other is direct is rw
out
=
`
lcrc run
--name
one
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 1000"
`
out
=
`
isula run
--name
one
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 1000"
`
container_status
$out
container_status
$out
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
fail
$TEST_NAME
"03:FAIL"
fail
$TEST_NAME
"03:FAIL"
...
@@ -169,26 +169,26 @@ test_003(){
...
@@ -169,26 +169,26 @@ test_003(){
echo
cc
>
$TEST_FOLDER2
/c.txt
echo
cc
>
$TEST_FOLDER2
/c.txt
$ISULAD_TOOLS
add-path
$out
$TEST_FOLDER1
:/tmp:rw
$TEST_FOLDER2
:/home:ro
>
/dev/null 2>&1
$ISULAD_TOOLS
add-path
$out
$TEST_FOLDER1
:/tmp:rw
$TEST_FOLDER2
:/home:ro
>
/dev/null 2>&1
out1
=
`
lcrc
exec
one bash
-c
"cat /tmp/b.txt"
`
out1
=
`
isula
exec
one bash
-c
"cat /tmp/b.txt"
`
if
[
"
$out1
"
!=
"hello"
]
;
then
if
[
"
$out1
"
!=
"hello"
]
;
then
fail
$TEST_NAME
"03-1:FAIL"
fail
$TEST_NAME
"03-1:FAIL"
fi
fi
out1
=
`
lcrc
exec
one bash
-c
"cat /home/c.txt"
`
out1
=
`
isula
exec
one bash
-c
"cat /home/c.txt"
`
if
[
"
$out1
"
!=
"cc"
]
;
then
if
[
"
$out1
"
!=
"cc"
]
;
then
fail
$TEST_NAME
"03-2:FAIL"
fail
$TEST_NAME
"03-2:FAIL"
fi
fi
lcrc
exec
one bash
-c
"cd /home && echo hello>c.txt"
>
/dev/null 2>&1
isula
exec
one bash
-c
"cd /home && echo hello>c.txt"
>
/dev/null 2>&1
if
[
$?
-eq
0
]
;
then
if
[
$?
-eq
0
]
;
then
fail
$TEST_NAME
"03-3:FAIL"
fail
$TEST_NAME
"03-3:FAIL"
fi
fi
out
=
`
lcrc
exec
one bash
-c
"cd /home && cat c.txt"
`
out
=
`
isula
exec
one bash
-c
"cd /home && cat c.txt"
`
if
[
"
$out
"
==
"cc"
]
;
then
if
[
"
$out
"
==
"cc"
]
;
then
success
$TEST_NAME
"03-4:PASS"
success
$TEST_NAME
"03-4:PASS"
else
else
fail
$TEST_NAME
"03-4:FAIL"
fail
$TEST_NAME
"03-4:FAIL"
fi
fi
lcrc
rm
-f
one
>
/dev/null
isula
rm
-f
one
>
/dev/null
}
}
main
(){
main
(){
...
...
test/path_test.sh
浏览文件 @
58cdc83a
...
@@ -20,13 +20,13 @@
...
@@ -20,13 +20,13 @@
TEST_NAME
=
"test_path"
TEST_NAME
=
"test_path"
test_001
(){
test_001
(){
out
=
`
lcrc run
--name
one
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 100000"
`
out
=
`
isula run
--name
one
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 100000"
`
container_status
$out
container_status
$out
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
fail
$TEST_NAME
"01:FAIL"
fail
$TEST_NAME
"01:FAIL"
fi
fi
out1
=
`
lcrc
ps |
grep
one |
awk
'{print $1}'
`
out1
=
`
isula
ps |
grep
one |
awk
'{print $1}'
`
TEST_FOLDER
=
$TMP
/
$TEST_NAME
/001
TEST_FOLDER
=
$TMP
/
$TEST_NAME
/001
if
[
-d
$TEST_FOLDER
]
;
then
if
[
-d
$TEST_FOLDER
]
;
then
rm
-rf
$TEST_FOLDER
>
/dev/null
rm
-rf
$TEST_FOLDER
>
/dev/null
...
@@ -41,7 +41,7 @@ test_001(){
...
@@ -41,7 +41,7 @@ test_001(){
fail
$TEST_NAME
"01-1:FAIL"
fail
$TEST_NAME
"01-1:FAIL"
fi
fi
out
=
`
lcrc
exec
one sh
-c
"cat /tmp/b.txt"
`
out
=
`
isula
exec
one sh
-c
"cat /tmp/b.txt"
`
if
[
"
$out
"
==
"hello"
]
;
then
if
[
"
$out
"
==
"hello"
]
;
then
success
$TEST_NAME
"01-2:PASS"
success
$TEST_NAME
"01-2:PASS"
else
else
...
@@ -50,7 +50,7 @@ test_001(){
...
@@ -50,7 +50,7 @@ test_001(){
#test remove-path
#test remove-path
$ISULAD_TOOLS
remove-path
$out1
$TEST_FOLDER
:/tmp
>
/dev/null
$ISULAD_TOOLS
remove-path
$out1
$TEST_FOLDER
:/tmp
>
/dev/null
out
=
`
lcrc
exec
one sh
-c
"cd tmp && ls"
>
/dev/null 2>&1
`
out
=
`
isula
exec
one sh
-c
"cd tmp && ls"
>
/dev/null 2>&1
`
if
[
"
$out
"
==
""
]
;
then
if
[
"
$out
"
==
""
]
;
then
success
$TEST_NAME
"01-3:PASS"
success
$TEST_NAME
"01-3:PASS"
else
else
...
@@ -58,12 +58,12 @@ test_001(){
...
@@ -58,12 +58,12 @@ test_001(){
fi
fi
# clean up container.
# clean up container.
lcrc
rm
-f
one
>
/dev/null
isula
rm
-f
one
>
/dev/null
}
}
test_002
(){
test_002
(){
#test exited container
#test exited container
out
=
`
lcrc run
--name
one
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
`
out
=
`
isula run
--name
one
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
`
sleep
3
sleep
3
container_status
$out
container_status
$out
if
[
"
${
status
}
x"
!=
"exitedx"
]
;
then
if
[
"
${
status
}
x"
!=
"exitedx"
]
;
then
...
@@ -77,12 +77,12 @@ test_002(){
...
@@ -77,12 +77,12 @@ test_002(){
else
else
fail
$TEST_NAME
"02-1:Fail"
fail
$TEST_NAME
"02-1:Fail"
fi
fi
lcrc
rm
one
>
/dev/null
isula
rm
one
>
/dev/null
}
}
test_003
(){
test_003
(){
#test created container
#test created container
out
=
`
lcrc create
--name
one
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-ti
$UBUNTU_IMAGE
`
out
=
`
isula create
--name
one
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-ti
$UBUNTU_IMAGE
`
container_status
$out
container_status
$out
if
[
"
${
status
}
x"
!=
"createdx"
]
;
then
if
[
"
${
status
}
x"
!=
"createdx"
]
;
then
success
$TEST_NAME
"03:PASS"
success
$TEST_NAME
"03:PASS"
...
@@ -102,11 +102,11 @@ test_003(){
...
@@ -102,11 +102,11 @@ test_003(){
echo
hello
>
$TEST_FOLDER
/b.txt
echo
hello
>
$TEST_FOLDER
/b.txt
#created->up container
#created->up container
out1
=
`
lcrc
start one
`
out1
=
`
isula
start one
`
sleep
1
sleep
1
out
=
`
lcrc
ps |
grep
one |
awk
'{print $1}'
`
out
=
`
isula
ps |
grep
one |
awk
'{print $1}'
`
$ISULAD_TOOLS
add-path
$out
$TEST_FOLDER
:/tmp:ro
>
/dev/null 2>&1
$ISULAD_TOOLS
add-path
$out
$TEST_FOLDER
:/tmp:ro
>
/dev/null 2>&1
out1
=
`
lcrc
exec
$out
sh
-c
"cat /tmp/b.txt"
`
out1
=
`
isula
exec
$out
sh
-c
"cat /tmp/b.txt"
`
if
[
"
$out1
"
==
"hello"
]
;
then
if
[
"
$out1
"
==
"hello"
]
;
then
success
$TEST_NAME
"03-2:PASS"
success
$TEST_NAME
"03-2:PASS"
else
else
...
@@ -114,7 +114,7 @@ test_003(){
...
@@ -114,7 +114,7 @@ test_003(){
fi
fi
#test ro
#test ro
lcrc
exec
one sh
-c
"cd tmp && ls && echo abcddd> b.txt"
>
/dev/null 2>&1
isula
exec
one sh
-c
"cd tmp && ls && echo abcddd> b.txt"
>
/dev/null 2>&1
out
=
`
echo
$?
`
out
=
`
echo
$?
`
if
[
$out
-ne
0
]
;
then
if
[
$out
-ne
0
]
;
then
success
$TEST_NAME
"03-2:PASS"
success
$TEST_NAME
"03-2:PASS"
...
@@ -122,20 +122,20 @@ test_003(){
...
@@ -122,20 +122,20 @@ test_003(){
fail
$TEST_NAME
"03-2:FAIL"
fail
$TEST_NAME
"03-2:FAIL"
fi
fi
out
=
`
lcrc
ps |
grep
one |
awk
'{print $1}'
`
out
=
`
isula
ps |
grep
one |
awk
'{print $1}'
`
lcrc
rm
-f
one
>
/dev/null
isula
rm
-f
one
>
/dev/null
}
}
test_005
(){
test_005
(){
#test mount a Empty dirct
#test mount a Empty dirct
out
=
`
lcrc run
--name
one
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 10000"
`
out
=
`
isula run
--name
one
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 10000"
`
container_status
$out
container_status
$out
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
fail
$TEST_NAME
"05:FAIL"
fail
$TEST_NAME
"05:FAIL"
fi
fi
mkdir
-p
/tmp/isulad_test/test
mkdir
-p
/tmp/isulad_test/test
$ISULAD_TOOLS
add-path
$out
/tmp/isulad_test/test:/tmp:rw
>
/dev/null 2>&1
$ISULAD_TOOLS
add-path
$out
/tmp/isulad_test/test:/tmp:rw
>
/dev/null 2>&1
out1
=
`
lcrc
exec
one bash
-c
"mount | awk 'END{print
$1
}'"
`
out1
=
`
isula
exec
one bash
-c
"mount | awk 'END{print
$1
}'"
`
out1
=
${
out1
%on*
}
out1
=
${
out1
%on*
}
out2
=
${
out1
##*/
}
out2
=
${
out1
##*/
}
if
[
"
$out1
"
==
"/dev/
$out2
"
]
;
then
if
[
"
$out1
"
==
"/dev/
$out2
"
]
;
then
...
@@ -143,28 +143,28 @@ test_005(){
...
@@ -143,28 +143,28 @@ test_005(){
else
else
fail
$TEST_NAME
"05-1:FAIL"
fail
$TEST_NAME
"05-1:FAIL"
fi
fi
lcrc
rm
-f
one
>
/dev/null
isula
rm
-f
one
>
/dev/null
}
}
test_006
(){
test_006
(){
#test can not add ro and rw
#test can not add ro and rw
out
=
`
lcrc run
--name
one
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 10000"
`
out
=
`
isula run
--name
one
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 10000"
`
container_status
$out
container_status
$out
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
fail
$TEST_NAME
"06:FAIL"
fail
$TEST_NAME
"06:FAIL"
fi
fi
out
=
`
lcrc
exec
$out
sh
-c
"cd tmp && ls && echo cc > b.txt && cat b.txt"
`
out
=
`
isula
exec
$out
sh
-c
"cd tmp && ls && echo cc > b.txt && cat b.txt"
`
if
[
"
$out
"
==
"cc"
]
;
then
if
[
"
$out
"
==
"cc"
]
;
then
success
$TEST_NAME
"06-1:PASS"
success
$TEST_NAME
"06-1:PASS"
else
else
fail
$TEST_NAME
"06-1:FAIL"
fail
$TEST_NAME
"06-1:FAIL"
fi
fi
lcrc
rm
-f
one
>
/dev/null
isula
rm
-f
one
>
/dev/null
}
}
test_007
(){
test_007
(){
#test remove dirct
#test remove dirct
out
=
`
lcrc run
--name
one
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 10000"
`
out
=
`
isula run
--name
one
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 10000"
`
container_status
$out
container_status
$out
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
if
[
"
${
status
}
x"
!=
"runningx"
]
;
then
fail
$TEST_NAME
"07:FAIL"
fail
$TEST_NAME
"07:FAIL"
...
@@ -183,14 +183,14 @@ test_007(){
...
@@ -183,14 +183,14 @@ test_007(){
if
[
$out
-ne
0
]
;
then
if
[
$out
-ne
0
]
;
then
fail
$TEST_NAME
"07-1:FAIL"
fail
$TEST_NAME
"07-1:FAIL"
fi
fi
out
=
`
lcrc
exec
one bash
-c
"cat /tmp/b.txt"
`
out
=
`
isula
exec
one bash
-c
"cat /tmp/b.txt"
`
if
[
"
$out
"
!=
"hello"
]
;
then
if
[
"
$out
"
!=
"hello"
]
;
then
fail
$TEST_NAME
"07-2:FAIL"
fail
$TEST_NAME
"07-2:FAIL"
fi
fi
# remove the path from container.
# remove the path from container.
$ISULAD_TOOLS
remove-path one
$TEST_FOLDER
:/tmp:rw
>
/dev/null
$ISULAD_TOOLS
remove-path one
$TEST_FOLDER
:/tmp:rw
>
/dev/null
out
=
`
lcrc
exec
one bash
-c
"ls -l /tmp"
`
out
=
`
isula
exec
one bash
-c
"ls -l /tmp"
`
if
[
"
$out
"
==
"total 0"
]
;
then
if
[
"
$out
"
==
"total 0"
]
;
then
success
$TEST_NAME
"07-3:PASS"
success
$TEST_NAME
"07-3:PASS"
else
else
...
@@ -198,12 +198,12 @@ test_007(){
...
@@ -198,12 +198,12 @@ test_007(){
fi
fi
# clean up container.
# clean up container.
lcrc
rm
-f
one
>
/dev/null
isula
rm
-f
one
>
/dev/null
}
}
test_008
(){
test_008
(){
out
=
`
lcrc run
--name
one
--hook-spec
/var/lib/lcr
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 100000"
`
out
=
`
isula run
--name
one
--hook-spec
/var/lib/isula
d/hooks/hookspec.json
-d
$UBUNTU_IMAGE
bash
-c
"sleep 100000"
`
out2
=
`
lcrc
ps |
grep
one |
awk
'{print $1}'
`
out2
=
`
isula
ps |
grep
one |
awk
'{print $1}'
`
$ISULAD_TOOLS
add-path
$out2
$out1
:/tmp:rw
>
/dev/null 2>&1
$ISULAD_TOOLS
add-path
$out2
$out1
:/tmp:rw
>
/dev/null 2>&1
out
=
`
echo
$?
`
out
=
`
echo
$?
`
if
[
$out
-ne
0
]
;
then
if
[
$out
-ne
0
]
;
then
...
@@ -211,7 +211,7 @@ test_008(){
...
@@ -211,7 +211,7 @@ test_008(){
else
else
fail
$TEST_NAME
"08-1:FAIL"
fail
$TEST_NAME
"08-1:FAIL"
fi
fi
lcrc
rm
-f
one
>
/dev/null
isula
rm
-f
one
>
/dev/null
}
}
main
(){
main
(){
test_001
test_001
...
...
test/route_test.sh
浏览文件 @
58cdc83a
...
@@ -23,12 +23,12 @@ test_001(){
...
@@ -23,12 +23,12 @@ test_001(){
ip
link set
$BR
up
ip
link set
$BR
up
ip a a 192.168.182.1/24 dev
$BR
ip a a 192.168.182.1/24 dev
$BR
CONTAINER_ID
=
`
lcrc
run
-d
--net
none
$BUSYBOX_IMAGE
top
`
CONTAINER_ID
=
`
isula
run
-d
--net
none
$BUSYBOX_IMAGE
top
`
$ISULAD_TOOLS
--debug
--log
$TMP
/isulad-tools.log add-nic
\
$ISULAD_TOOLS
--debug
--log
$TMP
/isulad-tools.log add-nic
\
--type
veth
--name
eth0
--ip
192.168.182.2/24
\
--type
veth
--name
eth0
--ip
192.168.182.2/24
\
--mac
"aa:bb:cc:dd:ee:aa"
--bridge
$BR
--mtu
1450
\
--mac
"aa:bb:cc:dd:ee:aa"
--bridge
$BR
--mtu
1450
\
$CONTAINER_ID
$CONTAINER_ID
lcrc
exec
--privileged
$CONTAINER_ID
ip route delete 192.168.182.0/24
isula
exec
--privileged
$CONTAINER_ID
ip route delete 192.168.182.0/24
$ISULAD_TOOLS
add-route
$CONTAINER_ID
'[{"dest":"192.168.182.0/24", "src":"192.168.182.2","dev":"eth0"}]'
$ISULAD_TOOLS
add-route
$CONTAINER_ID
'[{"dest":"192.168.182.0/24", "src":"192.168.182.2","dev":"eth0"}]'
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
fail
$TEST_NAME
"01-1:FAIL"
fail
$TEST_NAME
"01-1:FAIL"
...
@@ -44,14 +44,14 @@ test_001(){
...
@@ -44,14 +44,14 @@ test_001(){
# success $TEST_NAME "01-1:PASS"
# success $TEST_NAME "01-1:PASS"
#fi
#fi
rules
=
`
lcrc
exec
$CONTAINER_ID
ip route
`
rules
=
`
isula
exec
$CONTAINER_ID
ip route
`
echo
$rules
|
grep
"192.168.182.0/24 dev eth0 src 192.168.182.2"
>
/dev/null 2>&1
echo
$rules
|
grep
"192.168.182.0/24 dev eth0 src 192.168.182.2"
>
/dev/null 2>&1
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
fail
$TEST_NAME
"01-2:FAIL"
fail
$TEST_NAME
"01-2:FAIL"
else
else
success
$TEST_NAME
"01-2:PASS"
success
$TEST_NAME
"01-2:PASS"
fi
fi
lcrc
rm
-f
$CONTAINER_ID
>
/dev/null 2>&1
isula
rm
-f
$CONTAINER_ID
>
/dev/null 2>&1
brctl delbr
$BR
>
/dev/null 2>&1
brctl delbr
$BR
>
/dev/null 2>&1
}
}
...
...
test/tools.sh
浏览文件 @
58cdc83a
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
container_status
(){
container_status
(){
id
=
$1
id
=
$1
status
=
`
lcrc
inspect
${
id
:00:12
}
|
grep
Status |
awk
-F
":"
'{print $2}'
`
status
=
`
isula
inspect
${
id
:00:12
}
|
grep
Status |
awk
-F
":"
'{print $2}'
`
status
=
${
status
#*\
"}
status
=
${
status
#*\
"}
status=
${
status
%%\
"*}
status=
${
status
%%\
"*}
}
}
...
...
utils/hooks.go
浏览文件 @
58cdc83a
...
@@ -25,7 +25,7 @@ import (
...
@@ -25,7 +25,7 @@ import (
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-spec/specs-go"
)
)
//
lcrc
info may result in dead lock when start with restart policy
//
isula
info may result in dead lock when start with restart policy
// try to get isulad root path with hook path
// try to get isulad root path with hook path
func
getGraphDriverPath
()
(
string
,
error
)
{
func
getGraphDriverPath
()
(
string
,
error
)
{
path
,
err
:=
os
.
Executable
()
path
,
err
:=
os
.
Executable
()
...
@@ -33,7 +33,7 @@ func getGraphDriverPath() (string, error) {
...
@@ -33,7 +33,7 @@ func getGraphDriverPath() (string, error) {
return
""
,
err
return
""
,
err
}
}
// get /var/lib/
lcrd from /var/lib/lcr
d/hooks/isulad-hooks
// get /var/lib/
isulad from /var/lib/isula
d/hooks/isulad-hooks
dir
:=
filepath
.
Dir
(
filepath
.
Dir
(
path
))
dir
:=
filepath
.
Dir
(
filepath
.
Dir
(
path
))
return
dir
,
nil
return
dir
,
nil
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录