Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
5f05f8b3
milvus
项目概览
BaiXuePrincess
/
milvus
与 Fork 源项目一致
从无法访问的项目Fork
通知
7
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5f05f8b3
编写于
10月 19, 2019
作者:
G
groot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#48 Config unittest failed
Former-commit-id: 528fa91b59745822d81e3e9ee7cd23fff2382292
上级
49e05252
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
12 deletion
+17
-12
core/unittest/server/test_config.cpp
core/unittest/server/test_config.cpp
+5
-3
core/unittest/server/utils.cpp
core/unittest/server/utils.cpp
+9
-7
core/unittest/server/utils.h
core/unittest/server/utils.h
+3
-2
未找到文件。
core/unittest/server/test_config.cpp
浏览文件 @
5f05f8b3
...
...
@@ -38,10 +38,11 @@ TEST_F(ConfigTest, CONFIG_TEST) {
milvus
::
Status
s
=
config_mgr
->
LoadConfigFile
(
""
);
ASSERT_FALSE
(
s
.
ok
());
s
=
config_mgr
->
LoadConfigFile
(
INVALID_CONFIG_PATH
);
std
::
string
config_path
(
CONFIG_PATH
);
s
=
config_mgr
->
LoadConfigFile
(
config_path
+
INVALID_CONFIG_FILE
);
ASSERT_FALSE
(
s
.
ok
());
s
=
config_mgr
->
LoadConfigFile
(
VALID_CONFIG_PATH
);
s
=
config_mgr
->
LoadConfigFile
(
config_path
+
VALID_CONFIG_FILE
);
ASSERT_TRUE
(
s
.
ok
());
config_mgr
->
Print
();
...
...
@@ -98,8 +99,9 @@ TEST_F(ConfigTest, CONFIG_TEST) {
}
TEST_F
(
ConfigTest
,
SERVER_CONFIG_TEST
)
{
std
::
string
config_path
(
CONFIG_PATH
);
milvus
::
server
::
Config
&
config
=
milvus
::
server
::
Config
::
GetInstance
();
milvus
::
Status
s
=
config
.
LoadConfigFile
(
VALID_CONFIG_PATH
);
milvus
::
Status
s
=
config
.
LoadConfigFile
(
config_path
+
VALID_CONFIG_FILE
);
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
ValidateConfig
();
...
...
core/unittest/server/utils.cpp
浏览文件 @
5f05f8b3
...
...
@@ -16,12 +16,12 @@
// under the License.
#include "server/utils.h"
#include "utils/CommonUtil.h"
#include <fstream>
#include <iostream>
#include <thread>
#include <string>
#include <boost/filesystem.hpp>
namespace
{
...
...
@@ -67,8 +67,8 @@ static const char
static
const
char
*
INVALID_CONFIG_STR
=
"*INVALID*"
;
void
WriteToFile
(
const
char
*
file_path
,
const
char
*
content
)
{
std
::
fstream
fs
(
file_path
,
std
::
ios_base
::
out
);
WriteToFile
(
const
std
::
string
&
file_path
,
const
char
*
content
)
{
std
::
fstream
fs
(
file_path
.
c_str
()
,
std
::
ios_base
::
out
);
//write data to file
fs
<<
content
;
...
...
@@ -80,12 +80,14 @@ WriteToFile(const char* file_path, const char* content) {
void
ConfigTest
::
SetUp
()
{
WriteToFile
(
VALID_CONFIG_PATH
,
VALID_CONFIG_STR
);
WriteToFile
(
INVALID_CONFIG_PATH
,
INVALID_CONFIG_STR
);
std
::
string
config_path
(
CONFIG_PATH
);
milvus
::
server
::
CommonUtil
::
CreateDirectory
(
config_path
);
WriteToFile
(
config_path
+
VALID_CONFIG_FILE
,
VALID_CONFIG_STR
);
WriteToFile
(
config_path
+
INVALID_CONFIG_FILE
,
INVALID_CONFIG_STR
);
}
void
ConfigTest
::
TearDown
()
{
boost
::
filesystem
::
remove
(
VALID_
CONFIG_PATH
);
boost
::
filesystem
::
remove
(
INVALID_CONFIG_PATH
);
std
::
string
config_path
(
CONFIG_PATH
);
milvus
::
server
::
CommonUtil
::
DeleteDirectory
(
config_path
);
}
core/unittest/server/utils.h
浏览文件 @
5f05f8b3
...
...
@@ -21,8 +21,9 @@
#include <gtest/gtest.h>
#include <chrono>
static
const
char
*
VALID_CONFIG_PATH
=
"/tmp/milvus_test/valid_config.yaml"
;
static
const
char
*
INVALID_CONFIG_PATH
=
"/tmp/milvus_test/invalid_config.conf"
;
static
const
char
*
CONFIG_PATH
=
"/tmp/milvus_test/"
;
static
const
char
*
VALID_CONFIG_FILE
=
"valid_config.yaml"
;
static
const
char
*
INVALID_CONFIG_FILE
=
"invalid_config.conf"
;
class
ConfigTest
:
public
::
testing
::
Test
{
protected:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录