Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
68b7307a
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,发现更多精彩内容 >>
提交
68b7307a
编写于
7月 24, 2020
作者:
W
wujing
提交者:
lifeng68
7月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
image store: add remove name unit testcase
Signed-off-by:
N
wujing
<
wujing50@huawei.com
>
上级
b9353240
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
50 addition
and
14 deletion
+50
-14
test/image/oci/storage/images/storage_images_ut.cpp
test/image/oci/storage/images/storage_images_ut.cpp
+50
-14
未找到文件。
test/image/oci/storage/images/storage_images_ut.cpp
浏览文件 @
68b7307a
...
...
@@ -297,6 +297,22 @@ protected:
image_store_free
();
}
void
BackUp
()
{
std
::
string
backup
=
std
::
string
(
store_real_path
)
+
".bak"
;
std
::
string
command
=
"cp -r "
+
std
::
string
(
store_real_path
)
+
" "
+
backup
;
ASSERT_EQ
(
system
(
command
.
c_str
()),
0
);
}
void
Restore
()
{
std
::
string
backup
=
std
::
string
(
store_real_path
)
+
".bak"
;
std
::
string
rm_command
=
"rm -rf "
+
std
::
string
(
store_real_path
);
std
::
string
undo_command
=
"mv "
+
backup
+
" "
+
std
::
string
(
store_real_path
);
ASSERT_EQ
(
system
(
rm_command
.
c_str
()),
0
);
ASSERT_EQ
(
system
(
undo_command
.
c_str
()),
0
);
}
std
::
vector
<
std
::
string
>
ids
{
"39891ff67da98ab8540d71320915f33d2eb80ab42908e398472cab3c1ce7ac10"
,
"e4db68de4ff27c2adfea0c54bbb73a61a42f5b667c326de4d7d5b19ab71c6a3b"
};
char
store_real_path
[
PATH_MAX
]
=
{
0x00
};
...
...
@@ -612,11 +628,7 @@ TEST_F(StorageImagesUnitTest, test_image_store_get_something)
TEST_F
(
StorageImagesUnitTest
,
test_image_store_delete
)
{
std
::
string
backup
=
std
::
string
(
store_real_path
)
+
".bak"
;
std
::
string
command
=
"cp -r "
+
std
::
string
(
store_real_path
)
+
" "
+
backup
;
std
::
string
rm_command
=
"rm -rf "
+
std
::
string
(
store_real_path
);
std
::
string
undo_command
=
"mv "
+
backup
+
" "
+
std
::
string
(
store_real_path
);
ASSERT_EQ
(
system
(
command
.
c_str
()),
0
);
BackUp
();
for
(
auto
elem
:
ids
)
{
ASSERT_TRUE
(
image_store_exists
(
elem
.
c_str
()));
...
...
@@ -626,17 +638,12 @@ TEST_F(StorageImagesUnitTest, test_image_store_delete)
ASSERT_FALSE
(
dirExists
((
std
::
string
(
store_real_path
)
+
"/overlay-images/"
+
elem
).
c_str
()));
}
ASSERT_EQ
(
system
(
rm_command
.
c_str
()),
0
);
ASSERT_EQ
(
system
(
undo_command
.
c_str
()),
0
);
Restore
();
}
TEST_F
(
StorageImagesUnitTest
,
test_image_store_wipe
)
{
std
::
string
backup
=
std
::
string
(
store_real_path
)
+
".bak"
;
std
::
string
command
=
"cp -r "
+
std
::
string
(
store_real_path
)
+
" "
+
backup
;
std
::
string
rm_command
=
"rm -rf "
+
std
::
string
(
store_real_path
);
std
::
string
undo_command
=
"mv "
+
backup
+
" "
+
std
::
string
(
store_real_path
);
ASSERT_EQ
(
system
(
command
.
c_str
()),
0
);
BackUp
();
for
(
auto
elem
:
ids
)
{
ASSERT_TRUE
(
image_store_exists
(
elem
.
c_str
()));
...
...
@@ -650,6 +657,35 @@ TEST_F(StorageImagesUnitTest, test_image_store_wipe)
ASSERT_FALSE
(
dirExists
((
std
::
string
(
store_real_path
)
+
"/overlay-images/"
+
elem
).
c_str
()));
}
ASSERT_EQ
(
system
(
rm_command
.
c_str
()),
0
);
ASSERT_EQ
(
system
(
undo_command
.
c_str
()),
0
);
Restore
();
}
TEST_F
(
StorageImagesUnitTest
,
test_image_store_remove_single_name
)
{
BackUp
();
for
(
auto
elem
:
ids
)
{
ASSERT_TRUE
(
image_store_exists
(
elem
.
c_str
()));
ASSERT_TRUE
(
dirExists
((
std
::
string
(
store_real_path
)
+
"/overlay-images/"
+
elem
).
c_str
()));
}
ASSERT_EQ
(
image_store_add_name
(
ids
.
at
(
0
).
c_str
(),
"imagehub.isulad.com/official/busybox:latest"
),
0
);
Restore
();
}
TEST_F
(
StorageImagesUnitTest
,
test_image_store_remove_multi_name
)
{
BackUp
();
for
(
auto
elem
:
ids
)
{
ASSERT_TRUE
(
image_store_exists
(
elem
.
c_str
()));
ASSERT_TRUE
(
dirExists
((
std
::
string
(
store_real_path
)
+
"/overlay-images/"
+
elem
).
c_str
()));
}
ASSERT_EQ
(
image_store_add_name
(
ids
.
at
(
1
).
c_str
(),
"imagehub.isulad.com/official/newname:latest"
),
0
);
ASSERT_EQ
(
image_store_add_name
(
ids
.
at
(
1
).
c_str
(),
"imagehub.isulad.com/official/othername:latest"
),
0
);
ASSERT_EQ
(
image_store_add_name
(
ids
.
at
(
0
).
c_str
(),
"imagehub.isulad.com/official/busybox:latest"
),
0
);
Restore
();
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录