add more unitest cases

Former-commit-id: 6367f0601b449098514ac4770eb72daa81d91607
This commit is contained in:
starlord 2019-07-15 10:29:28 +08:00
parent 2428ff1160
commit 2dffb947a9
2 changed files with 43 additions and 4 deletions

View File

@ -204,11 +204,21 @@ TEST_F(DBTest, SEARCH_TEST) {
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);
ASSERT_STATS(stat);
{
engine::QueryResults results;
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
};

View File

@ -14,6 +14,7 @@
#include "db/Options.h"
#include "db/DBMetaImpl.h"
#include "db/EngineFactory.h"
#include "db/Utils.h"
#include <vector>
@ -134,4 +135,32 @@ TEST(DBMiscTest, META_TEST) {
int delta = 10;
engine::meta::DateT dt = impl.GetDate(tt, delta);
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());
}