2019-09-17 02:51:48 +00:00
|
|
|
// Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
// or more contributor license agreements. See the NOTICE file
|
|
|
|
// distributed with this work for additional information
|
|
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
|
|
// to you under the Apache License, Version 2.0 (the
|
|
|
|
// "License"); you may not use this file except in compliance
|
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing,
|
|
|
|
// software distributed under the License is distributed on an
|
|
|
|
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
// KIND, either express or implied. See the License for the
|
|
|
|
// specific language governing permissions and limitations
|
|
|
|
// under the License.
|
|
|
|
|
2019-04-29 05:17:13 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <chrono>
|
2019-09-27 10:57:46 +00:00
|
|
|
#include <memory>
|
2020-02-11 15:03:29 +00:00
|
|
|
#include <fiu-control.h>
|
|
|
|
#include <fiu-local.h>
|
2019-04-29 05:17:13 +00:00
|
|
|
|
|
|
|
#include "db/DB.h"
|
2019-08-08 07:36:00 +00:00
|
|
|
#include "db/meta/MySQLMetaImpl.h"
|
2019-11-05 05:35:24 +00:00
|
|
|
#include "db/meta/SqliteMetaImpl.h"
|
2019-08-23 13:07:01 +00:00
|
|
|
#include "scheduler/ResourceFactory.h"
|
2019-11-05 05:35:24 +00:00
|
|
|
#include "scheduler/SchedInst.h"
|
2019-04-29 05:17:13 +00:00
|
|
|
|
|
|
|
#define TIMING
|
|
|
|
|
|
|
|
#ifdef TIMING
|
|
|
|
#define INIT_TIMER auto start = std::chrono::high_resolution_clock::now();
|
2019-11-05 05:35:24 +00:00
|
|
|
#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 ";
|
2019-04-29 05:17:13 +00:00
|
|
|
#else
|
|
|
|
#define INIT_TIMER
|
|
|
|
#define START_TIMER
|
|
|
|
#define STOP_TIMER(name)
|
|
|
|
#endif
|
|
|
|
|
2020-02-11 15:03:29 +00:00
|
|
|
#ifdef FIU_ENABLE
|
|
|
|
#define FIU_ENABLE_FIU(name) fiu_enable(name, 1, nullptr, 0)
|
|
|
|
#endif
|
|
|
|
|
2019-11-05 05:35:24 +00:00
|
|
|
static const char* CONFIG_PATH = "/tmp/milvus_test";
|
|
|
|
static const char* CONFIG_FILE = "/server_config.yaml";
|
2019-10-23 07:05:22 +00:00
|
|
|
|
2019-09-05 02:32:07 +00:00
|
|
|
class BaseTest : public ::testing::Test {
|
2019-09-27 10:57:46 +00:00
|
|
|
protected:
|
2019-11-05 05:35:24 +00:00
|
|
|
void
|
|
|
|
InitLog();
|
|
|
|
|
|
|
|
void
|
|
|
|
SetUp() override;
|
|
|
|
void
|
|
|
|
TearDown() override;
|
|
|
|
virtual milvus::engine::DBOptions
|
|
|
|
GetOptions();
|
2019-12-10 07:24:54 +00:00
|
|
|
|
|
|
|
std::shared_ptr<milvus::server::Context> dummy_context_;
|
2019-09-05 02:32:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class DBTest : public BaseTest {
|
2019-07-08 07:07:03 +00:00
|
|
|
protected:
|
2019-09-29 08:37:34 +00:00
|
|
|
milvus::engine::DBPtr db_;
|
2019-04-29 12:22:24 +00:00
|
|
|
|
2019-11-05 05:35:24 +00:00
|
|
|
void
|
|
|
|
SetUp() override;
|
|
|
|
void
|
|
|
|
TearDown() override;
|
2019-05-24 10:16:27 +00:00
|
|
|
};
|
|
|
|
|
2019-09-05 02:32:07 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2019-05-24 10:16:27 +00:00
|
|
|
class DBTest2 : public DBTest {
|
2019-07-08 07:07:03 +00:00
|
|
|
protected:
|
2019-11-05 05:35:24 +00:00
|
|
|
milvus::engine::DBOptions
|
|
|
|
GetOptions() override;
|
2019-04-29 05:17:13 +00:00
|
|
|
};
|
2019-04-29 07:47:09 +00:00
|
|
|
|
2019-09-10 08:16:50 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2019-11-05 05:35:24 +00:00
|
|
|
class EngineTest : public DBTest {};
|
2019-09-10 08:16:50 +00:00
|
|
|
|
2019-09-05 02:32:07 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class MetaTest : public BaseTest {
|
2019-07-08 07:07:03 +00:00
|
|
|
protected:
|
2019-09-29 08:37:34 +00:00
|
|
|
std::shared_ptr<milvus::engine::meta::SqliteMetaImpl> impl_;
|
2019-04-29 07:47:09 +00:00
|
|
|
|
2019-11-05 05:35:24 +00:00
|
|
|
void
|
|
|
|
SetUp() override;
|
|
|
|
void
|
|
|
|
TearDown() override;
|
2019-04-29 07:47:09 +00:00
|
|
|
};
|
2019-06-14 11:02:06 +00:00
|
|
|
|
2019-09-05 02:32:07 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class MySqlDBTest : public DBTest {
|
2019-09-27 10:57:46 +00:00
|
|
|
protected:
|
2019-11-05 05:35:24 +00:00
|
|
|
milvus::engine::DBOptions
|
|
|
|
GetOptions() override;
|
2019-06-20 08:14:58 +00:00
|
|
|
};
|
|
|
|
|
2019-09-05 02:32:07 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class MySqlMetaTest : public BaseTest {
|
2019-07-08 07:07:03 +00:00
|
|
|
protected:
|
2019-09-29 08:37:34 +00:00
|
|
|
std::shared_ptr<milvus::engine::meta::MySQLMetaImpl> impl_;
|
2019-09-05 02:32:07 +00:00
|
|
|
|
2019-11-05 05:35:24 +00:00
|
|
|
void
|
|
|
|
SetUp() override;
|
|
|
|
void
|
|
|
|
TearDown() override;
|
|
|
|
milvus::engine::DBOptions
|
|
|
|
GetOptions() override;
|
2019-06-14 11:02:06 +00:00
|
|
|
};
|
2019-07-08 03:14:28 +00:00
|
|
|
|
2019-09-05 02:32:07 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2019-11-05 05:35:24 +00:00
|
|
|
class MemManagerTest : public MetaTest {};
|
2019-09-05 12:33:38 +00:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2019-11-05 05:35:24 +00:00
|
|
|
class MemManagerTest2 : public DBTest {};
|