utils.cpp 1.7 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"
X
Xu Peng 已提交
14 15 16 17 18 19 20 21 22 23

using namespace zilliz::vecwise;

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

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

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

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

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

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

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

void MetaTest::TearDown() {
62
    impl_->DropAll();
X
Xu Peng 已提交
63
}