utils.h 2.4 KB
Newer Older
X
Xu Peng 已提交
1 2 3 4 5 6 7 8 9 10
////////////////////////////////////////////////////////////////////////////////
// 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>
Z
update  
zhiru 已提交
11
//#include <src/db/MySQLMetaImpl.h>
X
Xu Peng 已提交
12 13

#include "db/DB.h"
X
Xu Peng 已提交
14
#include "db/DBMetaImpl.h"
Z
update  
zhiru 已提交
15
#include "db/MySQLMetaImpl.h"
X
Xu Peng 已提交
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32


#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

Z
update  
zhiru 已提交
33
void ASSERT_STATS(zilliz::milvus::engine::Status &stat);
X
Xu Peng 已提交
34

Z
zhiru 已提交
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
//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);
X
Xu Peng 已提交
55 56

class DBTest : public ::testing::Test {
Z
update  
zhiru 已提交
57 58
 protected:
    zilliz::milvus::engine::DB *db_;
X
Xu Peng 已提交
59

X
Xu Peng 已提交
60
    void InitLog();
X
Xu Peng 已提交
61
    virtual void SetUp() override;
X
Xu Peng 已提交
62
    virtual void TearDown() override;
J
jinhai 已提交
63
    virtual zilliz::milvus::engine::Options GetOptions();
X
Xu Peng 已提交
64 65 66
};

class DBTest2 : public DBTest {
Z
update  
zhiru 已提交
67
 protected:
J
jinhai 已提交
68
    virtual zilliz::milvus::engine::Options GetOptions() override;
X
Xu Peng 已提交
69
};
X
Xu Peng 已提交
70 71 72


class MetaTest : public DBTest {
Z
update  
zhiru 已提交
73
 protected:
J
jinhai 已提交
74
    std::shared_ptr<zilliz::milvus::engine::meta::DBMetaImpl> impl_;
X
Xu Peng 已提交
75 76 77 78

    virtual void SetUp() override;
    virtual void TearDown() override;
};
Z
update  
zhiru 已提交
79

80
class MySQLTest : public ::testing::Test {
Z
update  
zhiru 已提交
81
 protected:
82
//    std::shared_ptr<zilliz::milvus::engine::meta::MySQLMetaImpl> impl_;
Z
update  
zhiru 已提交
83 84 85
    zilliz::milvus::engine::DBMetaOptions getDBMetaOptions();
};

Z
update  
zhiru 已提交
86 87
class MySQLDBTest : public ::testing::Test {
 protected:
Z
zhiru 已提交
88
    zilliz::milvus::engine::Options GetOptions();
Z
update  
zhiru 已提交
89
};
Z
zhiru 已提交
90

Z
update  
zhiru 已提交
91
class NewMemManagerTest : public ::testing::Test {
Z
zhiru 已提交
92
    void InitLog();
Z
update  
zhiru 已提交
93
    void SetUp() override;
Z
zhiru 已提交
94
};