mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-08 01:58:34 +08:00
70 lines
1.8 KiB
C++
70 lines
1.8 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
|
|
// Unauthorized copying of this file, via any medium is strictly prohibited.
|
|
// Proprietary and confidential.
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include <iostream>
|
|
#include <thread>
|
|
#include <boost/filesystem.hpp>
|
|
|
|
#include "utils.h"
|
|
#include "db/DBFactory.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 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::DBFactory::BuildOption();
|
|
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() {
|
|
db_->Stop();
|
|
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();
|
|
}
|