提交 5849a4f8 编写于 作者: G groot 提交者: jinhai

fix build error


Former-commit-id: 0d9ee6e9f2cc875efdf8cfab6aec07723d238c57
上级 dc3aefc7
...@@ -6,7 +6,7 @@ server_config: ...@@ -6,7 +6,7 @@ server_config:
db_config: db_config:
db_path: @MILVUS_DB_PATH@ # milvus data storage path 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 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_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 archive_days_threshold: 30 # files older than x days will be archived, unit: day
......
...@@ -70,9 +70,15 @@ DBWrapper::DBWrapper() { ...@@ -70,9 +70,15 @@ DBWrapper::DBWrapper() {
kill(0, SIGUSR1); 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) { 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); kill(0, SIGUSR1);
} }
} }
......
...@@ -17,6 +17,7 @@ aux_source_directory(../../src/config config_files) ...@@ -17,6 +17,7 @@ aux_source_directory(../../src/config config_files)
aux_source_directory(../../src/cache cache_srcs) aux_source_directory(../../src/cache cache_srcs)
aux_source_directory(../../src/wrapper wrapper_src) aux_source_directory(../../src/wrapper wrapper_src)
aux_source_directory(../../src/metrics metrics_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 scheduler_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/db/scheduler/context scheduler_context_files) aux_source_directory(${MILVUS_ENGINE_SRC}/db/scheduler/context scheduler_context_files)
...@@ -35,6 +36,7 @@ link_directories("/usr/local/cuda/lib64") ...@@ -35,6 +36,7 @@ link_directories("/usr/local/cuda/lib64")
#include_directories(../db/utils.h) #include_directories(../db/utils.h)
include_directories(../../src/metrics) include_directories(../../src/metrics)
include_directories(/usr/include/mysql)
#set(metrics_src_files #set(metrics_src_files
# ../../src/metrics/Metrics.cpp # ../../src/metrics/Metrics.cpp
...@@ -47,17 +49,14 @@ include_directories(../../src/metrics) ...@@ -47,17 +49,14 @@ include_directories(../../src/metrics)
# ) # )
set(count_test_src set(count_test_src
${unittest_srcs}
${config_files} ${config_files}
${cache_srcs} ${cache_srcs}
${db_srcs} ${db_srcs}
${db_scheduler_srcs} ${db_scheduler_srcs}
${wrapper_src} ${wrapper_src}
${metrics_src} ${metrics_src}
metrics_test.cpp ${test_srcs}
prometheus_test.cpp )
../db/utils.cpp
metricbase_test.cpp)
add_executable(metrics_test ${count_test_src} ${require_files} ) add_executable(metrics_test ${count_test_src} ${require_files} )
...@@ -75,6 +74,7 @@ target_link_libraries(metrics_test ...@@ -75,6 +74,7 @@ target_link_libraries(metrics_test
gtest gtest
pthread pthread
z z
mysqlpp
${unittest_libs} ${unittest_libs}
) )
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
using namespace zilliz::milvus; using namespace zilliz::milvus;
TEST(MetricbaseTest, Metricbase_Test){ TEST(MetricbaseTest, METRICBASE_TEST){
server::MetricsBase instance = server::MetricsBase::GetInstance(); server::MetricsBase instance = server::MetricsBase::GetInstance();
instance.Init(); instance.Init();
server::SystemInfo::GetInstance().Init(); server::SystemInfo::GetInstance().Init();
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <cache/CpuCacheMgr.h> #include <cache/CpuCacheMgr.h>
#include "metrics/Metrics.h" #include "metrics/Metrics.h"
#include "../db/utils.h" #include "utils.h"
#include "db/DB.h" #include "db/DB.h"
#include "db/DBMetaImpl.h" #include "db/DBMetaImpl.h"
#include "db/Factories.h" #include "db/Factories.h"
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
using namespace zilliz::milvus; using namespace zilliz::milvus;
TEST_F(DBTest, Metric_Tes) { TEST_F(MetricTest, Metric_Tes) {
server::SystemInfo::GetInstance().Init(); server::SystemInfo::GetInstance().Init();
// server::Metrics::GetInstance().Init(); // server::Metrics::GetInstance().Init();
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
using namespace zilliz::milvus; using namespace zilliz::milvus;
TEST(PrometheusTest, Prometheus_Test){ TEST(PrometheusTest, PROMETHEUS_TEST){
server::PrometheusMetrics instance = server::PrometheusMetrics::GetInstance(); server::PrometheusMetrics instance = server::PrometheusMetrics::GetInstance();
instance.Init(); instance.Init();
instance.SetStartup(true); instance.SetStartup(true);
......
////////////////////////////////////////////////////////////////////////////////
// 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();
}
////////////////////////////////////////////////////////////////////////////////
// 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();
};
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册