Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
a5365e4e
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,发现更多精彩内容 >>
提交
a5365e4e
编写于
6月 28, 2019
作者:
G
groot
提交者:
jinhai
7月 13, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MS-129 Add more unitest
Former-commit-id: 41e2c14878df2740c4584ac6c2bc8e107ab00b56
上级
8ec28b96
变更
24
展开全部
隐藏空白更改
内联
并排
Showing
24 changed file
with
1618 addition
and
1394 deletion
+1618
-1394
cpp/.gitignore
cpp/.gitignore
+5
-0
cpp/CMakeLists.txt
cpp/CMakeLists.txt
+2
-2
cpp/README.md
cpp/README.md
+5
-0
cpp/conf/log_config.conf
cpp/conf/log_config.conf
+6
-6
cpp/conf/server_config.yaml
cpp/conf/server_config.yaml
+3
-6
cpp/src/license/GPUInfoFile.h
cpp/src/license/GPUInfoFile.h
+69
-69
cpp/src/license/GetSysInfo.cpp
cpp/src/license/GetSysInfo.cpp
+83
-83
cpp/src/license/LicenseCheck.cpp
cpp/src/license/LicenseCheck.cpp
+131
-131
cpp/src/license/LicenseCheck.h
cpp/src/license/LicenseCheck.h
+52
-52
cpp/src/license/LicenseFile.h
cpp/src/license/LicenseFile.h
+86
-86
cpp/src/license/LicenseGenerator.cpp
cpp/src/license/LicenseGenerator.cpp
+120
-120
cpp/src/license/LicenseLibrary.cpp
cpp/src/license/LicenseLibrary.cpp
+327
-327
cpp/src/license/LicenseLibrary.h
cpp/src/license/LicenseLibrary.h
+102
-102
cpp/src/utils/CommonUtil.cpp
cpp/src/utils/CommonUtil.cpp
+2
-2
cpp/src/utils/CommonUtil.h
cpp/src/utils/CommonUtil.h
+1
-1
cpp/unittest/CMakeLists.txt
cpp/unittest/CMakeLists.txt
+1
-1
cpp/unittest/license/license_check_test.cpp
cpp/unittest/license/license_check_test.cpp
+183
-183
cpp/unittest/license/license_library_tests.cpp
cpp/unittest/license/license_library_tests.cpp
+204
-204
cpp/unittest/server/CMakeLists.txt
cpp/unittest/server/CMakeLists.txt
+9
-0
cpp/unittest/server/appendix/log_config.conf
cpp/unittest/server/appendix/log_config.conf
+27
-0
cpp/unittest/server/appendix/server_config.yaml
cpp/unittest/server/appendix/server_config.yaml
+28
-0
cpp/unittest/server/cache_test.cpp
cpp/unittest/server/cache_test.cpp
+48
-0
cpp/unittest/server/config_test.cpp
cpp/unittest/server/config_test.cpp
+34
-6
cpp/unittest/server/util_test.cpp
cpp/unittest/server/util_test.cpp
+90
-13
未找到文件。
cpp/.gitignore
浏览文件 @
a5365e4e
...
...
@@ -3,3 +3,8 @@ conf/server_config.yaml
conf/log_config.conf
version.h
megasearch/
lcov_out/
base.info
output.info
output_new.info
server.info
\ No newline at end of file
cpp/CMakeLists.txt
浏览文件 @
a5365e4e
...
...
@@ -136,9 +136,9 @@ if (BUILD_COVERAGE STREQUAL "ON")
endif
()
if
(
"
${
BUILD_UNIT_TEST
}
"
STREQUAL
"ON"
)
if
(
BUILD_UNIT_TEST
STREQUAL
"ON"
)
add_subdirectory
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/unittest
)
endif
(
BUILD_UNIT_TEST
)
endif
()
add_custom_target
(
Clean-All COMMAND
${
CMAKE_BUILD_TOOL
}
clean
)
...
...
cpp/README.md
浏览文件 @
a5365e4e
...
...
@@ -45,6 +45,11 @@ If you encounter the following error when building:
or
./build.sh --unittest
#### To run code coverage
apt-get install lcov
./build.sh -u -c
### Launch server
Set config in cpp/conf/server_config.yaml
...
...
cpp/conf/log_config.conf
浏览文件 @
a5365e4e
*
GLOBAL
:
FORMAT
=
"%datetime | %level | %logger | %msg"
FILENAME
=
"/
opt
/milvus/logs/milvus-%datetime{%H:%m}-global.log"
FILENAME
=
"/
tmp
/milvus/logs/milvus-%datetime{%H:%m}-global.log"
ENABLED
=
true
TO_FILE
=
true
TO_STANDARD_OUTPUT
=
false
...
...
@@ -8,12 +8,12 @@
PERFORMANCE_TRACKING
=
false
MAX_LOG_FILE_SIZE
=
2097152
## Throw log files away after 2MB
*
DEBUG
:
FILENAME
=
"/
opt
/milvus/logs/milvus-%datetime{%H:%m}-debug.log"
FILENAME
=
"/
tmp
/milvus/logs/milvus-%datetime{%H:%m}-debug.log"
ENABLED
=
true
*
WARNING
:
FILENAME
=
"/
opt
/milvus/logs/milvus-%datetime{%H:%m}-warning.log"
FILENAME
=
"/
tmp
/milvus/logs/milvus-%datetime{%H:%m}-warning.log"
*
TRACE
:
FILENAME
=
"/
opt
/milvus/logs/milvus-%datetime{%H:%m}-trace.log"
FILENAME
=
"/
tmp
/milvus/logs/milvus-%datetime{%H:%m}-trace.log"
*
VERBOSE
:
FORMAT
=
"%datetime{%d/%M/%y} | %level-%vlevel | %msg"
TO_FILE
=
false
...
...
@@ -21,7 +21,7 @@
## Error logs
*
ERROR
:
ENABLED
=
true
FILENAME
=
"/
opt
/milvus/logs/milvus-%datetime{%H:%m}-error.log"
FILENAME
=
"/
tmp
/milvus/logs/milvus-%datetime{%H:%m}-error.log"
*
FATAL
:
ENABLED
=
true
FILENAME
=
"/
opt
/milvus/logs/milvus-%datetime{%H:%m}-fatal.log"
FILENAME
=
"/
tmp
/milvus/logs/milvus-%datetime{%H:%m}-fatal.log"
cpp/conf/server_config.yaml
浏览文件 @
a5365e4e
...
...
@@ -5,11 +5,8 @@ server_config:
mode
:
single
# milvus deployment type: single, cluster, read_only
db_config
:
db_path
:
/tmp/milvus
#URI format: dialect://username:password@host:port/database
#All parts except dialect are optional, but you MUST include the delimiters
#Currently supports mysql or sqlite
db_backend_url
:
mysql://root:1234@:/test
# meta database uri
db_path
:
/tmp/milvus
# milvus data storage path
db_backend_url
:
http://127.0.0.1
# meta database uri
index_building_threshold
:
1024
# index building trigger threshold, default: 1024, unit: MB
archive_disk_threshold
:
512
# triger archive action if storage size exceed this value, unit: GB
archive_days_threshold
:
30
# files older than x days will be archived, unit: day
...
...
@@ -24,7 +21,7 @@ metric_config:
push_gateway_port
:
9091
# push method configure: push gateway port
license_config
:
# license configure
license_path
:
"
/
opt
/milvus/system.license"
# license file path
license_path
:
"
/
tmp
/milvus/system.license"
# license file path
cache_config
:
# cache configure
cpu_cache_capacity
:
16
# how many memory are used as cache, unit: GB, range: 0 ~ less than total memory
cpp/src/license/GPUInfoFile.h
浏览文件 @
a5365e4e
/*******************************************************************************
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#pragma once
#include <boost/serialization/access.hpp>
#include <string>
#include <map>
class
GPUInfoFile
{
public:
GPUInfoFile
()
=
default
;
GPUInfoFile
(
const
int
&
device_count
,
const
std
::
map
<
int
,
std
::
string
>
&
uuid_encryption_map
)
:
device_count_
(
device_count
),
uuid_encryption_map_
(
uuid_encryption_map
)
{}
int
get_device_count
()
{
return
device_count_
;
}
std
::
map
<
int
,
std
::
string
>
&
get_uuid_encryption_map
()
{
return
uuid_encryption_map_
;
}
public:
friend
class
boost
::
serialization
::
access
;
template
<
typename
Archive
>
void
serialize
(
Archive
&
ar
,
const
unsigned
int
version
)
{
ar
&
device_count_
;
ar
&
uuid_encryption_map_
;
}
public:
int
device_count_
=
0
;
std
::
map
<
int
,
std
::
string
>
uuid_encryption_map_
;
};
class
SerializedGPUInfoFile
{
public:
~
SerializedGPUInfoFile
()
{
if
(
gpu_info_file_
!=
nullptr
)
{
delete
(
gpu_info_file_
);
gpu_info_file_
=
nullptr
;
}
}
void
set_gpu_info_file
(
GPUInfoFile
*
gpu_info_file
)
{
gpu_info_file_
=
gpu_info_file
;
}
GPUInfoFile
*
get_gpu_info_file
()
{
return
gpu_info_file_
;
}
private:
friend
class
boost
::
serialization
::
access
;
template
<
typename
Archive
>
void
serialize
(
Archive
&
ar
,
const
unsigned
int
version
)
{
ar
&
gpu_info_file_
;
}
private:
GPUInfoFile
*
gpu_info_file_
=
nullptr
;
};
/
//
*******************************************************************************
//
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
//
* Unauthorized copying of this file, via any medium is strictly prohibited.
//
* Proprietary and confidential.
//
******************************************************************************/
//
#pragma once
//
//
#include <boost/serialization/access.hpp>
//
#include <string>
//
#include <map>
//
//
//
class GPUInfoFile {
//
public:
//
GPUInfoFile() = default;
//
//
GPUInfoFile(const int &device_count, const std::map<int, std::string> &uuid_encryption_map)
//
: device_count_(device_count), uuid_encryption_map_(uuid_encryption_map) {}
//
//
int get_device_count() {
//
return device_count_;
//
}
//
std::map<int, std::string> &get_uuid_encryption_map() {
//
return uuid_encryption_map_;
//
}
//
//
//
public:
//
friend class boost::serialization::access;
//
//
template<typename Archive>
//
void serialize(Archive &ar, const unsigned int version) {
//
ar & device_count_;
//
ar & uuid_encryption_map_;
//
}
//
//
public:
//
int device_count_ = 0;
//
std::map<int, std::string> uuid_encryption_map_;
//
};
//
//
class SerializedGPUInfoFile {
//
public:
//
~SerializedGPUInfoFile() {
//
if (gpu_info_file_ != nullptr) {
//
delete (gpu_info_file_);
//
gpu_info_file_ = nullptr;
//
}
//
}
//
//
void
//
set_gpu_info_file(GPUInfoFile *gpu_info_file) {
//
gpu_info_file_ = gpu_info_file;
//
}
//
//
GPUInfoFile *get_gpu_info_file() {
//
return gpu_info_file_;
//
}
//
private:
//
friend class boost::serialization::access;
//
//
template<typename Archive>
//
void serialize(Archive &ar, const unsigned int version) {
//
ar & gpu_info_file_;
//
}
//
//
private:
//
GPUInfoFile *gpu_info_file_ = nullptr;
//
};
cpp/src/license/GetSysInfo.cpp
浏览文件 @
a5365e4e
#include "utils/Log.h"
#include "LicenseLibrary.h"
#include "utils/Error.h"
#include <iostream>
#include <getopt.h>
#include <memory.h>
// Not provide path: current work path will be used and system.info.
using
namespace
zilliz
::
milvus
;
void
print_usage
(
const
std
::
string
&
app_name
)
{
printf
(
"
\n
Usage: %s [OPTIONS]
\n\n
"
,
app_name
.
c_str
());
printf
(
" Options:
\n
"
);
printf
(
" -h --help Print this help
\n
"
);
printf
(
" -s --sysinfo filename Generate system info file as given name
\n
"
);
printf
(
"
\n
"
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
std
::
string
app_name
=
argv
[
0
];
if
(
argc
!=
1
&&
argc
!=
3
)
{
print_usage
(
app_name
);
return
EXIT_FAILURE
;
}
static
struct
option
long_options
[]
=
{{
"system_info"
,
required_argument
,
0
,
's'
},
{
"help"
,
no_argument
,
0
,
'h'
},
{
NULL
,
0
,
0
,
0
}};
int
value
=
0
;
int
option_index
=
0
;
std
::
string
system_info_filename
=
"./system.info"
;
while
((
value
=
getopt_long
(
argc
,
argv
,
"s:h"
,
long_options
,
&
option_index
))
!=
-
1
)
{
switch
(
value
)
{
case
's'
:
{
char
*
system_info_filename_ptr
=
strdup
(
optarg
);
system_info_filename
=
system_info_filename_ptr
;
free
(
system_info_filename_ptr
);
// printf("Generate system info file: %s\n", system_info_filename.c_str());
break
;
}
case
'h'
:
print_usage
(
app_name
);
return
EXIT_SUCCESS
;
case
'?'
:
print_usage
(
app_name
);
return
EXIT_FAILURE
;
default:
print_usage
(
app_name
);
break
;
}
}
int
device_count
=
0
;
server
::
ServerError
err
=
server
::
LicenseLibrary
::
GetDeviceCount
(
device_count
);
if
(
err
!=
server
::
SERVER_SUCCESS
)
return
-
1
;
// 1. Get All GPU UUID
std
::
vector
<
std
::
string
>
uuid_array
;
err
=
server
::
LicenseLibrary
::
GetUUID
(
device_count
,
uuid_array
);
if
(
err
!=
server
::
SERVER_SUCCESS
)
return
-
1
;
// 2. Get UUID SHA256
std
::
vector
<
std
::
string
>
uuid_sha256_array
;
err
=
server
::
LicenseLibrary
::
GetUUIDSHA256
(
device_count
,
uuid_array
,
uuid_sha256_array
);
if
(
err
!=
server
::
SERVER_SUCCESS
)
return
-
1
;
// 3. Generate GPU ID map with GPU UUID
std
::
map
<
int
,
std
::
string
>
uuid_encrption_map
;
for
(
int
i
=
0
;
i
<
device_count
;
++
i
)
{
uuid_encrption_map
[
i
]
=
uuid_sha256_array
[
i
];
}
// 4. Generate GPU_info File
err
=
server
::
LicenseLibrary
::
GPUinfoFileSerialization
(
system_info_filename
,
device_count
,
uuid_encrption_map
);
if
(
err
!=
server
::
SERVER_SUCCESS
)
return
-
1
;
printf
(
"Generate GPU_info File Success
\n
"
);
return
0
;
}
\ No newline at end of file
//
//#include "utils/Log.h"
//#include "LicenseLibrary.h"
//#include "utils/Error.h"
//
//#include <iostream>
//#include <getopt.h>
//#include <memory.h>
//// Not provide path: current work path will be used and system.info.
//using namespace zilliz::milvus;
//
//void
//print_usage(const std::string &app_name) {
// printf("\n Usage: %s [OPTIONS]\n\n", app_name.c_str());
// printf(" Options:\n");
// printf(" -h --help Print this help\n");
// printf(" -s --sysinfo filename Generate system info file as given name\n");
// printf("\n");
//}
//
//int main(int argc, char *argv[]) {
// std::string app_name = argv[0];
// if (argc != 1 && argc != 3) {
// print_usage(app_name);
// return EXIT_FAILURE;
// }
//
// static struct option long_options[] = {{"system_info", required_argument, 0, 's'},
// {"help", no_argument, 0, 'h'},
// {NULL, 0, 0, 0}};
// int value = 0;
// int option_index = 0;
// std::string system_info_filename = "./system.info";
// while ((value = getopt_long(argc, argv, "s:h", long_options, &option_index)) != -1) {
// switch (value) {
// case 's': {
// char *system_info_filename_ptr = strdup(optarg);
// system_info_filename = system_info_filename_ptr;
// free(system_info_filename_ptr);
//// printf("Generate system info file: %s\n", system_info_filename.c_str());
// break;
// }
// case 'h':print_usage(app_name);
// return EXIT_SUCCESS;
// case '?':print_usage(app_name);
// return EXIT_FAILURE;
// default:print_usage(app_name);
// break;
// }
// }
//
// int device_count = 0;
// server::ServerError err = server::LicenseLibrary::GetDeviceCount(device_count);
// if (err != server::SERVER_SUCCESS) return -1;
//
// // 1. Get All GPU UUID
// std::vector<std::string> uuid_array;
// err = server::LicenseLibrary::GetUUID(device_count, uuid_array);
// if (err != server::SERVER_SUCCESS) return -1;
//
// // 2. Get UUID SHA256
// std::vector<std::string> uuid_sha256_array;
// err = server::LicenseLibrary::GetUUIDSHA256(device_count, uuid_array, uuid_sha256_array);
// if (err != server::SERVER_SUCCESS) return -1;
//
// // 3. Generate GPU ID map with GPU UUID
// std::map<int, std::string> uuid_encrption_map;
// for (int i = 0; i < device_count; ++i) {
// uuid_encrption_map[i] = uuid_sha256_array[i];
// }
//
//
// // 4. Generate GPU_info File
// err = server::LicenseLibrary::GPUinfoFileSerialization(system_info_filename,
// device_count,
// uuid_encrption_map);
// if (err != server::SERVER_SUCCESS) return -1;
//
// printf("Generate GPU_info File Success\n");
//
//
// return 0;
//}
\ No newline at end of file
cpp/src/license/LicenseCheck.cpp
浏览文件 @
a5365e4e
#include "LicenseCheck.h"
#include <iostream>
#include <thread>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
//#include <boost/foreach.hpp>
//#include <boost/serialization/vector.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/serialization/map.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/thread.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
namespace
zilliz
{
namespace
milvus
{
namespace
server
{
LicenseCheck
::
LicenseCheck
()
{
}
LicenseCheck
::~
LicenseCheck
()
{
StopCountingDown
();
}
ServerError
LicenseCheck
::
LegalityCheck
(
const
std
::
string
&
license_file_path
)
{
int
device_count
;
LicenseLibrary
::
GetDeviceCount
(
device_count
);
std
::
vector
<
std
::
string
>
uuid_array
;
LicenseLibrary
::
GetUUID
(
device_count
,
uuid_array
);
std
::
vector
<
std
::
string
>
sha_array
;
LicenseLibrary
::
GetUUIDSHA256
(
device_count
,
uuid_array
,
sha_array
);
int
output_device_count
;
std
::
map
<
int
,
std
::
string
>
uuid_encryption_map
;
time_t
starting_time
;
time_t
end_time
;
ServerError
err
=
LicenseLibrary
::
LicenseFileDeserialization
(
license_file_path
,
output_device_count
,
uuid_encryption_map
,
starting_time
,
end_time
);
if
(
err
!=
SERVER_SUCCESS
)
{
std
::
cout
<<
"License check error: 01"
<<
std
::
endl
;
return
SERVER_UNEXPECTED_ERROR
;
}
time_t
system_time
;
LicenseLibrary
::
GetSystemTime
(
system_time
);
if
(
device_count
!=
output_device_count
)
{
std
::
cout
<<
"License check error: 02"
<<
std
::
endl
;
return
SERVER_UNEXPECTED_ERROR
;
}
for
(
int
i
=
0
;
i
<
device_count
;
++
i
)
{
if
(
sha_array
[
i
]
!=
uuid_encryption_map
[
i
])
{
std
::
cout
<<
"License check error: 03"
<<
std
::
endl
;
return
SERVER_UNEXPECTED_ERROR
;
}
}
if
(
system_time
<
starting_time
||
system_time
>
end_time
)
{
std
::
cout
<<
"License check error: 04"
<<
std
::
endl
;
return
SERVER_UNEXPECTED_ERROR
;
}
std
::
cout
<<
"Legality Check Success"
<<
std
::
endl
;
return
SERVER_SUCCESS
;
}
// Part 2: Timing check license
ServerError
LicenseCheck
::
AlterFile
(
const
std
::
string
&
license_file_path
,
const
boost
::
system
::
error_code
&
ec
,
boost
::
asio
::
deadline_timer
*
pt
)
{
ServerError
err
=
LicenseCheck
::
LegalityCheck
(
license_file_path
);
if
(
err
!=
SERVER_SUCCESS
)
{
std
::
cout
<<
"license file check error"
<<
std
::
endl
;
exit
(
1
);
}
std
::
cout
<<
"---runing---"
<<
std
::
endl
;
pt
->
expires_at
(
pt
->
expires_at
()
+
boost
::
posix_time
::
hours
(
1
));
pt
->
async_wait
(
boost
::
bind
(
LicenseCheck
::
AlterFile
,
license_file_path
,
boost
::
asio
::
placeholders
::
error
,
pt
));
return
SERVER_SUCCESS
;
}
ServerError
LicenseCheck
::
StartCountingDown
(
const
std
::
string
&
license_file_path
)
{
if
(
!
LicenseLibrary
::
IsFileExistent
(
license_file_path
))
{
std
::
cout
<<
"license file not exist"
<<
std
::
endl
;
exit
(
1
);
}
//create a thread to run AlterFile
if
(
counting_thread_
==
nullptr
)
{
counting_thread_
=
std
::
make_shared
<
std
::
thread
>
([
&
]()
{
boost
::
asio
::
deadline_timer
t
(
io_service_
,
boost
::
posix_time
::
hours
(
1
));
t
.
async_wait
(
boost
::
bind
(
LicenseCheck
::
AlterFile
,
license_file_path
,
boost
::
asio
::
placeholders
::
error
,
&
t
));
io_service_
.
run
();
//this thread will block here
});
}
return
SERVER_SUCCESS
;
}
ServerError
LicenseCheck
::
StopCountingDown
()
{
if
(
!
io_service_
.
stopped
())
{
io_service_
.
stop
();
}
if
(
counting_thread_
!=
nullptr
)
{
counting_thread_
->
join
();
counting_thread_
=
nullptr
;
}
return
SERVER_SUCCESS
;
}
}
}
}
\ No newline at end of file
//#include "LicenseCheck.h"
//#include <iostream>
//#include <thread>
//
//#include <boost/archive/binary_oarchive.hpp>
//#include <boost/archive/binary_iarchive.hpp>
////#include <boost/foreach.hpp>
////#include <boost/serialization/vector.hpp>
//#include <boost/filesystem/path.hpp>
//#include <boost/serialization/map.hpp>
//#include <boost/filesystem/operations.hpp>
//#include <boost/thread.hpp>
//#include <boost/date_time/posix_time/posix_time.hpp>
//
//
//namespace zilliz {
//namespace milvus {
//namespace server {
//
//LicenseCheck::LicenseCheck() {
//
//}
//
//LicenseCheck::~LicenseCheck() {
// StopCountingDown();
//}
//
//ServerError
//LicenseCheck::LegalityCheck(const std::string &license_file_path) {
//
// int device_count;
// LicenseLibrary::GetDeviceCount(device_count);
// std::vector<std::string> uuid_array;
// LicenseLibrary::GetUUID(device_count, uuid_array);
//
// std::vector<std::string> sha_array;
// LicenseLibrary::GetUUIDSHA256(device_count, uuid_array, sha_array);
//
// int output_device_count;
// std::map<int, std::string> uuid_encryption_map;
// time_t starting_time;
// time_t end_time;
// ServerError err = LicenseLibrary::LicenseFileDeserialization(license_file_path,
// output_device_count,
// uuid_encryption_map,
// starting_time,
// end_time);
// if(err !=SERVER_SUCCESS)
// {
// std::cout << "License check error: 01" << std::endl;
// return SERVER_UNEXPECTED_ERROR;
// }
// time_t system_time;
// LicenseLibrary::GetSystemTime(system_time);
//
// if (device_count != output_device_count) {
// std::cout << "License check error: 02" << std::endl;
// return SERVER_UNEXPECTED_ERROR;
// }
// for (int i = 0; i < device_count; ++i) {
// if (sha_array[i] != uuid_encryption_map[i]) {
// std::cout << "License check error: 03" << std::endl;
// return SERVER_UNEXPECTED_ERROR;
// }
// }
// if (system_time < starting_time || system_time > end_time) {
// std::cout << "License check error: 04" << std::endl;
// return SERVER_UNEXPECTED_ERROR;
// }
// std::cout << "Legality Check Success" << std::endl;
// return SERVER_SUCCESS;
//}
//
//// Part 2: Timing check license
//
//ServerError
//LicenseCheck::AlterFile(const std::string &license_file_path,
// const boost::system::error_code &ec,
// boost::asio::deadline_timer *pt) {
//
// ServerError err = LicenseCheck::LegalityCheck(license_file_path);
// if(err!=SERVER_SUCCESS) {
// std::cout << "license file check error" << std::endl;
// exit(1);
// }
//
// std::cout << "---runing---" << std::endl;
// pt->expires_at(pt->expires_at() + boost::posix_time::hours(1));
// pt->async_wait(boost::bind(LicenseCheck::AlterFile, license_file_path, boost::asio::placeholders::error, pt));
//
// return SERVER_SUCCESS;
//
//}
//
//ServerError
//LicenseCheck::StartCountingDown(const std::string &license_file_path) {
//
// if (!LicenseLibrary::IsFileExistent(license_file_path)) {
// std::cout << "license file not exist" << std::endl;
// exit(1);
// }
//
// //create a thread to run AlterFile
// if(counting_thread_ == nullptr) {
// counting_thread_ = std::make_shared<std::thread>([&]() {
// boost::asio::deadline_timer t(io_service_, boost::posix_time::hours(1));
// t.async_wait(boost::bind(LicenseCheck::AlterFile, license_file_path, boost::asio::placeholders::error, &t));
// io_service_.run();//this thread will block here
// });
// }
//
// return SERVER_SUCCESS;
//}
//
//ServerError
//LicenseCheck::StopCountingDown() {
// if(!io_service_.stopped()) {
// io_service_.stop();
// }
//
// if(counting_thread_ != nullptr) {
// counting_thread_->join();
// counting_thread_ = nullptr;
// }
//
// return SERVER_SUCCESS;
//}
//
//}
//}
//}
\ No newline at end of file
cpp/src/license/LicenseCheck.h
浏览文件 @
a5365e4e
#pragma once
#include "utils/Error.h"
#include "LicenseLibrary.h"
#include <boost/asio.hpp>
#include <thread>
#include <memory>
namespace
zilliz
{
namespace
milvus
{
namespace
server
{
class
LicenseCheck
{
private:
LicenseCheck
();
~
LicenseCheck
();
public:
static
LicenseCheck
&
GetInstance
()
{
static
LicenseCheck
instance
;
return
instance
;
};
static
ServerError
LegalityCheck
(
const
std
::
string
&
license_file_path
);
ServerError
StartCountingDown
(
const
std
::
string
&
license_file_path
);
ServerError
StopCountingDown
();
private:
static
ServerError
AlterFile
(
const
std
::
string
&
license_file_path
,
const
boost
::
system
::
error_code
&
ec
,
boost
::
asio
::
deadline_timer
*
pt
);
private:
boost
::
asio
::
io_service
io_service_
;
std
::
shared_ptr
<
std
::
thread
>
counting_thread_
;
};
}
}
}
//
#pragma once
//
//
#include "utils/Error.h"
//
#include "LicenseLibrary.h"
//
//
#include <boost/asio.hpp>
//
//
#include <thread>
//
#include <memory>
//
//
namespace zilliz {
//
namespace milvus {
//
namespace server {
//
//
class LicenseCheck {
//
private:
//
LicenseCheck();
//
~LicenseCheck();
//
//
public:
//
static LicenseCheck &
//
GetInstance() {
//
static LicenseCheck instance;
//
return instance;
//
};
//
//
static ServerError
//
LegalityCheck(const std::string &license_file_path);
//
//
ServerError
//
StartCountingDown(const std::string &license_file_path);
//
//
ServerError
//
StopCountingDown();
//
//
private:
//
static ServerError
//
AlterFile(const std::string &license_file_path,
//
const boost::system::error_code &ec,
//
boost::asio::deadline_timer *pt);
//
//
private:
//
boost::asio::io_service io_service_;
//
std::shared_ptr<std::thread> counting_thread_;
//
//
};
//
//
}
//
}
//
}
//
//
cpp/src/license/LicenseFile.h
浏览文件 @
a5365e4e
/*******************************************************************************
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#pragma once
#include <boost/serialization/access.hpp>
#include <string>
#include <map>
class
LicenseFile
{
public:
LicenseFile
()
=
default
;
LicenseFile
(
const
int
&
device_count
,
const
std
::
map
<
int
,
std
::
string
>
&
uuid_encryption_map
,
const
time_t
&
starting_time
,
const
time_t
&
end_time
)
:
device_count_
(
device_count
),
uuid_encryption_map_
(
uuid_encryption_map
),
starting_time_
(
starting_time
),
end_time_
(
end_time
)
{}
int
get_device_count
()
{
return
device_count_
;
}
std
::
map
<
int
,
std
::
string
>
&
get_uuid_encryption_map
()
{
return
uuid_encryption_map_
;
}
time_t
get_starting_time
()
{
return
starting_time_
;
}
time_t
get_end_time
()
{
return
end_time_
;
}
public:
friend
class
boost
::
serialization
::
access
;
template
<
typename
Archive
>
void
serialize
(
Archive
&
ar
,
const
unsigned
int
version
)
{
ar
&
device_count_
;
ar
&
uuid_encryption_map_
;
ar
&
starting_time_
;
ar
&
end_time_
;
}
public:
int
device_count_
=
0
;
std
::
map
<
int
,
std
::
string
>
uuid_encryption_map_
;
time_t
starting_time_
=
0
;
time_t
end_time_
=
0
;
};
class
SerializedLicenseFile
{
public:
~
SerializedLicenseFile
()
{
if
(
license_file_
!=
nullptr
)
{
delete
(
license_file_
);
license_file_
=
nullptr
;
}
}
void
set_license_file
(
LicenseFile
*
license_file
)
{
license_file_
=
license_file
;
}
LicenseFile
*
get_license_file
()
{
return
license_file_
;
}
private:
friend
class
boost
::
serialization
::
access
;
template
<
typename
Archive
>
void
serialize
(
Archive
&
ar
,
const
unsigned
int
version
)
{
ar
&
license_file_
;
}
private:
LicenseFile
*
license_file_
=
nullptr
;
};
/
//
*******************************************************************************
//
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
//
* Unauthorized copying of this file, via any medium is strictly prohibited.
//
* Proprietary and confidential.
//
******************************************************************************/
//
#pragma once
//
//
//
#include <boost/serialization/access.hpp>
//
#include <string>
//
#include <map>
//
//
//
class LicenseFile {
//
public:
//
LicenseFile() = default;
//
//
LicenseFile(const int &device_count,
//
const std::map<int, std::string> &uuid_encryption_map,
//
const time_t &starting_time,
//
const time_t &end_time)
//
: device_count_(device_count),
//
uuid_encryption_map_(uuid_encryption_map),
//
starting_time_(starting_time),
//
end_time_(end_time) {}
//
//
int get_device_count() {
//
return device_count_;
//
}
//
std::map<int, std::string> &get_uuid_encryption_map() {
//
return uuid_encryption_map_;
//
}
//
time_t get_starting_time() {
//
return starting_time_;
//
}
//
time_t get_end_time() {
//
return end_time_;
//
}
//
//
public:
//
friend class boost::serialization::access;
//
//
template<typename Archive>
//
void serialize(Archive &ar, const unsigned int version) {
//
ar & device_count_;
//
ar & uuid_encryption_map_;
//
ar & starting_time_;
//
ar & end_time_;
//
}
//
//
public:
//
int device_count_ = 0;
//
std::map<int, std::string> uuid_encryption_map_;
//
time_t starting_time_ = 0;
//
time_t end_time_ = 0;
//
};
//
//
class SerializedLicenseFile {
//
public:
//
~SerializedLicenseFile() {
//
if (license_file_ != nullptr) {
//
delete (license_file_);
//
license_file_ = nullptr;
//
}
//
}
//
//
void
//
set_license_file(LicenseFile *license_file) {
//
license_file_ = license_file;
//
}
//
//
LicenseFile *get_license_file() {
//
return license_file_;
//
}
//
private:
//
friend class boost::serialization::access;
//
//
template<typename Archive>
//
void serialize(Archive &ar, const unsigned int version) {
//
ar & license_file_;
//
}
//
//
private:
//
LicenseFile *license_file_ = nullptr;
//
};
//
cpp/src/license/LicenseGenerator.cpp
浏览文件 @
a5365e4e
#include <iostream>
#include <getopt.h>
#include <memory.h>
#include "utils/Log.h"
#include "license/LicenseLibrary.h"
#include "utils/Error.h"
using
namespace
zilliz
::
milvus
;
// Not provide path: current work path will be used and system.info.
void
print_usage
(
const
std
::
string
&
app_name
)
{
printf
(
"
\n
Usage: %s [OPTIONS]
\n\n
"
,
app_name
.
c_str
());
printf
(
" Options:
\n
"
);
printf
(
" -h --help Print this help
\n
"
);
printf
(
" -s --sysinfo filename sysinfo file location
\n
"
);
printf
(
" -l --license filename Generate license file as given name
\n
"
);
printf
(
" -b --starting time Set start time (format: YYYY-MM-DD)
\n
"
);
printf
(
" -e --end time Set end time (format: YYYY-MM-DD)
\n
"
);
printf
(
"
\n
"
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
std
::
string
app_name
=
argv
[
0
];
// if (argc != 1 && argc != 3) {
// print_usage(app_name);
// return EXIT_FAILURE;
//
//#include <iostream>
//#include <getopt.h>
//#include <memory.h>
//
//#include "utils/Log.h"
//#include "license/LicenseLibrary.h"
//#include "utils/Error.h"
//
//
//using namespace zilliz::milvus;
//// Not provide path: current work path will be used and system.info.
//
//void
//print_usage(const std::string &app_name) {
// printf("\n Usage: %s [OPTIONS]\n\n", app_name.c_str());
// printf(" Options:\n");
// printf(" -h --help Print this help\n");
// printf(" -s --sysinfo filename sysinfo file location\n");
// printf(" -l --license filename Generate license file as given name\n");
// printf(" -b --starting time Set start time (format: YYYY-MM-DD)\n");
// printf(" -e --end time Set end time (format: YYYY-MM-DD)\n");
// printf("\n");
//}
//
//int main(int argc, char *argv[]) {
// std::string app_name = argv[0];
//// if (argc != 1 && argc != 3) {
//// print_usage(app_name);
//// return EXIT_FAILURE;
//// }
// static struct option long_options[] = {{"system_info", required_argument, 0, 's'},
// {"license", optional_argument, 0, 'l'},
// {"help", no_argument, 0, 'h'},
// {"starting_time", required_argument, 0, 'b'},
// {"end_time", required_argument, 0, 'e'},
// {NULL, 0, 0, 0}};
// server::ServerError err;
// int value = 0;
// int option_index = 0;
// std::string system_info_filename = "./system.info";
// std::string license_filename = "./system.license";
// char *string_starting_time = NULL;
// char *string_end_time = NULL;
// time_t starting_time = 0;
// time_t end_time = 0;
// int flag_s = 1;
// int flag_b = 1;
// int flag_e = 1;
// while ((value = getopt_long(argc, argv, "hl:s:b:e:", long_options, NULL)) != -1) {
// switch (value) {
// case 's': {
// flag_s = 0;
// system_info_filename = (std::string) (optarg);
// break;
// }
// case 'b': {
// flag_b = 0;
// string_starting_time = optarg;
// break;
// }
// case 'e': {
// flag_e = 0;
// string_end_time = optarg;
// break;
// }
// case 'l': {
// license_filename = (std::string) (optarg);
// break;
// }
// case 'h':print_usage(app_name);
// return EXIT_SUCCESS;
// case '?':print_usage(app_name);
// return EXIT_FAILURE;
// default:print_usage(app_name);
// break;
// }
//
// }
static
struct
option
long_options
[]
=
{{
"system_info"
,
required_argument
,
0
,
's'
},
{
"license"
,
optional_argument
,
0
,
'l'
},
{
"help"
,
no_argument
,
0
,
'h'
},
{
"starting_time"
,
required_argument
,
0
,
'b'
},
{
"end_time"
,
required_argument
,
0
,
'e'
},
{
NULL
,
0
,
0
,
0
}};
server
::
ServerError
err
;
int
value
=
0
;
int
option_index
=
0
;
std
::
string
system_info_filename
=
"./system.info"
;
std
::
string
license_filename
=
"./system.license"
;
char
*
string_starting_time
=
NULL
;
char
*
string_end_time
=
NULL
;
time_t
starting_time
=
0
;
time_t
end_time
=
0
;
int
flag_s
=
1
;
int
flag_b
=
1
;
int
flag_e
=
1
;
while
((
value
=
getopt_long
(
argc
,
argv
,
"hl:s:b:e:"
,
long_options
,
NULL
))
!=
-
1
)
{
switch
(
value
)
{
case
's'
:
{
flag_s
=
0
;
system_info_filename
=
(
std
::
string
)
(
optarg
);
break
;
}
case
'b'
:
{
flag_b
=
0
;
string_starting_time
=
optarg
;
break
;
}
case
'e'
:
{
flag_e
=
0
;
string_end_time
=
optarg
;
break
;
}
case
'l'
:
{
license_filename
=
(
std
::
string
)
(
optarg
);
break
;
}
case
'h'
:
print_usage
(
app_name
);
return
EXIT_SUCCESS
;
case
'?'
:
print_usage
(
app_name
);
return
EXIT_FAILURE
;
default:
print_usage
(
app_name
);
break
;
}
}
if
(
flag_s
)
{
printf
(
"Error: sysinfo file location must be entered
\n
"
);
return
1
;
}
if
(
flag_b
)
{
printf
(
"Error: start time must be entered
\n
"
);
return
1
;
}
if
(
flag_e
)
{
printf
(
"Error: end time must be entered
\n
"
);
return
1
;
}
err
=
server
::
LicenseLibrary
::
GetDateTime
(
string_starting_time
,
starting_time
);
if
(
err
!=
server
::
SERVER_SUCCESS
)
return
-
1
;
err
=
server
::
LicenseLibrary
::
GetDateTime
(
string_end_time
,
end_time
);
if
(
err
!=
server
::
SERVER_SUCCESS
)
return
-
1
;
int
output_info_device_count
=
0
;
std
::
map
<
int
,
std
::
string
>
output_info_uuid_encrption_map
;
err
=
server
::
LicenseLibrary
::
GPUinfoFileDeserialization
(
system_info_filename
,
output_info_device_count
,
output_info_uuid_encrption_map
);
if
(
err
!=
server
::
SERVER_SUCCESS
)
return
-
1
;
err
=
server
::
LicenseLibrary
::
LicenseFileSerialization
(
license_filename
,
output_info_device_count
,
output_info_uuid_encrption_map
,
starting_time
,
end_time
);
if
(
err
!=
server
::
SERVER_SUCCESS
)
return
-
1
;
printf
(
"Generate License File Success
\n
"
);
return
0
;
}
// if (flag_s) {
// printf("Error: sysinfo file location must be entered\n");
// return 1;
// }
// if (flag_b) {
// printf("Error: start time must be entered\n");
// return 1;
// }
// if (flag_e) {
// printf("Error: end time must be entered\n");
// return 1;
// }
//
// err = server::LicenseLibrary::GetDateTime(string_starting_time, starting_time);
// if (err != server::SERVER_SUCCESS) return -1;
//
// err = server::LicenseLibrary::GetDateTime(string_end_time, end_time);
// if (err != server::SERVER_SUCCESS) return -1;
//
//
// int output_info_device_count = 0;
// std::map<int, std::string> output_info_uuid_encrption_map;
//
//
// err = server::LicenseLibrary::GPUinfoFileDeserialization(system_info_filename,
// output_info_device_count,
// output_info_uuid_encrption_map);
// if (err != server::SERVER_SUCCESS) return -1;
//
//
// err = server::LicenseLibrary::LicenseFileSerialization(license_filename,
// output_info_device_count,
// output_info_uuid_encrption_map,
// starting_time,
// end_time);
// if (err != server::SERVER_SUCCESS) return -1;
//
//
// printf("Generate License File Success\n");
//
// return 0;
//}
cpp/src/license/LicenseLibrary.cpp
浏览文件 @
a5365e4e
此差异已折叠。
点击以展开。
cpp/src/license/LicenseLibrary.h
浏览文件 @
a5365e4e
#pragma once
#include "LicenseFile.h"
#include "GPUInfoFile.h"
#include "utils/Error.h"
#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <vector>
#include <map>
#include <time.h>
namespace
zilliz
{
namespace
milvus
{
namespace
server
{
class
LicenseLibrary
{
public:
// Part 0: File check
static
bool
IsFileExistent
(
const
std
::
string
&
path
);
// Part 1: Get GPU Info
static
ServerError
GetDeviceCount
(
int
&
device_count
);
static
ServerError
GetUUID
(
int
device_count
,
std
::
vector
<
std
::
string
>
&
uuid_array
);
static
ServerError
GetUUIDMD5
(
int
device_count
,
std
::
vector
<
std
::
string
>
&
uuid_array
,
std
::
vector
<
std
::
string
>
&
md5_array
);
static
ServerError
GetUUIDSHA256
(
const
int
&
device_count
,
std
::
vector
<
std
::
string
>
&
uuid_array
,
std
::
vector
<
std
::
string
>
&
sha_array
);
static
ServerError
GetSystemTime
(
time_t
&
system_time
);
// Part 2: Handle License File
static
ServerError
LicenseFileSerialization
(
const
std
::
string
&
path
,
int
device_count
,
const
std
::
map
<
int
,
std
::
string
>
&
uuid_encrption_map
,
time_t
starting_time
,
time_t
end_time
);
static
ServerError
LicenseFileDeserialization
(
const
std
::
string
&
path
,
int
&
device_count
,
std
::
map
<
int
,
std
::
string
>
&
uuid_encrption_map
,
time_t
&
starting_time
,
time_t
&
end_time
);
//#pragma once
//
//#include "LicenseFile.h"
//#include "GPUInfoFile.h"
//
//#include "utils/Error.h"
//
//#include <boost/asio.hpp>
//#include <boost/thread.hpp>
//#include <boost/date_time/posix_time/posix_time.hpp>
//
//#include <vector>
//#include <map>
//#include <time.h>
//
//
//namespace zilliz {
//namespace milvus {
//namespace server {
//
//class LicenseLibrary {
// public:
// // Part 0: File check
// static bool
// IsFileExistent(const std::string &path);
//
// // Part 1: Get GPU Info
// static ServerError
// GetDeviceCount(int &device_count);
//
// static ServerError
// GetUUID(int device_count, std::vector<std::string> &uuid_array);
//
// static ServerError
// GetUUIDMD5(int device_count, std::vector<std::string> &uuid_array, std::vector<std::string> &md5_array);
//
//
// static ServerError
// GetUUIDSHA256(const int &device_count,
// std::vector<std::string> &uuid_array,
// std::vector<std::string> &sha_array);
//
// static ServerError
// SecretFileSerialization(const std::string &path,
// const time_t &update_time,
// const off_t &file_size,
// const time_t &starting_time,
// const time_t &end_time,
// const std::string &file_md5);
// GetSystemTime(time_t &system_time);
//
// // Part 2: Handle License File
// static ServerError
// SecretFileDeserialization(const std::string &path,
// time_t &update_time,
// off_t &file_size,
// time_t &starting_time,
// time_t &end_time,
// std::string &file_md5);
// Part 3: File attribute: UpdateTime Time/ Size/ MD5
static
ServerError
GetFileUpdateTimeAndSize
(
const
std
::
string
&
path
,
time_t
&
update_time
,
off_t
&
file_size
);
static
ServerError
GetFileMD5
(
const
std
::
string
&
path
,
std
::
string
&
filemd5
);
// Part 4: GPU Info File Serialization/Deserialization
static
ServerError
GPUinfoFileSerialization
(
const
std
::
string
&
path
,
int
device_count
,
const
std
::
map
<
int
,
std
::
string
>
&
uuid_encrption_map
);
static
ServerError
GPUinfoFileDeserialization
(
const
std
::
string
&
path
,
int
&
device_count
,
std
::
map
<
int
,
std
::
string
>
&
uuid_encrption_map
);
static
ServerError
GetDateTime
(
const
char
*
cha
,
time_t
&
data_time
);
private:
static
constexpr
int
sha256_length_
=
32
;
};
}
}
}
// LicenseFileSerialization(const std::string &path,
// int device_count,
// const std::map<int, std::string> &uuid_encrption_map,
// time_t starting_time,
// time_t end_time);
//
// static ServerError
// LicenseFileDeserialization(const std::string &path,
// int &device_count,
// std::map<int, std::string> &uuid_encrption_map,
// time_t &starting_time,
// time_t &end_time);
//
//// static ServerError
//// SecretFileSerialization(const std::string &path,
//// const time_t &update_time,
//// const off_t &file_size,
//// const time_t &starting_time,
//// const time_t &end_time,
//// const std::string &file_md5);
////
//// static ServerError
//// SecretFileDeserialization(const std::string &path,
//// time_t &update_time,
//// off_t &file_size,
//// time_t &starting_time,
//// time_t &end_time,
//// std::string &file_md5);
//
// // Part 3: File attribute: UpdateTime Time/ Size/ MD5
// static ServerError
// GetFileUpdateTimeAndSize(const std::string &path, time_t &update_time, off_t &file_size);
//
// static ServerError
// GetFileMD5(const std::string &path, std::string &filemd5);
//
// // Part 4: GPU Info File Serialization/Deserialization
// static ServerError
// GPUinfoFileSerialization(const std::string &path,
// int device_count,
// const std::map<int, std::string> &uuid_encrption_map);
// static ServerError
// GPUinfoFileDeserialization(const std::string &path,
// int &device_count,
// std::map<int, std::string> &uuid_encrption_map);
//
// static ServerError
// GetDateTime(const char *cha, time_t &data_time);
//
//
// private:
// static constexpr int sha256_length_ = 32;
//};
//
//
//}
//}
//}
cpp/src/utils/CommonUtil.cpp
浏览文件 @
a5365e4e
...
...
@@ -51,7 +51,7 @@ bool CommonUtil::GetSystemAvailableThreads(unsigned int &threadCnt) {
return
true
;
}
bool
CommonUtil
::
IsDirectoryExit
(
const
std
::
string
&
path
)
bool
CommonUtil
::
IsDirectoryExi
s
t
(
const
std
::
string
&
path
)
{
DIR
*
dp
=
nullptr
;
if
((
dp
=
opendir
(
path
.
c_str
()))
==
nullptr
)
{
...
...
@@ -182,7 +182,7 @@ void CommonUtil::ConvertTime(time_t time_integer, tm &time_struct) {
memcpy
(
&
time_struct
,
t_m
,
sizeof
(
tm
));
}
void
ConvertTime
(
tm
time_struct
,
time_t
&
time_integer
)
{
void
Co
mmonUtil
::
Co
nvertTime
(
tm
time_struct
,
time_t
&
time_integer
)
{
time_integer
=
mktime
(
&
time_struct
);
}
...
...
cpp/src/utils/CommonUtil.h
浏览文件 @
a5365e4e
...
...
@@ -20,7 +20,7 @@ class CommonUtil {
static
bool
GetSystemAvailableThreads
(
unsigned
int
&
threadCnt
);
static
bool
IsFileExist
(
const
std
::
string
&
path
);
static
bool
IsDirectoryExit
(
const
std
::
string
&
path
);
static
bool
IsDirectoryExi
s
t
(
const
std
::
string
&
path
);
static
ServerError
CreateDirectory
(
const
std
::
string
&
path
);
static
ServerError
DeleteDirectory
(
const
std
::
string
&
path
);
...
...
cpp/unittest/CMakeLists.txt
浏览文件 @
a5365e4e
...
...
@@ -42,6 +42,6 @@ set(unittest_libs
add_subdirectory
(
server
)
add_subdirectory
(
db
)
add_subdirectory
(
faiss_wrapper
)
add_subdirectory
(
license
)
#
add_subdirectory(license)
add_subdirectory
(
metrics
)
add_subdirectory
(
storage
)
\ No newline at end of file
cpp/unittest/license/license_check_test.cpp
浏览文件 @
a5365e4e
////
//// Created by zilliz on 19-5-13.
////
//
//#include "utils/Log.h"
//#include "license/LicenseCheck.h"
//#include "utils/Error.h"
//
//#include <gtest/gtest.h>
//#include <iostream>
//
//
//using namespace zilliz::milvus;
//
//TEST(LicenseLibraryTest, CHECK_TEST) {
//
//
// server::ServerError err;
// // 1. Set license file name
// std::string license_file_path("/tmp/milvus/abc.license");
//
// // 2. Legality check
// err = server::LicenseCheck::LegalityCheck(license_file_path);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
//}
//
//TEST(LicenseLibraryTest, CHECK_ERROR1_TEST){
//
// server::ServerError err;
// // 1. Set license file name
// std::string license_file_path("/tmp/milvus/abc");
//
// // 2. Legality check
// err = server::LicenseCheck::LegalityCheck(license_file_path);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//}
//
//TEST(LicenseLibraryTest, CHECK_ERROR2_TEST){
//
// server::ServerError err;
// // 1. Set license file name
// std::string license_file_path("/tmp/milvus/abc.license");
//
// // 2. Define output var
// int device_count;
// std::map<int, std::string> uuid_encryption_map;
// time_t starting_time;
// time_t end_time;
//
// // 3. Read License File
// err = server::LicenseLibrary::LicenseFileDeserialization(license_file_path,
// device_count,
// uuid_encryption_map,
// starting_time,
// end_time);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// // 4. Change device count
// ++device_count;
// err = server::LicenseLibrary::LicenseFileSerialization(license_file_path,
// device_count,
// uuid_encryption_map,
// starting_time,
// end_time);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// // 5. Legality check
// err = server::LicenseCheck::LegalityCheck(license_file_path);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//}
//
//TEST(LicenseLibraryTest, CHECK_ERROR3_TEST){
//
// server::ServerError err;
// // 1. Set license file name
// std::string license_file_path("/tmp/milvus/abc.license");
//
// // 2. Define output var
// int device_count;
// std::map<int, std::string> uuid_encryption_map;
// time_t starting_time;
// time_t end_time;
//
// // 3. Read License File
// err = server::LicenseLibrary::LicenseFileDeserialization(license_file_path,
// device_count,
// uuid_encryption_map,
// starting_time,
// end_time);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// // 4. Change device count
// if(device_count) uuid_encryption_map[0]+="u";
// err = server::LicenseLibrary::LicenseFileSerialization(license_file_path,
// device_count,
// uuid_encryption_map,
// starting_time,
// end_time);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// // 5. Legality check
// err = server::LicenseCheck::LegalityCheck(license_file_path);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//}
//
//TEST(LicenseLibraryTest, CHECK_ERROR4_1_TEST){
//
// server::ServerError err;
// // 1. Set license file name
// std::string license_file_path("/tmp/milvus/abc.license");
//
// // 2. Define output var
// int device_count;
// std::map<int, std::string> uuid_encryption_map;
// time_t starting_time;
// time_t end_time;
//
// // 3. Read License File
// err = server::LicenseLibrary::LicenseFileDeserialization(license_file_path,
// device_count,
// uuid_encryption_map,
// starting_time,
// end_time);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// // 4. Change starting time
// time_t system_time;
// err = server::LicenseLibrary::GetSystemTime(system_time);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// system_time+=60*60*24;
//
// err = server::LicenseLibrary::LicenseFileSerialization(license_file_path,
// device_count,
// uuid_encryption_map,
// system_time,
// end_time);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// // 5. Legality check
// err = server::LicenseCheck::LegalityCheck(license_file_path);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//}
//
//TEST(LicenseLibraryTest, CHECK_ERROR4_2_TEST){
//
// server::ServerError err;
// // 1. Set license file name
// std::string license_file_path("/tmp/milvus/abc.license");
//
// // 2. Define output var
// int device_count;
// std::map<int, std::string> uuid_encryption_map;
// time_t starting_time;
// time_t end_time;
//
// // 3. Read License File
// err = server::LicenseLibrary::LicenseFileDeserialization(license_file_path,
// device_count,
// uuid_encryption_map,
// starting_time,
// end_time);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// // 4. Change end time
// time_t system_time;
// err = server::LicenseLibrary::GetSystemTime(system_time);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// system_time-=100;
//
// err = server::LicenseLibrary::LicenseFileSerialization(license_file_path,
// device_count,
// uuid_encryption_map,
// starting_time,
// system_time);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// // 5. Legality check
// err = server::LicenseCheck::LegalityCheck(license_file_path);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//}
//
// Created by zilliz on 19-5-13.
//
#include "utils/Log.h"
#include "license/LicenseCheck.h"
#include "utils/Error.h"
#include <gtest/gtest.h>
#include <iostream>
using
namespace
zilliz
::
milvus
;
TEST
(
LicenseLibraryTest
,
CHECK_TEST
)
{
server
::
ServerError
err
;
// 1. Set license file name
std
::
string
license_file_path
(
"/tmp/milvus/abc.license"
);
// 2. Legality check
err
=
server
::
LicenseCheck
::
LegalityCheck
(
license_file_path
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
}
TEST
(
LicenseLibraryTest
,
CHECK_ERROR1_TEST
){
server
::
ServerError
err
;
// 1. Set license file name
std
::
string
license_file_path
(
"/tmp/milvus/abc"
);
// 2. Legality check
err
=
server
::
LicenseCheck
::
LegalityCheck
(
license_file_path
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
}
TEST
(
LicenseLibraryTest
,
CHECK_ERROR2_TEST
){
server
::
ServerError
err
;
// 1. Set license file name
std
::
string
license_file_path
(
"/tmp/milvus/abc.license"
);
// 2. Define output var
int
device_count
;
std
::
map
<
int
,
std
::
string
>
uuid_encryption_map
;
time_t
starting_time
;
time_t
end_time
;
// 3. Read License File
err
=
server
::
LicenseLibrary
::
LicenseFileDeserialization
(
license_file_path
,
device_count
,
uuid_encryption_map
,
starting_time
,
end_time
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
// 4. Change device count
++
device_count
;
err
=
server
::
LicenseLibrary
::
LicenseFileSerialization
(
license_file_path
,
device_count
,
uuid_encryption_map
,
starting_time
,
end_time
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
// 5. Legality check
err
=
server
::
LicenseCheck
::
LegalityCheck
(
license_file_path
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
}
TEST
(
LicenseLibraryTest
,
CHECK_ERROR3_TEST
){
server
::
ServerError
err
;
// 1. Set license file name
std
::
string
license_file_path
(
"/tmp/milvus/abc.license"
);
// 2. Define output var
int
device_count
;
std
::
map
<
int
,
std
::
string
>
uuid_encryption_map
;
time_t
starting_time
;
time_t
end_time
;
// 3. Read License File
err
=
server
::
LicenseLibrary
::
LicenseFileDeserialization
(
license_file_path
,
device_count
,
uuid_encryption_map
,
starting_time
,
end_time
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
// 4. Change device count
if
(
device_count
)
uuid_encryption_map
[
0
]
+=
"u"
;
err
=
server
::
LicenseLibrary
::
LicenseFileSerialization
(
license_file_path
,
device_count
,
uuid_encryption_map
,
starting_time
,
end_time
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
// 5. Legality check
err
=
server
::
LicenseCheck
::
LegalityCheck
(
license_file_path
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
}
TEST
(
LicenseLibraryTest
,
CHECK_ERROR4_1_TEST
){
server
::
ServerError
err
;
// 1. Set license file name
std
::
string
license_file_path
(
"/tmp/milvus/abc.license"
);
// 2. Define output var
int
device_count
;
std
::
map
<
int
,
std
::
string
>
uuid_encryption_map
;
time_t
starting_time
;
time_t
end_time
;
// 3. Read License File
err
=
server
::
LicenseLibrary
::
LicenseFileDeserialization
(
license_file_path
,
device_count
,
uuid_encryption_map
,
starting_time
,
end_time
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
// 4. Change starting time
time_t
system_time
;
err
=
server
::
LicenseLibrary
::
GetSystemTime
(
system_time
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
system_time
+=
60
*
60
*
24
;
err
=
server
::
LicenseLibrary
::
LicenseFileSerialization
(
license_file_path
,
device_count
,
uuid_encryption_map
,
system_time
,
end_time
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
// 5. Legality check
err
=
server
::
LicenseCheck
::
LegalityCheck
(
license_file_path
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
}
TEST
(
LicenseLibraryTest
,
CHECK_ERROR4_2_TEST
){
server
::
ServerError
err
;
// 1. Set license file name
std
::
string
license_file_path
(
"/tmp/milvus/abc.license"
);
// 2. Define output var
int
device_count
;
std
::
map
<
int
,
std
::
string
>
uuid_encryption_map
;
time_t
starting_time
;
time_t
end_time
;
// 3. Read License File
err
=
server
::
LicenseLibrary
::
LicenseFileDeserialization
(
license_file_path
,
device_count
,
uuid_encryption_map
,
starting_time
,
end_time
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
// 4. Change end time
time_t
system_time
;
err
=
server
::
LicenseLibrary
::
GetSystemTime
(
system_time
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
system_time
-=
100
;
err
=
server
::
LicenseLibrary
::
LicenseFileSerialization
(
license_file_path
,
device_count
,
uuid_encryption_map
,
starting_time
,
system_time
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
// 5. Legality check
err
=
server
::
LicenseCheck
::
LegalityCheck
(
license_file_path
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
}
cpp/unittest/license/license_library_tests.cpp
浏览文件 @
a5365e4e
/*******************************************************************************
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#include "utils/Log.h"
#include "license/LicenseLibrary.h"
#include "utils/Error.h"
#include <gtest/gtest.h>
#include <iostream>
using
namespace
zilliz
::
milvus
;
TEST
(
LicenseLibraryTest
,
FILE_EXISTENT_TEST
)
{
std
::
string
hosts_file
=
"/etc/hosts"
;
ASSERT_EQ
(
server
::
LicenseLibrary
::
IsFileExistent
(
hosts_file
),
true
);
std
::
string
no_exist_file
=
"/temp/asdaasd"
;
ASSERT_EQ
(
server
::
LicenseLibrary
::
IsFileExistent
(
no_exist_file
),
false
);
std
::
string
directory
=
"/tmp"
;
ASSERT_EQ
(
server
::
LicenseLibrary
::
IsFileExistent
(
directory
),
false
);
}
TEST
(
LicenseLibraryTest
,
GPU_INFO_TEST
)
{
int
device_count
=
0
;
server
::
ServerError
err
=
server
::
LicenseLibrary
::
GetDeviceCount
(
device_count
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
std
::
cout
<<
"Device Count: "
<<
device_count
<<
std
::
endl
;
std
::
vector
<
std
::
string
>
uuid_array
;
err
=
server
::
LicenseLibrary
::
GetUUID
(
device_count
,
uuid_array
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
for
(
long
i
=
0
;
i
<
device_count
;
++
i
)
{
std
::
cout
<<
"Device Id: "
<<
i
<<
", UUID: "
<<
uuid_array
[
i
]
<<
std
::
endl
;
}
std
::
vector
<
std
::
string
>
uuid_md5_array
;
err
=
server
::
LicenseLibrary
::
GetUUIDMD5
(
device_count
,
uuid_array
,
uuid_md5_array
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
for
(
long
i
=
0
;
i
<
device_count
;
++
i
)
{
std
::
cout
<<
"Device Id: "
<<
i
<<
", UUID: "
<<
uuid_array
[
i
]
<<
", UUID_MD5: "
<<
uuid_md5_array
[
i
]
<<
std
::
endl
;
}
std
::
vector
<
std
::
string
>
uuid_sha256_array
;
err
=
server
::
LicenseLibrary
::
GetUUIDSHA256
(
device_count
,
uuid_array
,
uuid_sha256_array
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
for
(
long
i
=
0
;
i
<
device_count
;
++
i
)
{
std
::
cout
<<
"Device Id: "
<<
i
<<
", UUID: "
<<
uuid_array
[
i
]
<<
", UUID_SHA256: "
<<
uuid_sha256_array
[
i
]
<<
std
::
endl
;
}
time_t
systemtime
;
err
=
server
::
LicenseLibrary
::
GetSystemTime
(
systemtime
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
std
::
cout
<<
"System Time: "
<<
systemtime
<<
std
::
endl
;
}
TEST
(
LicenseLibraryTest
,
LICENSE_FILE_TEST
)
{
// 0. File check
std
::
string
test
(
"/tmp/a.test"
);
bool
is
=
server
::
LicenseLibrary
::
IsFileExistent
(
test
);
ASSERT_EQ
(
is
,
false
);
// 1. Get Device Count
int
device_count
=
0
;
server
::
ServerError
err
=
server
::
LicenseLibrary
::
GetDeviceCount
(
device_count
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
// 2. Get All GPU UUID
std
::
vector
<
std
::
string
>
uuid_array
;
err
=
server
::
LicenseLibrary
::
GetUUID
(
device_count
,
uuid_array
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
// 3. Get UUID SHA256
std
::
vector
<
std
::
string
>
uuid_sha256_array
;
err
=
server
::
LicenseLibrary
::
GetUUIDSHA256
(
device_count
,
uuid_array
,
uuid_sha256_array
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
// 4. Generate GPU ID map with GPU UUID
std
::
map
<
int
,
std
::
string
>
uuid_encrption_map
;
for
(
int
i
=
0
;
i
<
device_count
;
++
i
)
{
uuid_encrption_map
[
i
]
=
uuid_sha256_array
[
i
];
}
// 5.GPU_info File
std
::
string
GPU_info_file_path
(
"/tmp/milvus.info"
);
// 6. Generate GPU_info File
err
=
server
::
LicenseLibrary
::
GPUinfoFileSerialization
(
GPU_info_file_path
,
device_count
,
uuid_encrption_map
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
// 7. Define output var
int
output_info_device_count
=
0
;
std
::
map
<
int
,
std
::
string
>
output_info_uuid_encrption_map
;
// 8. Read GPU_info File
err
=
server
::
LicenseLibrary
::
GPUinfoFileDeserialization
(
GPU_info_file_path
,
output_info_device_count
,
output_info_uuid_encrption_map
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
ASSERT_EQ
(
device_count
,
output_info_device_count
);
for
(
int
i
=
0
;
i
<
device_count
;
++
i
)
{
ASSERT_EQ
(
uuid_encrption_map
[
i
],
output_info_uuid_encrption_map
[
i
]);
}
// 9. Set license file name
std
::
string
license_file_path
(
"/tmp/milvus.license"
);
// 10. Get System Time/starting_time ans End Time
time_t
sysyem_time
;
err
=
server
::
LicenseLibrary
::
GetSystemTime
(
sysyem_time
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
// 11.GetDateTime
time_t
starting_time
;
time_t
end_time
;
const
char
*
string_starting_time
=
"2019-05-10"
;
const
char
*
string_end_time
=
"2022-05-10"
;
err
=
server
::
LicenseLibrary
::
GetDateTime
(
string_starting_time
,
starting_time
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
err
=
server
::
LicenseLibrary
::
GetDateTime
(
string_end_time
,
end_time
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
// 12. Generate License File
err
=
server
::
LicenseLibrary
::
LicenseFileSerialization
(
license_file_path
,
device_count
,
uuid_encrption_map
,
starting_time
,
end_time
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
// 13. Define output var
int
output_device_count
=
0
;
std
::
map
<
int
,
std
::
string
>
output_uuid_encrption_map
;
time_t
output_starting_time
;
time_t
output_end_time
;
// 14. Read License File
err
=
server
::
LicenseLibrary
::
LicenseFileDeserialization
(
license_file_path
,
output_device_count
,
output_uuid_encrption_map
,
output_starting_time
,
output_end_time
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
ASSERT_EQ
(
device_count
,
output_device_count
);
ASSERT_EQ
(
starting_time
,
output_starting_time
);
ASSERT_EQ
(
end_time
,
output_end_time
);
for
(
int
i
=
0
;
i
<
device_count
;
++
i
)
{
ASSERT_EQ
(
uuid_encrption_map
[
i
],
output_uuid_encrption_map
[
i
]);
}
// // 15. Get License File Attribute
// time_t update_time;
// off_t file_size;
// err = server::LicenseLibrary::GetFileUpdateTimeAndSize(license_file_path, update_time, file_size);
///*******************************************************************************
// * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
// * Unauthorized copying of this file, via any medium is strictly prohibited.
// * Proprietary and confidential.
// ******************************************************************************/
//
//
//#include "utils/Log.h"
//#include "license/LicenseLibrary.h"
//#include "utils/Error.h"
//
//#include <gtest/gtest.h>
//#include <iostream>
//
//
//using namespace zilliz::milvus;
//
//TEST(LicenseLibraryTest, FILE_EXISTENT_TEST) {
//
// std::string hosts_file = "/etc/hosts";
// ASSERT_EQ(server::LicenseLibrary::IsFileExistent(hosts_file), true);
//
// std::string no_exist_file = "/temp/asdaasd";
// ASSERT_EQ(server::LicenseLibrary::IsFileExistent(no_exist_file), false);
//
// std::string directory = "/tmp";
// ASSERT_EQ(server::LicenseLibrary::IsFileExistent(directory), false);
//}
//
//TEST(LicenseLibraryTest, GPU_INFO_TEST) {
//
// int device_count = 0;
// server::ServerError err = server::LicenseLibrary::GetDeviceCount(device_count);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
// std::cout << "Device Count: " << device_count << std::endl;
//
// // 16. Get License File MD5
// std::string file_md5;
// err = server::LicenseLibrary::GetFileMD5(license_file_path, file_md5);
// std::vector<std::string> uuid_array;
// err = server::LicenseLibrary::GetUUID(device_count, uuid_array);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
// // 17. Generate Secret File
// std::string secret_file_path("/tmp/milvus.secret");
// err = server::LicenseLibrary::SecretFileSerialization(secret_file_path,
// update_time,
// file_size,
// starting_time,
// end_time,
// file_md5);
// for (long i = 0; i < device_count; ++i) {
// std::cout << "Device Id: " << i << ", UUID: " << uuid_array[i] << std::endl;
// }
//
// std::vector<std::string> uuid_md5_array;
// err = server::LicenseLibrary::GetUUIDMD5(device_count, uuid_array, uuid_md5_array);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
// for (long i = 0; i < device_count; ++i) {
// std::cout << "Device Id: " << i << ", UUID: " << uuid_array[i] << ", UUID_MD5: " << uuid_md5_array[i]
// << std::endl;
// }
//
// std::vector<std::string> uuid_sha256_array;
// err = server::LicenseLibrary::GetUUIDSHA256(device_count, uuid_array, uuid_sha256_array);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
// // 18. Define output var
// time_t output_update_time;
// off_t output_file_size;
// for (long i = 0; i < device_count; ++i) {
// std::cout << "Device Id: " << i << ", UUID: " << uuid_array[i] << ", UUID_SHA256: "
// << uuid_sha256_array[i] << std::endl;
// }
//
// time_t systemtime;
// err = server::LicenseLibrary::GetSystemTime(systemtime);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
// std::cout << "System Time: " << systemtime << std::endl;
//
//}
//
//TEST(LicenseLibraryTest, LICENSE_FILE_TEST) {
//
// // 0. File check
// std::string test("/tmp/a.test");
// bool is = server::LicenseLibrary::IsFileExistent(test);
// ASSERT_EQ(is, false);
//
// // 1. Get Device Count
// int device_count = 0;
// server::ServerError err = server::LicenseLibrary::GetDeviceCount(device_count);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// // 2. Get All GPU UUID
// std::vector<std::string> uuid_array;
// err = server::LicenseLibrary::GetUUID(device_count, uuid_array);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// // 3. Get UUID SHA256
// std::vector<std::string> uuid_sha256_array;
// err = server::LicenseLibrary::GetUUIDSHA256(device_count, uuid_array, uuid_sha256_array);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// // 4. Generate GPU ID map with GPU UUID
// std::map<int, std::string> uuid_encrption_map;
// for (int i = 0; i < device_count; ++i) {
// uuid_encrption_map[i] = uuid_sha256_array[i];
// }
//
// // 5.GPU_info File
// std::string GPU_info_file_path("/tmp/milvus.info");
//
//
// // 6. Generate GPU_info File
// err = server::LicenseLibrary::GPUinfoFileSerialization(GPU_info_file_path,
// device_count,
// uuid_encrption_map);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// // 7. Define output var
// int output_info_device_count = 0;
// std::map<int, std::string> output_info_uuid_encrption_map;
//
// // 8. Read GPU_info File
// err = server::LicenseLibrary::GPUinfoFileDeserialization(GPU_info_file_path,
// output_info_device_count,
// output_info_uuid_encrption_map);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// ASSERT_EQ(device_count, output_info_device_count);
// for (int i = 0; i < device_count; ++i) {
// ASSERT_EQ(uuid_encrption_map[i], output_info_uuid_encrption_map[i]);
// }
//
// // 9. Set license file name
// std::string license_file_path("/tmp/milvus.license");
//
// // 10. Get System Time/starting_time ans End Time
// time_t sysyem_time;
// err = server::LicenseLibrary::GetSystemTime(sysyem_time);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// // 11.GetDateTime
// time_t starting_time;
// time_t end_time;
// const char *string_starting_time = "2019-05-10";
// const char *string_end_time = "2022-05-10";
// err = server::LicenseLibrary::GetDateTime(string_starting_time, starting_time);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
// err = server::LicenseLibrary::GetDateTime(string_end_time, end_time);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// // 12. Generate License File
// err = server::LicenseLibrary::LicenseFileSerialization(license_file_path,
// device_count,
// uuid_encrption_map,
// starting_time,
// end_time);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// // 13. Define output var
// int output_device_count = 0;
// std::map<int, std::string> output_uuid_encrption_map;
// time_t output_starting_time;
// time_t output_end_time;
// std::string output_file_md5;
// // 19. Read License File
// err = server::LicenseLibrary::SecretFileDeserialization(secret_file_path,
// output_update_time,
// output_file_size,
// output_starting_time,
// output_end_time,
// output_file_md5);
//
// // 14. Read License File
// err = server::LicenseLibrary::LicenseFileDeserialization(license_file_path,
// output_device_count,
// output_uuid_encrption_map,
// output_starting_time,
// output_end_time);
// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
// ASSERT_EQ(update_time, output_update_time);
// ASSERT_EQ(file_size, output_file_size);
// ASSERT_EQ(device_count, output_device_count);
// ASSERT_EQ(starting_time, output_starting_time);
// ASSERT_EQ(end_time, output_end_time);
// ASSERT_EQ(file_md5, output_file_md5);
}
//
// for (int i = 0; i < device_count; ++i) {
// ASSERT_EQ(uuid_encrption_map[i], output_uuid_encrption_map[i]);
// }
//
//// // 15. Get License File Attribute
//// time_t update_time;
//// off_t file_size;
//// err = server::LicenseLibrary::GetFileUpdateTimeAndSize(license_file_path, update_time, file_size);
//// ASSERT_EQ(err, server::SERVER_SUCCESS);
////
//// // 16. Get License File MD5
//// std::string file_md5;
//// err = server::LicenseLibrary::GetFileMD5(license_file_path, file_md5);
//// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
//
//
//// // 17. Generate Secret File
//// std::string secret_file_path("/tmp/milvus.secret");
//// err = server::LicenseLibrary::SecretFileSerialization(secret_file_path,
//// update_time,
//// file_size,
//// starting_time,
//// end_time,
//// file_md5);
//// ASSERT_EQ(err, server::SERVER_SUCCESS);
//
//// // 18. Define output var
//// time_t output_update_time;
//// off_t output_file_size;
//// time_t output_starting_time;
//// time_t output_end_time;
//// std::string output_file_md5;
//
//// // 19. Read License File
//// err = server::LicenseLibrary::SecretFileDeserialization(secret_file_path,
//// output_update_time,
//// output_file_size,
//// output_starting_time,
//// output_end_time,
//// output_file_md5);
//// ASSERT_EQ(err, server::SERVER_SUCCESS);
////
//// ASSERT_EQ(update_time, output_update_time);
//// ASSERT_EQ(file_size, output_file_size);
//// ASSERT_EQ(starting_time, output_starting_time);
//// ASSERT_EQ(end_time, output_end_time);
//// ASSERT_EQ(file_md5, output_file_md5);
//
//
//}
cpp/unittest/server/CMakeLists.txt
浏览文件 @
a5365e4e
...
...
@@ -18,6 +18,7 @@ set(utils_srcs
${
MILVUS_ENGINE_SRC
}
/utils/StringHelpFunctions.cpp
${
MILVUS_ENGINE_SRC
}
/utils/TimeRecorder.cpp
${
MILVUS_ENGINE_SRC
}
/utils/CommonUtil.cpp
${
MILVUS_ENGINE_SRC
}
/utils/LogUtil.cpp
)
cuda_add_executable
(
server_test
...
...
@@ -54,3 +55,11 @@ target_link_libraries(server_test
)
install
(
TARGETS server_test DESTINATION bin
)
configure_file
(
appendix/server_config.yaml
"
${
CMAKE_CURRENT_BINARY_DIR
}
/milvus/conf/server_config.yaml"
COPYONLY
)
configure_file
(
appendix/log_config.conf
"
${
CMAKE_CURRENT_BINARY_DIR
}
/milvus/conf/log_config.conf"
COPYONLY
)
cpp/unittest/server/appendix/log_config.conf
0 → 100644
浏览文件 @
a5365e4e
*
GLOBAL
:
FORMAT
=
"%datetime | %level | %logger | %msg"
FILENAME
=
"/tmp/milvus/logs/milvus-%datetime{%H:%m}-global.log"
ENABLED
=
true
TO_FILE
=
true
TO_STANDARD_OUTPUT
=
false
SUBSECOND_PRECISION
=
3
PERFORMANCE_TRACKING
=
false
MAX_LOG_FILE_SIZE
=
2097152
## Throw log files away after 2MB
*
DEBUG
:
FILENAME
=
"/tmp/milvus/logs/milvus-%datetime{%H:%m}-debug.log"
ENABLED
=
true
*
WARNING
:
FILENAME
=
"/tmp/milvus/logs/milvus-%datetime{%H:%m}-warning.log"
*
TRACE
:
FILENAME
=
"/tmp/milvus/logs/milvus-%datetime{%H:%m}-trace.log"
*
VERBOSE
:
FORMAT
=
"%datetime{%d/%M/%y} | %level-%vlevel | %msg"
TO_FILE
=
false
TO_STANDARD_OUTPUT
=
false
## Error logs
*
ERROR
:
ENABLED
=
true
FILENAME
=
"/tmp/milvus/logs/milvus-%datetime{%H:%m}-error.log"
*
FATAL
:
ENABLED
=
true
FILENAME
=
"/tmp/milvus/logs/milvus-%datetime{%H:%m}-fatal.log"
cpp/unittest/server/appendix/server_config.yaml
0 → 100644
浏览文件 @
a5365e4e
server_config
:
address
:
0.0.0.0
port
:
19530
# the port milvus listen to, default: 19530, range: 1025 ~ 65534
gpu_index
:
0
# the gpu milvus use, default: 0, range: 0 ~ gpu number - 1
mode
:
single
# milvus deployment type: single, cluster
db_config
:
db_path
:
/tmp/milvus
# milvus data storage path
db_backend_url
:
http://127.0.0.1
# meta database uri
index_building_threshold
:
1024
# index building trigger threshold, default: 1024, unit: MB
archive_disk_threshold
:
512
# triger archive action if storage size exceed this value, unit: GB
archive_days_threshold
:
30
# files older than x days will be archived, unit: day
metric_config
:
is_startup
:
off
# if monitoring start: on, off
collector
:
prometheus
# metrics collector: prometheus
prometheus_config
:
# following are prometheus configure
collect_type
:
pull
# prometheus collect data method
port
:
8080
# the port prometheus use to fetch metrics
push_gateway_ip_address
:
127.0.0.1
# push method configure: push gateway ip address
push_gateway_port
:
9091
# push method configure: push gateway port
license_config
:
# license configure
license_path
:
"
/tmp/milvus/system.license"
# license file path
cache_config
:
# cache configure
cpu_cache_capacity
:
16
# how many memory are used as cache, unit: GB, range: 0 ~ less than total memory
cpp/unittest/server/cache_test.cpp
浏览文件 @
a5365e4e
...
...
@@ -11,6 +11,23 @@
using
namespace
zilliz
::
milvus
;
namespace
{
class
InvalidCacheMgr
:
public
cache
::
CacheMgr
{
public:
InvalidCacheMgr
()
{
}
};
class
LessItemCacheMgr
:
public
cache
::
CacheMgr
{
public:
LessItemCacheMgr
()
{
cache_
=
std
::
make_shared
<
cache
::
Cache
>
(
1UL
<<
12
,
10
);
}
};
}
TEST
(
CacheTest
,
CPU_CACHE_TEST
)
{
cache
::
CacheMgr
*
cpu_mgr
=
cache
::
CpuCacheMgr
::
GetInstance
();
...
...
@@ -78,4 +95,35 @@ TEST(CacheTest, GPU_CACHE_TEST) {
gpu_mgr
->
ClearCache
();
ASSERT_EQ
(
gpu_mgr
->
ItemCount
(),
0
);
}
TEST
(
CacheTest
,
INVALID_TEST
)
{
{
InvalidCacheMgr
mgr
;
ASSERT_EQ
(
mgr
.
ItemCount
(),
0
);
ASSERT_FALSE
(
mgr
.
ItemExists
(
"test"
));
ASSERT_EQ
(
mgr
.
GetItem
(
"test"
),
nullptr
);
mgr
.
InsertItem
(
"test"
,
cache
::
DataObjPtr
());
mgr
.
InsertItem
(
"test"
,
engine
::
Index_ptr
(
nullptr
));
mgr
.
EraseItem
(
"test"
);
mgr
.
PrintInfo
();
mgr
.
ClearCache
();
mgr
.
SetCapacity
(
100
);
ASSERT_EQ
(
mgr
.
CacheCapacity
(),
0
);
ASSERT_EQ
(
mgr
.
CacheUsage
(),
0
);
}
{
LessItemCacheMgr
mgr
;
for
(
int
i
=
0
;
i
<
20
;
i
++
)
{
std
::
shared_ptr
<
faiss
::
Index
>
raw_index
(
faiss
::
index_factory
(
2
,
"IDMap,Flat"
));
engine
::
Index_ptr
index
=
std
::
make_shared
<
engine
::
Index
>
(
raw_index
);
index
->
ntotal
=
2
;
cache
::
DataObjPtr
obj
=
std
::
make_shared
<
cache
::
DataObj
>
(
index
);
mgr
.
InsertItem
(
"index_"
+
std
::
to_string
(
i
),
obj
);
}
ASSERT_EQ
(
mgr
.
GetItem
(
"index_0"
),
nullptr
);
}
}
\ No newline at end of file
cpp/unittest/server/config_test.cpp
浏览文件 @
a5365e4e
...
...
@@ -10,13 +10,27 @@
using
namespace
zilliz
::
milvus
;
static
const
std
::
string
CONFIG_FILE_PATH
=
"../../../conf/server_config.yaml"
;
namespace
{
static
const
std
::
string
CONFIG_FILE_PATH
=
"./milvus/conf/server_config.yaml"
;
static
const
std
::
string
LOG_FILE_PATH
=
"./milvus/conf/log_config.conf"
;
}
TEST
(
ConfigTest
,
CONFIG_TEST
)
{
server
::
IConfigMgr
*
config_mgr
=
server
::
IConfigMgr
::
GetInstance
();
server
::
ServerError
err
=
config_mgr
->
LoadConfigFile
(
CONFIG_FILE_PATH
);
server
::
ServerError
err
=
config_mgr
->
LoadConfigFile
(
""
);
ASSERT_EQ
(
err
,
server
::
SERVER_UNEXPECTED_ERROR
);
err
=
config_mgr
->
LoadConfigFile
(
LOG_FILE_PATH
);
ASSERT_EQ
(
err
,
server
::
SERVER_UNEXPECTED_ERROR
);
err
=
config_mgr
->
LoadConfigFile
(
CONFIG_FILE_PATH
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
config_mgr
->
Print
();
server
::
ConfigNode
&
root_config
=
config_mgr
->
GetRootNode
();
server
::
ConfigNode
&
server_config
=
root_config
.
GetChild
(
"server_config"
);
server
::
ConfigNode
&
db_config
=
root_config
.
GetChild
(
"db_config"
);
...
...
@@ -43,10 +57,6 @@ TEST(ConfigTest, CONFIG_TEST) {
auto
children
=
server_config
.
GetChildren
();
ASSERT_TRUE
(
children
.
empty
());
root_config
.
PrintAll
();
std
::
string
all
=
root_config
.
DumpString
();
ASSERT_TRUE
(
!
all
.
empty
());
server_config
.
ClearConfig
();
auto
configs
=
server_config
.
GetConfig
();
ASSERT_TRUE
(
configs
.
empty
());
...
...
@@ -56,9 +66,20 @@ TEST(ConfigTest, CONFIG_TEST) {
auto
seq
=
server_config
.
GetSequence
(
"seq"
);
ASSERT_EQ
(
seq
.
size
(),
2UL
);
server
::
ConfigNode
combine
;
combine
.
Combine
(
server_config
);
combine
.
PrintAll
();
std
::
string
all
=
combine
.
DumpString
();
ASSERT_TRUE
(
!
all
.
empty
());
server_config
.
ClearSequences
();
auto
seqs
=
server_config
.
GetSequences
();
ASSERT_TRUE
(
seqs
.
empty
());
const
server
::
ConfigNode
const_node
=
root_config
.
GetChild
(
"cache_config"
);
float
flt
=
const_node
.
GetFloatValue
(
"cpu_cache_capacity"
);
ASSERT_GT
(
flt
,
0.0
);
}
TEST
(
ConfigTest
,
SERVER_CONFIG_TEST
)
{
...
...
@@ -73,5 +94,12 @@ TEST(ConfigTest, SERVER_CONFIG_TEST) {
int32_t
cap
=
node1
.
GetInt32Value
(
"cpu_cache_capacity"
);
ASSERT_GT
(
cap
,
0
);
node1
.
SetValue
(
"bool"
,
"true"
);
bool
bt
=
node1
.
GetBoolValue
(
"bool"
);
ASSERT_TRUE
(
bt
);
config
.
PrintAll
();
const
server
::
ServerConfig
const_config
=
config
;
server
::
ConfigNode
node
=
const_config
.
GetConfig
(
"aaa"
);
}
\ No newline at end of file
cpp/unittest/server/util_test.cpp
浏览文件 @
a5365e4e
...
...
@@ -11,35 +11,83 @@
#include "utils/StringHelpFunctions.h"
#include "utils/TimeRecorder.h"
#include "utils/BlockingQueue.h"
#include "utils/LogUtil.h"
using
namespace
zilliz
::
milvus
;
namespace
{
static
const
std
::
string
LOG_FILE_PATH
=
"./milvus/conf/log_config.conf"
;
using
TimeUnit
=
server
::
TimeRecorder
::
TimeDisplayUnit
;
double
TestTimeRecorder
(
TimeUnit
unit
,
int64_t
log_level
)
{
double
TestTimeRecorder
(
TimeUnit
unit
,
int64_t
log_level
,
int64_t
sleep_ms
)
{
server
::
TimeRecorder
rc
(
"test rc"
,
unit
,
log_level
);
rc
.
Record
(
"begin"
);
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
mi
croseconds
(
10
));
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
mi
lliseconds
(
sleep_ms
));
rc
.
Elapse
(
"end"
);
return
rc
.
Span
();
}
}
TEST
(
CommonTest
,
COMMON_TEST
)
{
TEST
(
UtilTest
,
EXCEPTION_TEST
)
{
std
::
string
err_msg
=
"failed"
;
server
::
ServerException
ex
(
server
::
SERVER_UNEXPECTED_ERROR
,
err_msg
);
ASSERT_EQ
(
ex
.
error_code
(),
server
::
SERVER_UNEXPECTED_ERROR
);
std
::
string
msg
=
ex
.
what
();
ASSERT_EQ
(
msg
,
err_msg
);
}
TEST
(
UtilTest
,
COMMON_TEST
)
{
unsigned
long
total_mem
=
0
,
free_mem
=
0
;
server
::
CommonUtil
::
GetSystemMemInfo
(
total_mem
,
free_mem
);
ASSERT_GT
(
total_mem
,
0
);
ASSERT_GT
(
free_mem
,
0
);
unsigned
int
thread_cnt
=
0
;
server
::
CommonUtil
::
GetSystemAvailableThreads
(
thread_cnt
);
ASSERT_GT
(
thread_cnt
,
0
);
std
::
string
path1
=
"/tmp/milvus_test/"
;
std
::
string
path2
=
path1
+
"common_test_12345/"
;
std
::
string
path3
=
path2
+
"abcdef"
;
server
::
ServerError
err
=
server
::
CommonUtil
::
CreateDirectory
(
path3
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
//test again
err
=
server
::
CommonUtil
::
CreateDirectory
(
path3
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
ASSERT_TRUE
(
server
::
CommonUtil
::
IsDirectoryExit
(
path3
));
ASSERT_TRUE
(
server
::
CommonUtil
::
IsDirectoryExi
s
t
(
path3
));
err
=
server
::
CommonUtil
::
DeleteDirectory
(
path1
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
//test again
err
=
server
::
CommonUtil
::
DeleteDirectory
(
path1
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
ASSERT_FALSE
(
server
::
CommonUtil
::
IsDirectoryExit
(
path1
));
ASSERT_FALSE
(
server
::
CommonUtil
::
IsDirectoryExist
(
path1
));
ASSERT_FALSE
(
server
::
CommonUtil
::
IsFileExist
(
path1
));
std
::
string
exe_path
=
server
::
CommonUtil
::
GetExePath
();
ASSERT_FALSE
(
exe_path
.
empty
());
time_t
tt
;
time
(
&
tt
);
tm
time_struct
;
memset
(
&
time_struct
,
0
,
sizeof
(
tm
));
server
::
CommonUtil
::
ConvertTime
(
tt
,
time_struct
);
ASSERT_GT
(
time_struct
.
tm_year
,
0
);
ASSERT_GT
(
time_struct
.
tm_mon
,
0
);
ASSERT_GT
(
time_struct
.
tm_mday
,
0
);
server
::
CommonUtil
::
ConvertTime
(
time_struct
,
tt
);
ASSERT_GT
(
tt
,
0
);
bool
res
=
server
::
CommonUtil
::
TimeStrToTime
(
"2019-03-23"
,
tt
,
time_struct
);
ASSERT_EQ
(
time_struct
.
tm_year
,
119
);
ASSERT_EQ
(
time_struct
.
tm_mon
,
2
);
ASSERT_EQ
(
time_struct
.
tm_mday
,
23
);
ASSERT_GT
(
tt
,
0
);
ASSERT_TRUE
(
res
);
}
TEST
(
UtilTest
,
STRINGFUNCTIONS_TEST
)
{
...
...
@@ -47,29 +95,49 @@ TEST(UtilTest, STRINGFUNCTIONS_TEST) {
server
::
StringHelpFunctions
::
TrimStringBlank
(
str
);
ASSERT_EQ
(
str
,
"test zilliz"
);
str
=
"
\"
test zilliz
\"
"
;
server
::
StringHelpFunctions
::
TrimStringQuote
(
str
,
"
\"
"
);
ASSERT_EQ
(
str
,
"test zilliz"
);
str
=
"a,b,c"
;
std
::
vector
<
std
::
string
>
result
;
server
::
StringHelpFunctions
::
SplitStringByDelimeter
(
str
,
","
,
result
);
server
::
ServerError
err
=
server
::
StringHelpFunctions
::
SplitStringByDelimeter
(
str
,
","
,
result
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
ASSERT_EQ
(
result
.
size
(),
3UL
);
result
.
clear
();
err
=
server
::
StringHelpFunctions
::
SplitStringByQuote
(
str
,
","
,
"
\"
"
,
result
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
ASSERT_EQ
(
result
.
size
(),
3UL
);
result
.
clear
();
err
=
server
::
StringHelpFunctions
::
SplitStringByQuote
(
str
,
","
,
""
,
result
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
ASSERT_EQ
(
result
.
size
(),
3UL
);
str
=
"55,
\"
aa,gg,yy
\"
,b"
;
result
.
clear
();
server
::
StringHelpFunctions
::
SplitStringByQuote
(
str
,
","
,
"
\"
"
,
result
);
err
=
server
::
StringHelpFunctions
::
SplitStringByQuote
(
str
,
","
,
"
\"
"
,
result
);
ASSERT_EQ
(
err
,
server
::
SERVER_SUCCESS
);
ASSERT_EQ
(
result
.
size
(),
3UL
);
}
TEST
(
UtilTest
,
TIMERECORDER_TEST
)
{
double
span
=
TestTimeRecorder
(
TimeUnit
::
eTimeAutoUnit
,
0
);
double
span
=
TestTimeRecorder
(
TimeUnit
::
eTimeAutoUnit
,
0
,
1001
);
ASSERT_GT
(
span
,
0.0
);
span
=
TestTimeRecorder
(
TimeUnit
::
eTimeAutoUnit
,
0
,
101
);
ASSERT_GT
(
span
,
0.0
);
span
=
TestTimeRecorder
(
TimeUnit
::
eTimeHourUnit
,
1
);
span
=
TestTimeRecorder
(
TimeUnit
::
eTimeHourUnit
,
1
,
10
);
ASSERT_GT
(
span
,
0.0
);
span
=
TestTimeRecorder
(
TimeUnit
::
eTimeMinuteUnit
,
2
);
span
=
TestTimeRecorder
(
TimeUnit
::
eTimeMinuteUnit
,
2
,
10
);
ASSERT_GT
(
span
,
0.0
);
span
=
TestTimeRecorder
(
TimeUnit
::
eTimeSecondUnit
,
3
);
span
=
TestTimeRecorder
(
TimeUnit
::
eTimeSecondUnit
,
3
,
10
);
ASSERT_GT
(
span
,
0.0
);
span
=
TestTimeRecorder
(
TimeUnit
::
eTimeMilliSecUnit
,
4
);
span
=
TestTimeRecorder
(
TimeUnit
::
eTimeMilliSecUnit
,
4
,
10
);
ASSERT_GT
(
span
,
0.0
);
span
=
TestTimeRecorder
(
TimeUnit
::
eTimeMicroSecUnit
,
-
1
);
span
=
TestTimeRecorder
(
TimeUnit
::
eTimeMicroSecUnit
,
-
1
,
10
);
ASSERT_GT
(
span
,
0.0
);
}
...
...
@@ -98,5 +166,14 @@ TEST(UtilTest, BLOCKINGQUEUE_TEST) {
str
=
bq
.
Take
();
ASSERT_EQ
(
id
,
str
);
}
ASSERT_EQ
(
bq
.
Size
(),
0
);
}
TEST
(
UtilTest
,
LOG_TEST
)
{
int32_t
res
=
server
::
InitLog
(
LOG_FILE_PATH
);
ASSERT_EQ
(
res
,
0
);
std
::
string
fname
=
server
::
GetFileName
(
LOG_FILE_PATH
);
ASSERT_EQ
(
fname
,
"log_config.conf"
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录