Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
0d31bb4b
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,发现更多精彩内容 >>
提交
0d31bb4b
编写于
5月 06, 2020
作者:
W
wujing
提交者:
lifeng68
7月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
image health check config unit test
Signed-off-by:
N
wujing
<
wujing50@huawei.com
>
上级
28ad73d6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
44 deletion
+29
-44
src/image/oci/storage/image_store/image_store.c
src/image/oci/storage/image_store/image_store.c
+16
-37
test/image/oci/storage/images/data/resources/ffc8ef7968a2acb7545006bed022001addaa262c0f760883146c4a4fae54e689/=c2hhMjU2OmZmYzhlZjc5NjhhMmFjYjc1NDUwMDZiZWQwMjIwMDFhZGRhYTI2MmMwZjc2MDg4MzE0NmM0YTRmYWU1NGU2ODk=
...iZWQwMjIwMDFhZGRhYTI2MmMwZjc2MDg4MzE0NmM0YTRmYWU1NGU2ODk=
+1
-1
test/image/oci/storage/images/storage_images_llt.cc
test/image/oci/storage/images/storage_images_llt.cc
+12
-6
未找到文件。
src/image/oci/storage/image_store/image_store.c
浏览文件 @
0d31bb4b
...
...
@@ -1455,10 +1455,12 @@ static int append_big_data_name(storage_image *image, const char *name)
static
int
update_image_with_big_data
(
image_t
*
image
,
const
char
*
key
,
const
char
*
data
,
bool
*
should_save
)
{
int
ret
=
0
;
bool
size_found
=
false
;
int64_t
old_size
;
const
char
*
old_digest
=
NULL
;
char
*
new_digest
=
NULL
;
char
*
full_digest
=
NULL
;
bool
add_name
=
true
;
size_t
i
;
digest_image_t
*
digest_filter_images
=
NULL
;
...
...
@@ -1489,10 +1491,11 @@ static int update_image_with_big_data(image_t *image, const char *key, const cha
old_digest
=
get_value_from_json_map_string_string
(
im
->
big_data_digests
,
key
);
new_digest
=
sha256_digest_str
(
data
);
full_digest
=
util_full_digest
(
new_digest
);
if
(
old_digest
!=
NULL
)
{
update_json_map_string_string
(
im
->
big_data_digests
,
key
,
new
_digest
);
update_json_map_string_string
(
im
->
big_data_digests
,
key
,
full
_digest
);
}
else
{
append_json_map_string_string
(
im
->
big_data_digests
,
key
,
new
_digest
);
append_json_map_string_string
(
im
->
big_data_digests
,
key
,
full
_digest
);
}
if
(
!
size_found
||
old_size
!=
(
int64_t
)
strlen
(
data
)
||
old_digest
==
NULL
||
strcmp
(
old_digest
,
new_digest
)
!=
0
)
{
...
...
@@ -1509,7 +1512,8 @@ static int update_image_with_big_data(image_t *image, const char *key, const cha
if
(
add_name
)
{
if
(
append_big_data_name
(
im
,
key
)
!=
0
)
{
ERROR
(
"Failed to append big data name"
);
return
-
1
;
ret
=
-
1
;
goto
out
;
}
*
should_save
=
true
;
}
...
...
@@ -1519,7 +1523,8 @@ static int update_image_with_big_data(image_t *image, const char *key, const cha
if
(
remove_image_from_digest_index
(
g_image_store
,
image
,
old_digest
)
!=
0
)
{
ERROR
(
"Failed to remove the image from the list of images in the digest-based "
"index which corresponds to the old digest for this item, unless it's also the hard-coded digest"
);
return
-
1
;
ret
=
-
1
;
goto
out
;
}
}
...
...
@@ -1530,12 +1535,16 @@ static int update_image_with_big_data(image_t *image, const char *key, const cha
digest_image_slice_without_value
(
digest_filter_images
,
image
);
if
(
append_image_to_digest_images
(
digest_filter_images
,
image
)
!=
0
)
{
ERROR
(
"Failed to append image to digest images"
);
return
-
1
;
ret
=
-
1
;
goto
out
;
}
}
}
return
0
;
out:
free
(
new_digest
);
free
(
full_digest
);
return
ret
;
}
int
image_store_set_big_data
(
const
char
*
id
,
const
char
*
key
,
const
char
*
data
)
...
...
@@ -2072,33 +2081,6 @@ out:
return
ret
;
}
/*typedef struct {
char *id;
char **repo_tags;
size_t repo_tags_len;
char **repo_digests;
size_t repo_digests_len;
uint64_t size;
char *created;
char *loaded;
imagetool_image_uid *uid;
char *username;
oci_image_spec *spec;
defs_health_check *healthcheck;
}
imagetool_image;*/
static
int
resort_image_names
(
const
char
**
names
,
size_t
names_len
,
char
**
first_name
,
char
***
image_tags
,
char
***
image_digests
)
{
...
...
@@ -2402,7 +2384,6 @@ static imagetool_image *get_image_info(const image_t *image)
}
nret
=
asprintf
(
&
sha256_key
,
"sha256:%s"
,
img
->
id
);
// if (nret < 0 || (size_t)nret > strlen("sha256:") + strlen(img->id) + 1) {
if
(
nret
<
0
)
{
ERROR
(
"Failed to get sha256 key"
);
ret
=
-
1
;
...
...
@@ -2430,7 +2411,7 @@ static imagetool_image *get_image_info(const image_t *image)
}
if
(
pack_image_summary_item
(
config_file
,
info
)
!=
0
)
{
ERROR
(
"Failed to pack
health check config
from image config"
);
ERROR
(
"Failed to pack
image summary item
from image config"
);
ret
=
-
1
;
goto
out
;
}
...
...
@@ -2446,8 +2427,6 @@ static imagetool_image *get_image_info(const image_t *image)
goto
out
;
}
// info->size = img->names_len;
out:
if
(
ret
!=
0
)
{
free_imagetool_image
(
info
);
...
...
test/image/oci/storage/images/data/resources/ffc8ef7968a2acb7545006bed022001addaa262c0f760883146c4a4fae54e689/=c2hhMjU2OmZmYzhlZjc5NjhhMmFjYjc1NDUwMDZiZWQwMjIwMDFhZGRhYTI2MmMwZjc2MDg4MzE0NmM0YTRmYWU1NGU2ODk=
浏览文件 @
0d31bb4b
{"architecture":"amd64","config":{"Hostname":"","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sh"],"Healthcheck":{"Test":["CMD-SHELL","date \u003e\u003e /tmp/health_check || exit 1"],"Interval":3000000000,"Timeout":3000000000,"StartPeriod":1000000000,"Retries":3,"ExitOnUnhealthy":true},"ArgsEscaped":true,"Image":"sha256:e4db68de4ff27c2adfea0c54bbb73a61a42f5b667c326de4d7d5b19ab71c6a3b","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":null,"Annotations":null},"container":"ed0b5c882c5b98b9f67a6dff3be078658d45d49540c8d8778b878d68a75bd8b7","container_config":{"Hostname":"ed0b5c882c5b","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh","-c","#(nop) ","HEALTHCHECK \u0026{[\"CMD-SHELL\" \"date \u003e\u003e /tmp/health_check || exit 1\"] \"3s\" \"3s\" \"1s\" '\\x03' %!q(bool=true)}"],"Healthcheck":{"Test":["CMD-SHELL","date \u003e\u003e /tmp/health_check || exit 1"],"Interval":3000000000,"Timeout":3000000000,"StartPeriod":1000000000,"Retries":3,"ExitOnUnhealthy":true},"ArgsEscaped":true,"Image":"sha256:e4db68de4ff27c2adfea0c54bbb73a61a42f5b667c326de4d7d5b19ab71c6a3b","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":{},"Annotations":{"native.umask":"secure"}},"created":"2020-03-30T08:02:50.586247435Z","docker_version":"dev","history":[{"created":"2019-06-15T00:19:54.271494486Z","created_by":"/bin/sh -c #(nop) ADD file:b265aa0ea2ef7ff1f4a3e087217e75aca2c90f5c345406299664cc7969b2b28e in / "},{"created":"2019-06-15T00:19:54.402459069Z","created_by":"/bin/sh -c #(nop) CMD [\"sh\"]","empty_layer":true},{"created":"2020-03-30T08:02:50.586247435Z","created_by":"/bin/sh -c #(nop) HEALTHCHECK \u0026{[\"CMD-SHELL\" \"date \u003e\u003e /tmp/health_check || exit 1\"] \"3s\" \"3s\" \"1s\" '\\x03' %!q(bool=true)}","empty_layer":true}],"os":"linux","rootfs":{"type":"layers","diff_ids":["sha256:6194458b07fcf01f1483d96cd6c34302ffff7f382bb151a6d023c4e80ba3050a"]}}
\ No newline at end of file
{"architecture":"amd64","config":{"Hostname":"","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sh"],"HealthCheck":{"Test":["CMD-SHELL","date \u003e\u003e /tmp/health_check || exit 1"],"Interval":3000000000,"Timeout":3000000000,"StartPeriod":1000000000,"Retries":3,"ExitOnUnhealthy":true},"ArgsEscaped":true,"Image":"sha256:e4db68de4ff27c2adfea0c54bbb73a61a42f5b667c326de4d7d5b19ab71c6a3b","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":null,"Annotations":null},"container":"ed0b5c882c5b98b9f67a6dff3be078658d45d49540c8d8778b878d68a75bd8b7","container_config":{"Hostname":"ed0b5c882c5b","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh","-c","#(nop) ","HEALTHCHECK \u0026{[\"CMD-SHELL\" \"date \u003e\u003e /tmp/health_check || exit 1\"] \"3s\" \"3s\" \"1s\" '\\x03' %!q(bool=true)}"],"HealthCheck":{"Test":["CMD-SHELL","date \u003e\u003e /tmp/health_check || exit 1"],"Interval":3000000000,"Timeout":3000000000,"StartPeriod":1000000000,"Retries":3,"ExitOnUnhealthy":true},"ArgsEscaped":true,"Image":"sha256:e4db68de4ff27c2adfea0c54bbb73a61a42f5b667c326de4d7d5b19ab71c6a3b","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":{},"Annotations":{"native.umask":"secure"}},"created":"2020-03-30T08:02:50.586247435Z","docker_version":"dev","history":[{"created":"2019-06-15T00:19:54.271494486Z","created_by":"/bin/sh -c #(nop) ADD file:b265aa0ea2ef7ff1f4a3e087217e75aca2c90f5c345406299664cc7969b2b28e in / "},{"created":"2019-06-15T00:19:54.402459069Z","created_by":"/bin/sh -c #(nop) CMD [\"sh\"]","empty_layer":true},{"created":"2020-03-30T08:02:50.586247435Z","created_by":"/bin/sh -c #(nop) HEALTHCHECK \u0026{[\"CMD-SHELL\" \"date \u003e\u003e /tmp/health_check || exit 1\"] \"3s\" \"3s\" \"1s\" '\\x03' %!q(bool=true)}","empty_layer":true}],"os":"linux","rootfs":{"type":"layers","diff_ids":["sha256:6194458b07fcf01f1483d96cd6c34302ffff7f382bb151a6d023c4e80ba3050a"]}}
test/image/oci/storage/images/storage_images_llt.cc
浏览文件 @
0d31bb4b
...
...
@@ -248,7 +248,7 @@ TEST_F(StorageImagesUnitTest, test_image_store_create)
GetDirectory
()
+
"/data/resources/ffc8ef7968a2acb7545006bed022001addaa262c0f760883146c4a4fae54e689/"
"=c2hhMjU2OmZmYzhlZjc5NjhhMmFjYjc1NDUwMDZiZWQwMjIwMDFhZGRhYTI2MmMwZjc2MDg4MzE0NmM0YTRmYWU1NGU2ODk="
;
ASSERT_STRNE
(
cleanpath
(
config_file
.
c_str
(),
real_path
,
sizeof
(
real_path
)),
nullptr
);
ASSERT_STRNE
(
cleanpath
(
config_file
.
c_str
(),
real_path
,
sizeof
(
real_path
)),
"manifest"
);
std
::
ifstream
t
(
real_path
);
std
::
string
buffer
((
std
::
istreambuf_iterator
<
char
>
(
t
)),
...
...
@@ -277,21 +277,27 @@ TEST_F(StorageImagesUnitTest, test_image_store_create)
auto
image
=
image_store_get_image
(
id
.
c_str
());
ASSERT_NE
(
image
,
nullptr
);
// ASSERT_STREQ(image->created, "2020-03-30T08:02:50.586247435Z");
// ASSERT_STREQ(image->loaded, "2020-04-29T09:06:29.385966253Z");
ASSERT_NE
(
image
->
created
,
nullptr
);
ASSERT_NE
(
image
->
loaded
,
nullptr
);
ASSERT_NE
(
image
->
repo_tags
,
nullptr
);
ASSERT_EQ
(
image
->
repo_tags_len
,
1
);
ASSERT_STREQ
(
image
->
repo_tags
[
0
],
"docker.io/library/health_check:latest"
);
ASSERT_EQ
(
image
->
healthcheck
,
nullptr
);
ASSERT_EQ
(
image
->
username
,
nullptr
);
ASSERT_EQ
(
image
->
size
,
0
);
ASSERT_EQ
(
image
->
spec
->
config
->
env_len
,
1
);
ASSERT_STREQ
(
image
->
spec
->
config
->
env
[
0
],
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
);
ASSERT_EQ
(
image
->
spec
->
config
->
cmd_len
,
4
);
ASSERT_STREQ
(
image
->
spec
->
config
->
cmd
[
0
],
"/bin/bash"
);
ASSERT_EQ
(
image
->
spec
->
config
->
cmd_len
,
1
);
ASSERT_STREQ
(
image
->
spec
->
config
->
cmd
[
0
],
"sh"
);
ASSERT_NE
(
image
->
healthcheck
,
nullptr
);
ASSERT_EQ
(
image
->
healthcheck
->
test_len
,
2
);
ASSERT_STREQ
(
image
->
healthcheck
->
test
[
0
],
"CMD-SHELL"
);
ASSERT_STREQ
(
image
->
healthcheck
->
test
[
1
],
"date >> /tmp/health_check || exit 1"
);
ASSERT_EQ
(
image
->
healthcheck
->
interval
,
3000000000
);
ASSERT_EQ
(
image
->
healthcheck
->
retries
,
3
);
ASSERT_EQ
(
image
->
healthcheck
->
start_period
,
1000000000
);
ASSERT_EQ
(
image
->
healthcheck
->
timeout
,
3000000000
);
ASSERT_TRUE
(
image
->
healthcheck
->
exit_on_unhealthy
);
ASSERT_EQ
(
image_store_delete
(
id
.
c_str
()),
0
);
ASSERT_EQ
(
image_store_get_image
(
id
.
c_str
()),
nullptr
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录