utils.cpp 2.3 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;
    }
}

Z
zhiru 已提交
25

X
Xu Peng 已提交
26
void DBTest::InitLog() {
X
Xu Peng 已提交
27 28 29 30 31 32
    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 已提交
33

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

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

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

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

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

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

zilliz::milvus::engine::DBMetaOptions MySQLTest::getDBMetaOptions() {
Z
zhiru 已提交
68 69 70
//    std::string path = "/tmp/milvus_test";
//    engine::DBMetaOptions options = engine::DBMetaOptionsFactory::Build(path);
    zilliz::milvus::engine::DBMetaOptions options;
Z
update  
zhiru 已提交
71
    options.path = "/tmp/milvus_test";
Z
zhiru 已提交
72
    options.backend_uri = "mysql://root:1234@:/test";
Z
update  
zhiru 已提交
73 74 75
    return options;

}
Z
zhiru 已提交
76 77 78 79 80 81 82

zilliz::milvus::engine::Options MySQLDBTest::GetOptions() {
    auto options = engine::OptionsFactory::Build();
    options.meta.path = "/tmp/milvus_test";
    options.meta.backend_uri = "mysql://root:1234@:/test";
    return options;
}