utils.cpp 1.9 KB
Newer Older
X
Xu Peng 已提交
1 2 3 4 5 6 7 8
////////////////////////////////////////////////////////////////////////////////
// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited.
// Proprietary and confidential.
////////////////////////////////////////////////////////////////////////////////

#include <iostream>
#include <easylogging++.h>
X
Xu Peng 已提交
9 10
#include <thread>
#include <boost/filesystem.hpp>
X
Xu Peng 已提交
11 12

#include "utils.h"
X
Xu Peng 已提交
13
#include "db/Factories.h"
Z
update  
zhiru 已提交
14
#include "db/Options.h"
X
Xu Peng 已提交
15

J
jinhai 已提交
16
using namespace zilliz::milvus;
X
Xu Peng 已提交
17 18 19 20 21 22 23 24

void ASSERT_STATS(engine::Status& stat) {
    ASSERT_TRUE(stat.ok());
    if(!stat.ok()) {
        std::cout << stat.ToString() << std::endl;
    }
}

X
Xu Peng 已提交
25
void DBTest::InitLog() {
X
Xu Peng 已提交
26 27 28 29 30 31
    el::Configurations defaultConf;
    defaultConf.setToDefault();
    defaultConf.set(el::Level::Debug,
            el::ConfigurationType::Format, "[%thread-%datetime-%level]: %msg (%fbase:%line)");
    el::Loggers::reconfigureLogger("default", defaultConf);
}
X
Xu Peng 已提交
32

X
Xu Peng 已提交
33
engine::Options DBTest::GetOptions() {
X
Xu Peng 已提交
34
    auto options = engine::OptionsFactory::Build();
G
groot 已提交
35
    options.meta.path = "/tmp/milvus_test";
X
Xu Peng 已提交
36 37 38 39 40 41
    return options;
}

void DBTest::SetUp() {
    InitLog();
    auto options = GetOptions();
G
groot 已提交
42
    db_ = engine::DBFactory::Build(options);
X
Xu Peng 已提交
43 44 45 46
}

void DBTest::TearDown() {
    delete db_;
G
groot 已提交
47
    boost::filesystem::remove_all("/tmp/milvus_test");
X
Xu Peng 已提交
48 49
}

X
Xu Peng 已提交
50 51
engine::Options DBTest2::GetOptions() {
    auto options = engine::OptionsFactory::Build();
G
groot 已提交
52
    options.meta.path = "/tmp/milvus_test";
X
Xu Peng 已提交
53
    options.meta.archive_conf = engine::ArchiveConf("delete", "disk:1");
X
Xu Peng 已提交
54 55 56
    return options;
}

X
Xu Peng 已提交
57
void MetaTest::SetUp() {
X
Xu Peng 已提交
58
    InitLog();
X
Xu Peng 已提交
59 60 61 62
    impl_ = engine::DBMetaImplFactory::Build();
}

void MetaTest::TearDown() {
63
    impl_->DropAll();
X
Xu Peng 已提交
64
}
Z
update  
zhiru 已提交
65 66 67 68 69 70 71 72

zilliz::milvus::engine::DBMetaOptions MySQLTest::getDBMetaOptions() {
    engine::DBMetaOptions options;
    options.backend_uri = "mysql://root:1234@:/test";
    options.path = "/tmp/milvus_test";
    return options;

}