Merge branch 'branch-0.3.1-yuncong' into 'branch-0.3.1-yuncong'

Fix unittest error

See merge request megasearch/milvus!207

Former-commit-id: 906107d2a559105a46a2e257af431be85c8287c8
This commit is contained in:
peng.xu 2019-07-15 10:30:06 +08:00
commit 520d4e9d71
2 changed files with 45 additions and 8 deletions

View File

@ -52,15 +52,13 @@ TEST_F(DBTest, CONFIG_TEST) {
engine::ArchiveConf conf("delete"); engine::ArchiveConf conf("delete");
ASSERT_EQ(conf.GetType(), "delete"); ASSERT_EQ(conf.GetType(), "delete");
auto criterias = conf.GetCriterias(); auto criterias = conf.GetCriterias();
ASSERT_TRUE(criterias.size() == 1); ASSERT_TRUE(criterias.size() == 0);
ASSERT_TRUE(criterias["disk"] == 512);
} }
{ {
engine::ArchiveConf conf("swap"); engine::ArchiveConf conf("swap");
ASSERT_EQ(conf.GetType(), "swap"); ASSERT_EQ(conf.GetType(), "swap");
auto criterias = conf.GetCriterias(); auto criterias = conf.GetCriterias();
ASSERT_TRUE(criterias.size() == 1); ASSERT_TRUE(criterias.size() == 0);
ASSERT_TRUE(criterias["disk"] == 512);
} }
{ {
ASSERT_ANY_THROW(engine::ArchiveConf conf1("swap", "disk:")); ASSERT_ANY_THROW(engine::ArchiveConf conf1("swap", "disk:"));
@ -206,11 +204,21 @@ TEST_F(DBTest, SEARCH_TEST) {
ASSERT_STATS(stat); ASSERT_STATS(stat);
} }
sleep(2); // wait until build index finish db_->BuildIndex(TABLE_NAME); // wait until build index finish
engine::QueryResults results; {
stat = db_->Query(TABLE_NAME, k, nq, xq.data(), results); engine::QueryResults results;
ASSERT_STATS(stat); stat = db_->Query(TABLE_NAME, k, nq, xq.data(), results);
ASSERT_STATS(stat);
}
{//search by specify index file
engine::meta::DatesT dates;
std::vector<std::string> file_ids = {"1", "2", "3", "4"};
engine::QueryResults results;
stat = db_->Query(TABLE_NAME, file_ids, k, nq, xq.data(), dates, results);
ASSERT_STATS(stat);
}
// TODO(linxj): add groundTruth assert // TODO(linxj): add groundTruth assert
}; };

View File

@ -14,6 +14,7 @@
#include "db/Options.h" #include "db/Options.h"
#include "db/DBMetaImpl.h" #include "db/DBMetaImpl.h"
#include "db/EngineFactory.h" #include "db/EngineFactory.h"
#include "db/Utils.h"
#include <vector> #include <vector>
@ -134,4 +135,32 @@ TEST(DBMiscTest, META_TEST) {
int delta = 10; int delta = 10;
engine::meta::DateT dt = impl.GetDate(tt, delta); engine::meta::DateT dt = impl.GetDate(tt, delta);
ASSERT_GT(dt, 0); ASSERT_GT(dt, 0);
}
TEST(DBMiscTest, UTILS_TEST) {
engine::DBMetaOptions options;
options.path = "/tmp/milvus_test/main";
options.slave_paths.push_back("/tmp/milvus_test/slave_1");
options.slave_paths.push_back("/tmp/milvus_test/slave_2");
const std::string TABLE_NAME = "test_tbl";
auto status = engine::utils::CreateTablePath(options, TABLE_NAME);
ASSERT_TRUE(status.ok());
ASSERT_TRUE(boost::filesystem::exists(options.path));
for(auto& path : options.slave_paths) {
ASSERT_TRUE(boost::filesystem::exists(path));
}
engine::meta::TableFileSchema file;
file.id_ = 50;
file.table_id_ = TABLE_NAME;
file.file_type_ = 3;
file.date_ = 155000;
status = engine::utils::GetTableFilePath(options, file);
ASSERT_FALSE(status.ok());
ASSERT_TRUE(file.location_.empty());
status = engine::utils::DeleteTablePath(options, TABLE_NAME);
ASSERT_TRUE(status.ok());
} }