Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
beab9b2f
I
iSulad
项目概览
openeuler
/
iSulad
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
iSulad
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
beab9b2f
编写于
7月 07, 2020
作者:
W
wujing
提交者:
lifeng68
7月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add health check testcase
Signed-off-by:
N
wujing
<
wujing50@huawei.com
>
上级
32c7d43c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
178 addition
and
3 deletion
+178
-3
CI/make-and-install.sh
CI/make-and-install.sh
+2
-1
CI/test_cases/container_cases/health_check.bash
CI/test_cases/container_cases/health_check.bash
+172
-0
test/image/oci/storage/images/storage_images_ut.cpp
test/image/oci/storage/images/storage_images_ut.cpp
+4
-2
未找到文件。
CI/make-and-install.sh
浏览文件 @
beab9b2f
...
...
@@ -85,10 +85,11 @@ if [[ "x${GCOV}" == "xON" ]]; then
else
cmake
-DCMAKE_BUILD_TYPE
=
Debug
-DENABLE_UT
=
ON ..
make
-j
$(
nproc
)
ctest
-D
ExperimentalCoverage
ctest
if
[[
$?
-ne
0
]]
;
then
exit
1
fi
ctest
-D
ExperimentalCoverage
fi
echo_success
"===================RUN DT-LLT TESTCASES END========================="
...
...
CI/test_cases/container_cases/health_check.bash
0 → 100755
浏览文件 @
beab9b2f
#!/bin/bash
#
# attributes: isulad basic container create run healthcheck
# concurrent: NA
# spend time: 20
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
# - iSulad licensed under the Mulan PSL v2.
# - You can use this software according to the terms and conditions of the Mulan PSL v2.
# - You may obtain a copy of Mulan PSL v2 at:
# - http://license.coscl.org.cn/MulanPSL2
# - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# - PURPOSE.
# - See the Mulan PSL v2 for more details.
##- @Description:CI
##- @Author: WuJing
##- @Create: 2020-07-07
#######################################################################
declare
-r
curr_path
=
$(
dirname
$(
readlink
-f
"
$0
"
))
source
../helpers.bash
image
=
"busybox"
isula pull
${
image
}
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- failed to pull image:
${
image
}
"
&&
exit
${
FAILURE
}
function
test_health_check_paraments
()
{
local
ret
=
0
local test
=
"list && inspect image info test => (
${
FUNCNAME
[@]
}
)"
msg_info
"
${
test
}
starting..."
isula images |
grep
${
image
}
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- missing list image:
${
image
}
"
&&
((
ret++
))
container_name
=
"health_check_para"
isula run
-itd
-n
${
container_name
}
--health-cmd
'echo "iSulad" ; exit 1'
\
--health-interval
2s
--health-retries
2
--health-start-period
2s
--health-exit-on-unhealthy
${
image
}
/bin/sh
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- failed to run container with image:
${
image
}
"
&&
((
ret++
))
# start period : 2s => do health check => interval: 2s => do health check => exit on unhealthy
[[
$(
isula inspect
-f
'{{.State.Status}}'
${
container_name
}
)
==
"running"
]]
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- incorrent container status: not running"
&&
((
ret++
))
sleep
3
# finish first health check
# keep starting status with health check return non-zero at always until status change to unhealthy
[[
$(
isula inspect
-f
'{{.State.Health.Status}}'
${
container_name
}
)
==
"starting"
]]
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- incorrent container health check status: not starting"
&&
((
ret++
))
sleep
2
# finish second health check
[[
$(
isula inspect
-f
'{{.State.Health.Status}}'
${
container_name
}
)
==
"unhealthy"
]]
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- incorrent container health check status: not unhealthy"
&&
((
ret++
))
# validate --health-retries option
[[
$(
isula inspect
-f
'{{.State.Health.FailingStreak}}'
${
container_name
}
)
==
"2"
]]
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- incorrent container health check status: not unhealthy"
&&
((
ret++
))
[[
$(
isula inspect
-f
'{{.State.Status}}'
${
container_name
}
)
==
"exited"
]]
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- incorrent container status: not exited"
&&
((
ret++
))
[[
$(
isula inspect
-f
'{{.State.ExitCode}}'
${
container_name
}
)
==
"137"
]]
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- incorrent container exit code: not 137"
&&
((
ret++
))
isula
rm
-f
${
container_name
}
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- failed to remove container:
${
container_name
}
"
&&
((
ret++
))
msg_info
"
${
test
}
finished with return
${
ret
}
..."
return
${
ret
}
}
function
test_health_check_normally
()
{
local
ret
=
0
local
image
=
"busybox"
local test
=
"list && inspect image info test => (
${
FUNCNAME
[@]
}
)"
msg_info
"
${
test
}
starting..."
isula images |
grep
${
image
}
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- missing list image:
${
image
}
"
&&
((
ret++
))
container_name
=
"health_check_normally"
isula run
-itd
-n
${
container_name
}
--health-cmd
'date'
--health-interval
2s
${
image
}
/bin/sh
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- failed to run container with image:
${
image
}
"
&&
((
ret++
))
# start period : 0s => interval: 2s => do health check => interval: 2s => do health check => ...
[[
$(
isula inspect
-f
'{{.State.Status}}'
${
container_name
}
)
==
"running"
]]
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- incorrent container status: not running"
&&
((
ret++
))
sleep
1
# Health check has been performed yet
# Initial status when the container is still starting
[[
$(
isula inspect
-f
'{{.State.Health.Status}}'
${
container_name
}
)
==
"starting"
]]
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- incorrent container health check status: not starting"
&&
((
ret++
))
sleep
2
# finish first health check
# When the health check returns successfully, status immediately becomes healthy
[[
$(
isula inspect
-f
'{{.State.Health.Status}}'
${
container_name
}
)
==
"healthy"
]]
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- incorrent container health check status: not healthy"
&&
((
ret++
))
kill
-9
$(
isula inspect
-f
'{{.State.Pid}}'
${
container_name
}
)
&&
sleep
1
# Wait for the container to be killed
# The container process exits abnormally and the health check status becomes unhealthy
[[
$(
isula inspect
-f
'{{.State.Health.Status}}'
${
container_name
}
)
==
"unhealthy"
]]
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- incorrent container health check status: not unhealthy"
&&
((
ret++
))
[[
$(
isula inspect
-f
'{{.State.ExitCode}}'
${
container_name
}
)
==
"137"
]]
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- incorrent container exit code: not 137"
&&
((
ret++
))
isula
rm
-f
${
container_name
}
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- failed to remove container:
${
container_name
}
"
&&
((
ret++
))
msg_info
"
${
test
}
finished with return
${
ret
}
..."
return
${
ret
}
}
function
test_health_check_timeout
()
{
local
ret
=
0
local
image
=
"busybox"
local test
=
"list && inspect image info test => (
${
FUNCNAME
[@]
}
)"
msg_info
"
${
test
}
starting..."
isula images |
grep
${
image
}
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- missing list image:
${
image
}
"
&&
((
ret++
))
container_name
=
"health_check_timeout"
isula run
-itd
-n
${
container_name
}
--health-cmd
'sleep 5'
--health-interval
2s
--health-timeout
1s
\
--health-retries
1
--health-exit-on-unhealthy
${
image
}
/bin/sh
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- failed to run container with image:
${
image
}
"
&&
((
ret++
))
# start period : 0s => interval: 2s => do health check(1s timeout) => unhealthy(exited)
[[
$(
isula inspect
-f
'{{.State.Status}}'
${
container_name
}
)
==
"running"
]]
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- incorrent container status: not running"
&&
((
ret++
))
sleep
1
# Health check has been performed yet
# Initial status when the container is still starting
[[
$(
isula inspect
-f
'{{.State.Health.Status}}'
${
container_name
}
)
==
"starting"
]]
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- incorrent container health check status: not starting"
&&
((
ret++
))
sleep
3
# finish first health check
# The container process exits and the health check status becomes unhealthy
[[
$(
isula inspect
-f
'{{.State.Health.Status}}'
${
container_name
}
)
==
"unhealthy"
]]
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- incorrent container health check status: not unhealthy"
&&
((
ret++
))
[[
$(
isula inspect
-f
'{{.State.ExitCode}}'
${
container_name
}
)
==
"137"
]]
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- incorrent container exit code: not 137"
&&
((
ret++
))
isula
rm
-f
${
container_name
}
[[
$?
-ne
0
]]
&&
msg_err
"
${
FUNCNAME
[0]
}
:
${
LINENO
}
- failed to remove container:
${
container_name
}
"
&&
((
ret++
))
msg_info
"
${
test
}
finished with return
${
ret
}
..."
return
${
ret
}
}
declare
-i
ans
=
0
test_health_check_paraments
||
((
ans++
))
test_health_check_normally
||
((
ans++
))
test_health_check_timeout
||
((
ans++
))
show_result
${
ans
}
"
${
curr_path
}
/
${
0
}
"
test/image/oci/storage/images/storage_images_ut.cpp
浏览文件 @
beab9b2f
...
...
@@ -597,15 +597,17 @@ TEST_F(StorageImagesUnitTest, test_image_store_get_something)
{
char
**
names
=
NULL
;
size_t
names_len
=
0
;
imagetool_fs_info
fs_info
;
imagetool_fs_info
*
fs_info
=
(
imagetool_fs_info
*
)
util_common_calloc_s
(
sizeof
(
imagetool_fs_info
));
ASSERT_NE
(
fs_info
,
nullptr
);
ASSERT_EQ
(
image_store_get_images_number
(),
2
);
ASSERT_EQ
(
image_store_get_fs_info
(
&
fs_info
),
0
);
ASSERT_EQ
(
image_store_get_fs_info
(
fs_info
),
0
);
ASSERT_EQ
(
image_store_get_names
(
ids
.
at
(
0
).
c_str
(),
&
names
,
&
names_len
),
0
);
ASSERT_EQ
(
names_len
,
1
);
ASSERT_STREQ
(
names
[
0
],
"imagehub.isulad.com/official/centos:latest"
);
util_free_array_by_len
(
names
,
names_len
);
free_imagetool_fs_info
(
fs_info
);
}
TEST_F
(
StorageImagesUnitTest
,
test_image_store_delete
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录