Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
291729e0
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,发现更多精彩内容 >>
提交
291729e0
编写于
7月 27, 2020
作者:
Z
Zhangxiaoyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add layer_store_ut code
Signed-off-by:
N
Zhangxiaoyu
<
zhangxiaoyu58@huawei.com
>
上级
5ad8b187
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
59 addition
and
8 deletion
+59
-8
test/image/oci/storage/layers/CMakeLists.txt
test/image/oci/storage/layers/CMakeLists.txt
+4
-0
test/image/oci/storage/layers/storage_layers_ut.cpp
test/image/oci/storage/layers/storage_layers_ut.cpp
+53
-6
test/mocks/driver_quota_mock.cc
test/mocks/driver_quota_mock.cc
+1
-1
test/mocks/driver_quota_mock.h
test/mocks/driver_quota_mock.h
+1
-1
未找到文件。
test/image/oci/storage/layers/CMakeLists.txt
浏览文件 @
291729e0
...
...
@@ -100,6 +100,7 @@ add_executable(${LAYER_EXE}
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../../../src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../../../src/daemon/modules/image/oci/storage/layer_store/graphdriver/overlay2/driver_overlay2.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../../../src/daemon/modules/image/oci/storage/layer_store/graphdriver/quota/project_quota.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../../mocks/driver_quota_mock.cc
storage_layers_ut.cpp
)
target_include_directories
(
${
LAYER_EXE
}
PUBLIC
...
...
@@ -123,10 +124,13 @@ target_include_directories(${LAYER_EXE} PUBLIC
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../../../src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../../../src/daemon/modules/image/oci/storage/layer_store/graphdriver/overlay2
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../../../src/daemon/modules/image/oci/storage/layer_store/graphdriver/quota
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../../mocks
)
target_link_libraries
(
${
LAYER_EXE
}
${
GTEST_BOTH_LIBRARIES
}
${
GMOCK_LIBRARY
}
${
GMOCK_MAIN_LIBRARY
}
${
CMAKE_THREAD_LIBS_INIT
}
${
ISULA_LIBUTILS_LIBRARY
}
${
LIBTAR_LIBRARY
}
...
...
test/image/oci/storage/layers/storage_layers_ut.cpp
浏览文件 @
291729e0
...
...
@@ -28,6 +28,18 @@
#include "utils.h"
#include "storage.h"
#include "layer.h"
#include "driver_quota_mock.h"
using
::
testing
::
Args
;
using
::
testing
::
ByRef
;
using
::
testing
::
SetArgPointee
;
using
::
testing
::
DoAll
;
using
::
testing
::
NiceMock
;
using
::
testing
::
Return
;
using
::
testing
::
NotNull
;
using
::
testing
::
AtLeast
;
using
::
testing
::
Invoke
;
using
::
testing
::
_
;
std
::
string
GetDirectory
()
{
...
...
@@ -92,6 +104,22 @@ void free_layer_list(struct layer_list *ptr)
free
(
ptr
);
}
int
invokeIOCtl
(
int
fd
,
int
cmd
)
{
return
0
;
}
int
invokeQuotaCtl
(
int
cmd
,
const
char
*
special
,
int
id
,
caddr_t
addr
)
{
#define XFS_QUOTA_PDQ_ACCT (1<<4) // project quota accounting
#define XFS_QUOTA_PDQ_ENFD (1<<5) // project quota limits enforcement
fs_quota_stat_t
*
fs_quota_stat_info
=
(
fs_quota_stat_t
*
)
addr
;
fs_quota_stat_info
->
qs_flags
=
XFS_QUOTA_PDQ_ACCT
|
XFS_QUOTA_PDQ_ENFD
;
return
0
;
}
/********************************test data 1: container layer json**************************************
{
"id": "7db8f44a0a8e12ea4283e3180e98880007efbd5de2e7c98b67de9cdd4dfffb0b",
...
...
@@ -122,6 +150,7 @@ class StorageLayersUnitTest : public testing::Test {
protected:
void
SetUp
()
override
{
MockDriverQuota_SetMock
(
&
m_driver_quota_mock
);
struct
storage_module_init_options
opts
=
{
0
};
std
::
string
isulad_dir
=
"/var/lib/isulad/"
;
...
...
@@ -138,6 +167,8 @@ protected:
ASSERT_STRNE
(
cleanpath
(
run_dir
.
c_str
(),
real_run_path
,
sizeof
(
real_run_path
)),
nullptr
);
opts
.
storage_run_root
=
strdup
(
real_run_path
);
opts
.
driver_name
=
strdup
(
"overlay"
);
EXPECT_CALL
(
m_driver_quota_mock
,
QuotaCtl
(
_
,
_
,
_
,
_
)).
WillRepeatedly
(
Invoke
(
invokeQuotaCtl
));
ASSERT_EQ
(
layer_store_init
(
&
opts
),
0
);
free
(
opts
.
storage_root
);
...
...
@@ -147,6 +178,8 @@ protected:
void
TearDown
()
override
{
MockDriverQuota_SetMock
(
nullptr
);
layer_store_exit
();
layer_store_cleanup
();
...
...
@@ -154,6 +187,7 @@ protected:
ASSERT_EQ
(
system
(
rm_command
.
c_str
()),
0
);
}
NiceMock
<
MockDriverQuota
>
m_driver_quota_mock
;
char
real_path
[
PATH_MAX
]
=
{
0x00
};
char
real_run_path
[
PATH_MAX
]
=
{
0x00
};
char
data_path
[
PATH_MAX
]
=
{
0x00
};
...
...
@@ -213,18 +247,31 @@ TEST_F(StorageLayersUnitTest, test_layer_store_exists)
TEST_F
(
StorageLayersUnitTest
,
test_layer_store_create
)
{
char
*
new_id
=
nullptr
;
struct
layer_opts
opts
=
{
0
};
opts
.
parent
=
strdup
(
"9c27e219663c25e0f28493790cc0b88bc973ba3b1686355f221c38a36978ac63"
);
opts
.
writable
=
true
;
ASSERT_EQ
(
layer_store_create
(
nullptr
,
&
opts
,
nullptr
,
&
new_id
),
0
);
struct
layer_opts
*
layer_opt
=
(
struct
layer_opts
*
)
util_common_calloc_s
(
sizeof
(
struct
layer_opts
));
layer_opt
->
parent
=
strdup
(
"9c27e219663c25e0f28493790cc0b88bc973ba3b1686355f221c38a36978ac63"
);
layer_opt
->
writable
=
true
;
layer_opt
->
opts
=
(
struct
layer_store_mount_opts
*
)
util_common_calloc_s
(
sizeof
(
struct
layer_store_mount_opts
));
layer_opt
->
opts
->
mount_opts
=
(
json_map_string_string
*
)
util_common_calloc_s
(
sizeof
(
json_map_string_string
));
layer_opt
->
opts
->
mount_opts
->
keys
=
(
char
**
)
util_common_calloc_s
(
sizeof
(
char
*
));
layer_opt
->
opts
->
mount_opts
->
values
=
(
char
**
)
util_common_calloc_s
(
sizeof
(
char
*
));
layer_opt
->
opts
->
mount_opts
->
keys
[
0
]
=
strdup
(
"size"
);
layer_opt
->
opts
->
mount_opts
->
values
[
0
]
=
strdup
(
"128M"
);
layer_opt
->
opts
->
mount_opts
->
len
=
1
;
layer_opt
->
names
=
(
char
**
)
util_common_calloc_s
(
sizeof
(
char
*
));
layer_opt
->
names
[
0
]
=
strdup
(
"layer_name"
);
layer_opt
->
names_len
=
1
;
EXPECT_CALL
(
m_driver_quota_mock
,
IOCtl
(
_
,
_
)).
WillRepeatedly
(
Invoke
(
invokeIOCtl
));
ASSERT_EQ
(
layer_store_create
(
nullptr
,
layer_opt
,
nullptr
,
&
new_id
),
0
);
ASSERT_TRUE
(
layer_store_exists
(
new_id
));
ASSERT_EQ
(
layer_store_delete
(
new_id
),
0
);
ASSERT_FALSE
(
layer_store_exists
(
new_id
));
ASSERT_FALSE
(
dirExists
((
std
::
string
(
real_path
)
+
"/"
+
std
::
string
(
new_id
)).
c_str
()));
free
(
opts
.
paren
t
);
free
_layer_opts
(
layer_op
t
);
free
(
new_id
);
}
...
...
test/mocks/driver_quota_mock.cc
浏览文件 @
291729e0
...
...
@@ -10,7 +10,7 @@
* See the Mulan PSL v2 for more details.
* Author: zhangxiaoyu
* Create: 2020-06-20
* Description: provide
driver quota
mock
* Description: provide
quota syscall
mock
******************************************************************************/
#include "driver_quota_mock.h"
...
...
test/mocks/driver_quota_mock.h
浏览文件 @
291729e0
...
...
@@ -10,7 +10,7 @@
* See the Mulan PSL v2 for more details.
* Author: zhangxiaoyu
* Create: 2020-06-20
* Description: provide
driver quota
mock
* Description: provide
quota syscall
mock
******************************************************************************/
#ifndef _ISULAD_TEST_MOCKS_DRIVER_QUOTA_MOCK_H
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录