fix build error

Former-commit-id: da010fb2e477164a9dcc190839bcd7f9d0980b02
This commit is contained in:
starlord 2019-06-30 16:19:04 +08:00 committed by jinhai
parent 8ffb89d2d7
commit 57cff92d04
8 changed files with 161 additions and 12 deletions

View File

@ -6,7 +6,7 @@ server_config:
db_config:
db_path: @MILVUS_DB_PATH@ # milvus data storage path
db_backend_url: http://127.0.0.1 # meta database uri
db_backend_url: sqlite://:@:/ # 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

View File

@ -70,9 +70,15 @@ DBWrapper::DBWrapper() {
kill(0, SIGUSR1);
}
zilliz::milvus::engine::DB::Open(opt, &db_);
std::string msg = opt.meta.path;
try {
zilliz::milvus::engine::DB::Open(opt, &db_);
} catch(std::exception& ex) {
msg = ex.what();
}
if(db_ == nullptr) {
std::cout << "ERROR! Failed to open database" << std::endl;
std::cout << "ERROR! Failed to open database: " << msg << std::endl;
kill(0, SIGUSR1);
}
}

View File

@ -17,6 +17,7 @@ aux_source_directory(../../src/config config_files)
aux_source_directory(../../src/cache cache_srcs)
aux_source_directory(../../src/wrapper wrapper_src)
aux_source_directory(../../src/metrics metrics_src)
aux_source_directory(./ test_srcs)
aux_source_directory(${MILVUS_ENGINE_SRC}/db/scheduler scheduler_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/db/scheduler/context scheduler_context_files)
@ -35,6 +36,7 @@ link_directories("/usr/local/cuda/lib64")
#include_directories(../db/utils.h)
include_directories(../../src/metrics)
include_directories(/usr/include/mysql)
#set(metrics_src_files
# ../../src/metrics/Metrics.cpp
@ -47,17 +49,14 @@ include_directories(../../src/metrics)
# )
set(count_test_src
${unittest_srcs}
${config_files}
${cache_srcs}
${db_srcs}
${db_scheduler_srcs}
${wrapper_src}
${metrics_src}
metrics_test.cpp
prometheus_test.cpp
../db/utils.cpp
metricbase_test.cpp)
${test_srcs}
)
add_executable(metrics_test ${count_test_src} ${require_files} )
@ -75,6 +74,7 @@ target_link_libraries(metrics_test
gtest
pthread
z
mysqlpp
${unittest_libs}
)

View File

@ -11,7 +11,7 @@
using namespace zilliz::milvus;
TEST(MetricbaseTest, Metricbase_Test){
TEST(MetricbaseTest, METRICBASE_TEST){
server::MetricsBase instance = server::MetricsBase::GetInstance();
instance.Init();
server::SystemInfo::GetInstance().Init();

View File

@ -15,7 +15,7 @@
#include <cache/CpuCacheMgr.h>
#include "metrics/Metrics.h"
#include "../db/utils.h"
#include "utils.h"
#include "db/DB.h"
#include "db/DBMetaImpl.h"
#include "db/Factories.h"
@ -24,7 +24,7 @@
using namespace zilliz::milvus;
TEST_F(DBTest, Metric_Tes) {
TEST_F(MetricTest, Metric_Tes) {
server::SystemInfo::GetInstance().Init();
// server::Metrics::GetInstance().Init();

View File

@ -11,7 +11,7 @@
using namespace zilliz::milvus;
TEST(PrometheusTest, Prometheus_Test){
TEST(PrometheusTest, PROMETHEUS_TEST){
server::PrometheusMetrics instance = server::PrometheusMetrics::GetInstance();
instance.Init();
instance.SetStartup(true);

View File

@ -0,0 +1,79 @@
////////////////////////////////////////////////////////////////////////////////
// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited.
// Proprietary and confidential.
////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <easylogging++.h>
#include <thread>
#include <boost/filesystem.hpp>
#include "utils.h"
#include "db/Factories.h"
#include "db/Options.h"
INITIALIZE_EASYLOGGINGPP
using namespace zilliz::milvus;
static std::string uri;
class DBTestEnvironment : public ::testing::Environment {
public:
// explicit DBTestEnvironment(std::string uri) : uri_(uri) {}
static std::string getURI() {
return uri;
}
void SetUp() override {
getURI();
}
};
void ASSERT_STATS(engine::Status& stat) {
ASSERT_TRUE(stat.ok());
if(!stat.ok()) {
std::cout << stat.ToString() << std::endl;
}
}
void MetricTest::InitLog() {
el::Configurations defaultConf;
defaultConf.setToDefault();
defaultConf.set(el::Level::Debug,
el::ConfigurationType::Format, "[%thread-%datetime-%level]: %msg (%fbase:%line)");
el::Loggers::reconfigureLogger("default", defaultConf);
}
engine::Options MetricTest::GetOptions() {
auto options = engine::OptionsFactory::Build();
options.meta.path = "/tmp/milvus_test";
options.meta.backend_uri = "sqlite://:@:/";
return options;
}
void MetricTest::SetUp() {
InitLog();
auto options = GetOptions();
db_ = engine::DBFactory::Build(options);
}
void MetricTest::TearDown() {
delete db_;
boost::filesystem::remove_all("/tmp/milvus_test");
}
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
if (argc > 1) {
uri = argv[1];
}
// std::cout << uri << std::endl;
::testing::AddGlobalTestEnvironment(new DBTestEnvironment);
return RUN_ALL_TESTS();
}

View File

@ -0,0 +1,64 @@
////////////////////////////////////////////////////////////////////////////////
// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited.
// Proprietary and confidential.
////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <gtest/gtest.h>
#include <chrono>
//#include <src/db/MySQLMetaImpl.h>
#include "db/DB.h"
#include "db/DBMetaImpl.h"
#include "db/MySQLMetaImpl.h"
#define TIMING
#ifdef TIMING
#define INIT_TIMER auto start = std::chrono::high_resolution_clock::now();
#define START_TIMER start = std::chrono::high_resolution_clock::now();
#define STOP_TIMER(name) LOG(DEBUG) << "RUNTIME of " << name << ": " << \
std::chrono::duration_cast<std::chrono::milliseconds>( \
std::chrono::high_resolution_clock::now()-start \
).count() << " ms ";
#else
#define INIT_TIMER
#define START_TIMER
#define STOP_TIMER(name)
#endif
void ASSERT_STATS(zilliz::milvus::engine::Status& stat);
//class TestEnv : public ::testing::Environment {
//public:
//
// static std::string getURI() {
// if (const char* uri = std::getenv("MILVUS_DBMETA_URI")) {
// return uri;
// }
// else {
// return "";
// }
// }
//
// void SetUp() override {
// getURI();
// }
//
//};
//
//::testing::Environment* const test_env =
// ::testing::AddGlobalTestEnvironment(new TestEnv);
class MetricTest : public ::testing::Test {
protected:
zilliz::milvus::engine::DB* db_;
void InitLog();
virtual void SetUp() override;
virtual void TearDown() override;
virtual zilliz::milvus::engine::Options GetOptions();
};