From 4cd5d8dd1b4102b8fc5b0f2dd0cf20430353b26b Mon Sep 17 00:00:00 2001 From: BossZou <40255591+BossZou@users.noreply.github.com> Date: Sat, 28 Mar 2020 14:41:24 +0800 Subject: [PATCH] Add Superstructure/Substructure in http module (#1785) * add sub/super-structure in http module Signed-off-by: Yhz * update http test case Signed-off-by: Yhz * add Superstructure/Substructure in http module (fix #1784) Signed-off-by: Yhz --- CHANGELOG.md | 1 + core/src/server/web_impl/Constants.h | 2 + core/src/server/web_impl/Types.h | 4 + .../web_impl/handler/WebRequestHandler.cpp | 3 +- core/unittest/server/test_web.cpp | 361 +++++++++--------- 5 files changed, 199 insertions(+), 172 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 973165af1f..3a4b23d89a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ Please mark all change in change log and use the issue from GitHub - \#1698 Upgrade mishards to v0.7.0 - \#1719 Improve Milvus log - \#1754 Optimize behavior to get file ids from metadata in mishards +- \#1784 Add Substructure and Superstructure in http module ## Task diff --git a/core/src/server/web_impl/Constants.h b/core/src/server/web_impl/Constants.h index 331e95ef37..83e49b661e 100644 --- a/core/src/server/web_impl/Constants.h +++ b/core/src/server/web_impl/Constants.h @@ -46,6 +46,8 @@ static const char* NAME_METRIC_TYPE_IP = "IP"; static const char* NAME_METRIC_TYPE_HAMMING = "HAMMING"; static const char* NAME_METRIC_TYPE_JACCARD = "JACCARD"; static const char* NAME_METRIC_TYPE_TANIMOTO = "TANIMOTO"; +static const char* NAME_METRIC_TYPE_SUBSTRUCTURE = "SUBSTRUCTURE"; +static const char* NAME_METRIC_TYPE_SUPERSTRUCTURE = "SUPERSTRUCTURE"; //////////////////////////////////////////////////// diff --git a/core/src/server/web_impl/Types.h b/core/src/server/web_impl/Types.h index 0088dd0921..0c01f3fa3d 100644 --- a/core/src/server/web_impl/Types.h +++ b/core/src/server/web_impl/Types.h @@ -99,6 +99,8 @@ static const std::unordered_map MetricMap = { {engine::MetricType::HAMMING, NAME_METRIC_TYPE_HAMMING}, {engine::MetricType::JACCARD, NAME_METRIC_TYPE_JACCARD}, {engine::MetricType::TANIMOTO, NAME_METRIC_TYPE_TANIMOTO}, + {engine::MetricType::SUBSTRUCTURE, NAME_METRIC_TYPE_SUBSTRUCTURE}, + {engine::MetricType::SUPERSTRUCTURE, NAME_METRIC_TYPE_SUPERSTRUCTURE}, }; static const std::unordered_map MetricNameMap = { @@ -107,6 +109,8 @@ static const std::unordered_map MetricNameMap = {NAME_METRIC_TYPE_HAMMING, engine::MetricType::HAMMING}, {NAME_METRIC_TYPE_JACCARD, engine::MetricType::JACCARD}, {NAME_METRIC_TYPE_TANIMOTO, engine::MetricType::TANIMOTO}, + {NAME_METRIC_TYPE_SUBSTRUCTURE, engine::MetricType::SUBSTRUCTURE}, + {NAME_METRIC_TYPE_SUPERSTRUCTURE, engine::MetricType::SUPERSTRUCTURE}, }; } // namespace web diff --git a/core/src/server/web_impl/handler/WebRequestHandler.cpp b/core/src/server/web_impl/handler/WebRequestHandler.cpp index cecb193849..7df1e080a8 100644 --- a/core/src/server/web_impl/handler/WebRequestHandler.cpp +++ b/core/src/server/web_impl/handler/WebRequestHandler.cpp @@ -168,7 +168,8 @@ WebRequestHandler::IsBinaryTable(const std::string& collection_name, bool& bin) if (status.ok()) { auto metric = engine::MetricType(schema.metric_type_); bin = engine::MetricType::HAMMING == metric || engine::MetricType::JACCARD == metric || - engine::MetricType::TANIMOTO == metric; + engine::MetricType::TANIMOTO == metric || engine::MetricType::SUPERSTRUCTURE == metric || + engine::MetricType::SUBSTRUCTURE == metric; } return status; diff --git a/core/unittest/server/test_web.cpp b/core/unittest/server/test_web.cpp index 3a87d641c3..634d230109 100644 --- a/core/unittest/server/test_web.cpp +++ b/core/unittest/server/test_web.cpp @@ -41,7 +41,6 @@ #include "unittest/server/utils.h" #include "utils/CommonUtil.h" #include "version.h" -//#include "knowhere/VecIndex.h" static const char* TABLE_NAME = "test_web"; @@ -58,7 +57,7 @@ using OChunkedBuffer = oatpp::data::stream::ChunkedBuffer; using OOutputStream = oatpp::data::stream::BufferOutputStream; using OFloat32 = milvus::server::web::OFloat32; using OInt64 = milvus::server::web::OInt64; -template +template using OList = milvus::server::web::OList; using StatusCode = milvus::server::web::StatusCode; @@ -572,7 +571,7 @@ static const char* CONTROLLER_TEST_VALID_CONFIG_STR = "-+\n" "engine_config:\n" " use_blas_threshold: 1100\n" -#ifdef MILVUS_GPU_VERSION + #ifdef MILVUS_GPU_VERSION " gpu_search_threshold: 1000\n" "\n" "#----------------------+------------------------------------------------------------+------------+----------------" @@ -588,7 +587,7 @@ static const char* CONTROLLER_TEST_VALID_CONFIG_STR = " - gpu0\n" " build_index_resources:\n" " - gpu0\n" -#endif + #endif "\n" "#----------------------+------------------------------------------------------------+------------+----------------" "-+\n" @@ -599,6 +598,7 @@ static const char* CONTROLLER_TEST_VALID_CONFIG_STR = "tracing_config:\n" " json_config_path:\n" ""; +} // namespace static const char* CONTROLLER_TEST_TABLE_NAME = "controller_unit_test"; static const char* CONTROLLER_TEST_CONFIG_DIR = "/tmp/milvus_web_controller_test/"; @@ -607,7 +607,7 @@ static const char* CONTROLLER_TEST_CONFIG_FILE = "config.yaml"; class TestClient : public oatpp::web::client::ApiClient { public: #include OATPP_CODEGEN_BEGIN(ApiClient) - API_CLIENT_INIT(TestClient) + API_CLIENT_INIT(TestClient) API_CALL("GET", "/", root) @@ -623,12 +623,14 @@ class TestClient : public oatpp::web::client::ApiClient { BODY_DTO(milvus::server::web::AdvancedConfigDto::ObjectWrapper, body)) #ifdef MILVUS_GPU_VERSION + API_CALL("OPTIONS", "config/gpu_resources", optionsGpuConfig) API_CALL("GET", "/config/gpu_resources", getGPUConfig) API_CALL("PUT", "/config/gpu_resources", setGPUConfig, BODY_DTO(milvus::server::web::GPUConfigDto::ObjectWrapper, body)) + #endif API_CALL("OPTIONS", "/collections", optionsTables) @@ -665,7 +667,7 @@ class TestClient : public oatpp::web::client::ApiClient { BODY_DTO(milvus::server::web::PartitionRequestDto::ObjectWrapper, body)) API_CALL("GET", "/collections/{collection_name}/partitions", showPartitions, - PATH(String, collection_name, "collection_name"), + PATH(String, collection_name, "collection_name"), QUERY(String, offset), QUERY(String, page_size)) API_CALL("DELETE", "/collections/{collection_name}/partitions", dropPartition, @@ -698,8 +700,11 @@ class TestClient : public oatpp::web::client::ApiClient { #include OATPP_CODEGEN_END(ApiClient) }; -class WebControllerTest : public testing::Test { - protected: +using TestClientP = std::shared_ptr; +using TestConnP = std::shared_ptr; + +class WebControllerTest : public ::testing::Test { + public: static void SetUpTestCase() { mkdir(CONTROLLER_TEST_CONFIG_DIR, S_IRWXU); @@ -739,7 +744,7 @@ class WebControllerTest : public testing::Test { milvus::server::web::WebServer::GetInstance().Start(); - sleep(5); + sleep(3); } static void @@ -753,103 +758,6 @@ class WebControllerTest : public testing::Test { boost::filesystem::remove_all(CONTROLLER_TEST_CONFIG_DIR); } - void - GenTable(const OString& collection_name, int64_t dim, int64_t index_size, const OString& metric) { - auto response = client_ptr->getTable(collection_name, "", conncetion_ptr); - if (OStatus::CODE_200.code == response->getStatusCode()) { - return; - } - auto collection_dto = milvus::server::web::TableRequestDto::createShared(); - collection_dto->collection_name = collection_name; - collection_dto->dimension = dim; - collection_dto->index_file_size = index_size; - collection_dto->metric_type = metric; - client_ptr->createTable(collection_dto, conncetion_ptr); - } - - milvus::Status - FlushTable(const std::string& collection_name) { - nlohmann::json flush_json; - flush_json["flush"]["collection_names"] = {collection_name}; - auto response = client_ptr->op("task", flush_json.dump().c_str(), conncetion_ptr); - if (OStatus::CODE_200.code != response->getStatusCode()) { - return milvus::Status(milvus::SERVER_UNEXPECTED_ERROR, response->readBodyToString()->std_str()); - } - - return milvus::Status::OK(); - } - - milvus::Status - FlushTable(const OString& collection_name) { - nlohmann::json flush_json; - flush_json["flush"]["collection_names"] = {collection_name->std_str()}; - auto response = client_ptr->op("task", flush_json.dump().c_str(), conncetion_ptr); - if (OStatus::CODE_200.code != response->getStatusCode()) { - return milvus::Status(milvus::SERVER_UNEXPECTED_ERROR, response->readBodyToString()->std_str()); - } - - return milvus::Status::OK(); - } - - milvus::Status - InsertData(const OString& collection_name, int64_t dim, int64_t count, std::string tag = "", bool bin = false) { - nlohmann::json insert_json; - - if (bin) - insert_json["vectors"] = RandomBinRecordsJson(dim, count); - else - insert_json["vectors"] = RandomRecordsJson(dim, count); - - if (!tag.empty()) { - insert_json["partition_tag"] = tag; - } - - auto response = client_ptr->insert(collection_name, insert_json.dump().c_str(), conncetion_ptr); - if (OStatus::CODE_201.code != response->getStatusCode()) { - return milvus::Status(milvus::SERVER_UNEXPECTED_ERROR, response->readBodyToString()->c_str()); - } - - return FlushTable(collection_name); - } - - milvus::Status - InsertData(const OString& collection_name, int64_t dim, int64_t count, - const std::vector& ids, std::string tag = "", bool bin = false) { - nlohmann::json insert_json; - - if (bin) - insert_json["vectors"] = RandomBinRecordsJson(dim, count); - else - insert_json["vectors"] = RandomRecordsJson(dim, count); - - if (!ids.empty()) { - insert_json["ids"] = ids; - } - - if (!tag.empty()) { - insert_json["partition_tag"] = tag; - } - - auto response = client_ptr->insert(collection_name, insert_json.dump().c_str(), conncetion_ptr); - if (OStatus::CODE_201.code != response->getStatusCode()) { - return milvus::Status(milvus::SERVER_UNEXPECTED_ERROR, response->readBodyToString()->c_str()); - } - - return FlushTable(collection_name); - } - - milvus::Status - GenPartition(const OString& collection_name, const OString& tag) { - auto par_param = milvus::server::web::PartitionRequestDto::createShared(); - par_param->partition_tag = tag; - auto response = client_ptr->createPartition(collection_name, par_param); - if (OStatus::CODE_201.code != response->getStatusCode()) { - return milvus::Status(milvus::SERVER_UNEXPECTED_ERROR, response->readBodyToString()->c_str()); - } - - return milvus::Status::OK(); - } - void SetUp() override { std::string config_path = std::string(CONTROLLER_TEST_CONFIG_DIR).append(CONTROLLER_TEST_CONFIG_FILE); @@ -871,27 +779,133 @@ class WebControllerTest : public testing::Test { } void - TearDown() override{}; + TearDown() override {}; protected: std::shared_ptr object_mapper; - std::shared_ptr conncetion_ptr; - std::shared_ptr client_ptr; - - protected: - void - GenTable(const std::string& collection_name, int64_t dim, int64_t index_file_size, int64_t metric_type) { - auto collection_dto = milvus::server::web::TableRequestDto::createShared(); - collection_dto->collection_name = OString(collection_name.c_str()); - collection_dto->dimension = dim; - collection_dto->index_file_size = index_file_size; - collection_dto->metric_type = metric_type; - - client_ptr->createTable(collection_dto, conncetion_ptr); - } + TestConnP conncetion_ptr; + TestClientP client_ptr; }; +namespace { +void +GenTable(const TestClientP& client_ptr, + const TestConnP& connection_ptr, + const OString& collection_name, + int64_t dim, + int64_t index_size, + const OString& metric) { + auto response = client_ptr->getTable(collection_name, "", connection_ptr); + if (OStatus::CODE_200.code == response->getStatusCode()) { + return; + } + auto collection_dto = milvus::server::web::TableRequestDto::createShared(); + collection_dto->collection_name = collection_name; + collection_dto->dimension = dim; + collection_dto->index_file_size = index_size; + collection_dto->metric_type = metric; + client_ptr->createTable(collection_dto, connection_ptr); +} + +milvus::Status +FlushTable(const TestClientP& client_ptr, const TestConnP& connection_ptr, const std::string& collection_name) { + nlohmann::json flush_json; + flush_json["flush"]["collection_names"] = {collection_name}; + auto response = client_ptr->op("task", flush_json.dump().c_str(), connection_ptr); + if (OStatus::CODE_200.code != response->getStatusCode()) { + return milvus::Status(milvus::SERVER_UNEXPECTED_ERROR, response->readBodyToString()->std_str()); + } + + return milvus::Status::OK(); +} + +milvus::Status +FlushTable(const TestClientP& client_ptr, const TestConnP& connection_ptr, const OString& collection_name) { + nlohmann::json flush_json; + flush_json["flush"]["collection_names"] = {collection_name->std_str()}; + auto response = client_ptr->op("task", flush_json.dump().c_str(), connection_ptr); + if (OStatus::CODE_200.code != response->getStatusCode()) { + return milvus::Status(milvus::SERVER_UNEXPECTED_ERROR, response->readBodyToString()->std_str()); + } + + return milvus::Status::OK(); +} + +milvus::Status +InsertData(const TestClientP& client_ptr, + const TestConnP& connection_ptr, + const OString& collection_name, + int64_t dim, + int64_t count, + std::string tag = "", + bool bin = false) { + nlohmann::json insert_json; + + if (bin) + insert_json["vectors"] = RandomBinRecordsJson(dim, count); + else + insert_json["vectors"] = RandomRecordsJson(dim, count); + + if (!tag.empty()) { + insert_json["partition_tag"] = tag; + } + + auto response = client_ptr->insert(collection_name, insert_json.dump().c_str(), connection_ptr); + if (OStatus::CODE_201.code != response->getStatusCode()) { + return milvus::Status(milvus::SERVER_UNEXPECTED_ERROR, response->readBodyToString()->c_str()); + } + + return FlushTable(client_ptr, connection_ptr, collection_name); +} + +milvus::Status +InsertData(const TestClientP& client_ptr, + const TestConnP& connection_ptr, + const OString& collection_name, + int64_t dim, + int64_t count, + const std::vector& ids, + std::string tag = "", + bool bin = false) { + nlohmann::json insert_json; + + if (bin) + insert_json["vectors"] = RandomBinRecordsJson(dim, count); + else + insert_json["vectors"] = RandomRecordsJson(dim, count); + + if (!ids.empty()) { + insert_json["ids"] = ids; + } + + if (!tag.empty()) { + insert_json["partition_tag"] = tag; + } + + auto response = client_ptr->insert(collection_name, insert_json.dump().c_str(), connection_ptr); + if (OStatus::CODE_201.code != response->getStatusCode()) { + return milvus::Status(milvus::SERVER_UNEXPECTED_ERROR, response->readBodyToString()->c_str()); + } + + return FlushTable(client_ptr, connection_ptr, collection_name); +} + +milvus::Status +GenPartition(const TestClientP& client_ptr, + const TestConnP& connection_ptr, + const OString& collection_name, + const OString& tag) { + auto par_param = milvus::server::web::PartitionRequestDto::createShared(); + par_param->partition_tag = tag; + auto response = client_ptr->createPartition(collection_name, par_param); + if (OStatus::CODE_201.code != response->getStatusCode()) { + return milvus::Status(milvus::SERVER_UNEXPECTED_ERROR, response->readBodyToString()->c_str()); + } + + return milvus::Status::OK(); +} } // namespace + TEST_F(WebControllerTest, OPTIONS) { auto response = client_ptr->root(conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()); @@ -955,7 +969,7 @@ TEST_F(WebControllerTest, CREATE_TABLE) { TEST_F(WebControllerTest, GET_TABLE_META) { OString collection_name = "web_test_create_collection" + OString(RandomName().c_str()); - GenTable(collection_name, 10, 10, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name, 10, 10, "L2"); OQueryParams params; @@ -982,10 +996,10 @@ TEST_F(WebControllerTest, GET_TABLE_META) { TEST_F(WebControllerTest, GET_TABLE_STAT) { OString collection_name = "web_test_get_collection_stat" + OString(RandomName().c_str()); - GenTable(collection_name, 128, 5, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name, 128, 5, "L2"); for (size_t i = 0; i < 5; i++) { - InsertData(collection_name, 128, 1000); + InsertData(client_ptr, conncetion_ptr, collection_name, 128, 1000); } auto response = client_ptr->getTable(collection_name, "stat", conncetion_ptr); @@ -1041,7 +1055,7 @@ TEST_F(WebControllerTest, SHOW_TABLES) { TEST_F(WebControllerTest, DROP_TABLE) { auto collection_name = "collection_drop_test" + OString(RandomName().c_str()); - GenTable(collection_name, 128, 100, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name, 128, 100, "L2"); sleep(1); auto response = client_ptr->dropTable(collection_name, conncetion_ptr); @@ -1057,7 +1071,7 @@ TEST_F(WebControllerTest, DROP_TABLE) { TEST_F(WebControllerTest, INSERT) { auto collection_name = "test_insert_collection_test" + OString(RandomName().c_str()); const int64_t dim = 64; - GenTable(collection_name, dim, 100, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name, dim, 100, "L2"); nlohmann::json insert_json; insert_json["vectors"] = RandomRecordsJson(dim, 20); @@ -1077,20 +1091,24 @@ TEST_F(WebControllerTest, INSERT) { TEST_F(WebControllerTest, INSERT_BIN) { auto collection_name = "test_insert_bin_collection_test" + OString(RandomName().c_str()); const int64_t dim = 64; - GenTable(collection_name, dim, 100, "HAMMING"); - + GenTable(client_ptr, conncetion_ptr, collection_name, dim, 100, "HAMMING"); nlohmann::json insert_json; insert_json["vectors"] = RandomBinRecordsJson(dim, 20); - auto response = client_ptr->insert(collection_name, insert_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_201.code, response->getStatusCode()) << response->readBodyToString()->std_str(); - - auto status = FlushTable(collection_name); + auto status = FlushTable(client_ptr, conncetion_ptr, collection_name); ASSERT_TRUE(status.ok()) << status.message(); - auto result_dto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(20, result_dto->ids->count()); + response = client_ptr->dropTable(collection_name, conncetion_ptr); + ASSERT_EQ(OStatus::CODE_204.code, response->getStatusCode()); + collection_name = "test_insert_bin_collection_test" + OString(RandomName().c_str()); + GenTable(client_ptr, conncetion_ptr, collection_name, dim, 100, milvus::server::web::NAME_METRIC_TYPE_SUBSTRUCTURE); + response = client_ptr->insert(collection_name, insert_json.dump().c_str(), conncetion_ptr); + ASSERT_EQ(OStatus::CODE_201.code, response->getStatusCode()) << response->readBodyToString()->std_str(); + status = FlushTable(client_ptr, conncetion_ptr, collection_name); + ASSERT_TRUE(status.ok()) << status.message(); response = client_ptr->dropTable(collection_name, conncetion_ptr); ASSERT_EQ(OStatus::CODE_204.code, response->getStatusCode()); } @@ -1098,7 +1116,7 @@ TEST_F(WebControllerTest, INSERT_BIN) { TEST_F(WebControllerTest, INSERT_IDS) { auto collection_name = "test_insert_collection_test" + OString(RandomName().c_str()); const int64_t dim = 64; - GenTable(collection_name, dim, 100, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name, dim, 100, "L2"); std::vector ids; for (size_t i = 0; i < 20; i++) { @@ -1120,7 +1138,7 @@ TEST_F(WebControllerTest, INSERT_IDS) { TEST_F(WebControllerTest, INDEX) { auto collection_name = "test_insert_collection_test" + OString(RandomName().c_str()); - GenTable(collection_name, 64, 100, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name, 64, 100, "L2"); // test index with imcomplete param nlohmann::json index_json; @@ -1143,7 +1161,7 @@ TEST_F(WebControllerTest, INDEX) { // create index without existing table response = client_ptr->createIndex(collection_name + "fgafafafafafUUUUUUa124254", - index_json.dump().c_str(), conncetion_ptr); + index_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_404.code, response->getStatusCode()); // invalid index type @@ -1158,7 +1176,7 @@ TEST_F(WebControllerTest, INDEX) { ASSERT_EQ(OStatus::CODE_204.code, response->getStatusCode()); // insert data and create index - auto status = InsertData(collection_name, 64, 200); + auto status = InsertData(client_ptr, conncetion_ptr, collection_name, 64, 200); ASSERT_TRUE(status.ok()) << status.message(); index_json["index_type"] = milvus::server::web::IndexMap.at(milvus::engine::EngineType::FAISS_IVFFLAT); @@ -1189,7 +1207,7 @@ TEST_F(WebControllerTest, INDEX) { TEST_F(WebControllerTest, PARTITION) { const OString collection_name = "test_controller_partition_" + OString(RandomName().c_str()); - GenTable(collection_name, 64, 100, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name, 64, 100, "L2"); auto par_param = milvus::server::web::PartitionRequestDto::createShared(); auto response = client_ptr->createPartition(collection_name, par_param); @@ -1214,7 +1232,7 @@ TEST_F(WebControllerTest, PARTITION) { ASSERT_EQ(milvus::server::web::StatusCode::TABLE_NOT_EXISTS, error_dto->code); // insert 200 vectors into collection with tag = 'tag01' - auto status = InsertData(collection_name, 64, 200, "tag01"); + auto status = InsertData(client_ptr, conncetion_ptr, collection_name, 64, 200, "tag01"); ASSERT_TRUE(status.ok()) << status.message(); // Show all partitins @@ -1244,16 +1262,16 @@ TEST_F(WebControllerTest, PARTITION) { // drop without existing collections response = client_ptr->dropPartition(collection_name + "565755682353464aaasafdsfagagqq1223", - "{\"partition_tag\": \"tag01\"}", conncetion_ptr); + "{\"partition_tag\": \"tag01\"}", conncetion_ptr); ASSERT_EQ(OStatus::CODE_404.code, response->getStatusCode()); } TEST_F(WebControllerTest, SHOW_SEGMENTS) { OString collection_name = OString("test_milvus_web_segments_test_") + RandomName().c_str(); - GenTable(collection_name, 256, 1, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name, 256, 1, "L2"); - auto status = InsertData(collection_name, 256, 2000); + auto status = InsertData(client_ptr, conncetion_ptr, collection_name, 256, 2000); ASSERT_TRUE(status.ok()) << status.message(); auto response = client_ptr->showSegments(collection_name, "0", "10", "", conncetion_ptr); @@ -1273,9 +1291,9 @@ TEST_F(WebControllerTest, SHOW_SEGMENTS) { TEST_F(WebControllerTest, GET_SEGMENT_INFO) { OString collection_name = OString("test_milvus_web_get_segment_info_test_") + RandomName().c_str(); - GenTable(collection_name, 16, 1, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name, 16, 1, "L2"); - auto status = InsertData(collection_name, 16, 2000); + auto status = InsertData(client_ptr, conncetion_ptr, collection_name, 16, 2000); ASSERT_TRUE(status.ok()) << status.message(); auto response = client_ptr->showSegments(collection_name, "0", "10", "", conncetion_ptr); @@ -1315,21 +1333,21 @@ TEST_F(WebControllerTest, GET_SEGMENT_INFO) { TEST_F(WebControllerTest, SEGMENT_FILTER) { OString collection_name = OString("test_milvus_web_segment_filter_test_") + RandomName().c_str(); - GenTable(collection_name, 16, 1, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name, 16, 1, "L2"); - auto status = InsertData(collection_name, 16, 1000); + auto status = InsertData(client_ptr, conncetion_ptr, collection_name, 16, 1000); ASSERT_TRUE(status.ok()) << status.message(); - status = GenPartition(collection_name, "tag01"); + status = GenPartition(client_ptr, conncetion_ptr, collection_name, "tag01"); ASSERT_TRUE(status.ok()) << status.message(); - status = InsertData(collection_name, 16, 1000, "tag01"); + status = InsertData(client_ptr, conncetion_ptr, collection_name, 16, 1000, "tag01"); ASSERT_TRUE(status.ok()) << status.message(); - status = GenPartition(collection_name, "tag02"); + status = GenPartition(client_ptr, conncetion_ptr, collection_name, "tag02"); ASSERT_TRUE(status.ok()) << status.message(); - status = InsertData(collection_name, 16, 1000, "tag02"); + status = InsertData(client_ptr, conncetion_ptr, collection_name, 16, 1000, "tag02"); ASSERT_TRUE(status.ok()) << status.message(); // show segments filtering tag @@ -1342,7 +1360,7 @@ TEST_F(WebControllerTest, SEGMENT_FILTER) { ASSERT_TRUE(result_json.contains("segments")); auto segments_json = result_json["segments"]; ASSERT_TRUE(segments_json.is_array()); - for (auto & s : segments_json) { + for (auto& s : segments_json) { ASSERT_TRUE(s.contains("partition_tag")); ASSERT_EQ("_default", s["partition_tag"].get()); } @@ -1350,10 +1368,10 @@ TEST_F(WebControllerTest, SEGMENT_FILTER) { TEST_F(WebControllerTest, SEARCH) { const OString collection_name = "test_search_collection_test" + OString(RandomName().c_str()); - GenTable(collection_name, 64, 100, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name, 64, 100, "L2"); // Insert 200 vectors into collection - auto status = InsertData(collection_name, 64, 200); + auto status = InsertData(client_ptr, conncetion_ptr, collection_name, 64, 200); ASSERT_TRUE(status.ok()) << status.message(); // Create partition and insert 200 vectors into it @@ -1361,9 +1379,9 @@ TEST_F(WebControllerTest, SEARCH) { par_param->partition_tag = "tag" + OString(RandomName().c_str()); auto response = client_ptr->createPartition(collection_name, par_param); ASSERT_EQ(OStatus::CODE_201.code, response->getStatusCode()) - << "Error: " << response->getStatusDescription()->std_str(); + << "Error: " << response->getStatusDescription()->std_str(); - status = InsertData(collection_name, 64, 200, par_param->partition_tag->std_str()); + status = InsertData(client_ptr, conncetion_ptr, collection_name, 64, 200, par_param->partition_tag->std_str()); ASSERT_TRUE(status.ok()) << status.message(); // Test search @@ -1415,10 +1433,10 @@ TEST_F(WebControllerTest, SEARCH) { TEST_F(WebControllerTest, SEARCH_BIN) { const OString collection_name = "test_search_bin_collection_test" + OString(RandomName().c_str()); - GenTable(collection_name, 64, 100, "HAMMING"); + GenTable(client_ptr, conncetion_ptr, collection_name, 64, 100, "HAMMING"); // Insert 200 vectors into collection - auto status = InsertData(collection_name, 64, 200, "", true); + auto status = InsertData(client_ptr, conncetion_ptr, collection_name, 64, 200, "", true); ASSERT_TRUE(status.ok()) << status.message(); // Create partition and insert 200 vectors into it @@ -1428,7 +1446,8 @@ TEST_F(WebControllerTest, SEARCH_BIN) { ASSERT_EQ(OStatus::CODE_201.code, response->getStatusCode()) << "Error: " << response->readBodyToString()->std_str(); - status = InsertData(collection_name, 64, 200, par_param->partition_tag->std_str(), true); + status = + InsertData(client_ptr, conncetion_ptr, collection_name, 64, 200, par_param->partition_tag->std_str(), true); ASSERT_TRUE(status.ok()) << status.message(); // Test search @@ -1515,7 +1534,7 @@ TEST_F(WebControllerTest, SEARCH_BIN) { TEST_F(WebControllerTest, GET_VECTOR_BY_ID) { const OString collection_name = "test_milvus_web_get_vector_by_id_test_" + OString(RandomName().c_str()); - GenTable(collection_name, 64, 100, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name, 64, 100, "L2"); // Insert 100 vectors into collection std::vector ids; @@ -1523,7 +1542,7 @@ TEST_F(WebControllerTest, GET_VECTOR_BY_ID) { ids.emplace_back(i); } - auto status = InsertData(collection_name, 64, 100, ids); + auto status = InsertData(client_ptr, conncetion_ptr, collection_name, 64, 100, ids); ASSERT_TRUE(status.ok()) << status.message(); /* test task load */ @@ -1546,7 +1565,7 @@ TEST_F(WebControllerTest, GET_VECTOR_BY_ID) { auto vec_json = vector_json["vector"]; ASSERT_TRUE(vec_json.is_array()); std::vector vec; - for (auto & v : vec_json) { + for (auto& v : vec_json) { vec.emplace_back(v.get()); } @@ -1559,7 +1578,7 @@ TEST_F(WebControllerTest, GET_VECTOR_BY_ID) { TEST_F(WebControllerTest, DELETE_BY_ID) { const OString collection_name = "test_search_bin_collection_test" + OString(RandomName().c_str()); - GenTable(collection_name, 64, 100, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name, 64, 100, "L2"); // Insert 200 vectors into collection nlohmann::json insert_json; @@ -1573,7 +1592,7 @@ TEST_F(WebControllerTest, DELETE_BY_ID) { ASSERT_TRUE(ids_json.is_array()); std::vector ids; - for (auto & id : ids_json) { + for (auto& id : ids_json) { ids.emplace_back(id.get()); } @@ -1636,10 +1655,10 @@ TEST_F(WebControllerTest, CONFIG) { ASSERT_TRUE(result_json.contains("restart_required")); OString collection_name = "milvus_test_webcontroller_test_preload_collection"; - GenTable(collection_name, 16, 10, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name, 16, 10, "L2"); OString collection_name_s = "milvus_test_webcontroller_test_preload_collection_s"; - GenTable(collection_name_s, 16, 10, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name_s, 16, 10, "L2"); OString body_str = "{\"db_config\": {\"preload_table\": \"" + collection_name + "\"}}"; response = client_ptr->op("config", body_str, conncetion_ptr); @@ -1766,6 +1785,7 @@ TEST_F(WebControllerTest, GPU_CONFIG) { response = client_ptr->setGPUConfig(gpu_config_dto, conncetion_ptr); ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()); } + #endif TEST_F(WebControllerTest, DEVICES_CONFIG) { @@ -1775,9 +1795,9 @@ TEST_F(WebControllerTest, DEVICES_CONFIG) { TEST_F(WebControllerTest, FLUSH) { auto collection_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); - GenTable(collection_name, 16, 10, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name, 16, 10, "L2"); - auto status = InsertData(collection_name, 16, 1000); + auto status = InsertData(client_ptr, conncetion_ptr, collection_name, 16, 1000); ASSERT_TRUE(status.ok()) << status.message(); nlohmann::json flush_json; @@ -1798,9 +1818,9 @@ TEST_F(WebControllerTest, FLUSH) { TEST_F(WebControllerTest, COMPACT) { auto collection_name = milvus::server::web::OString("milvus_web_test_compact_") + RandomName().c_str(); - GenTable(collection_name, 16, 10, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name, 16, 10, "L2"); - auto status = InsertData(collection_name, 16, 1000); + auto status = InsertData(client_ptr, conncetion_ptr, collection_name, 16, 1000); ASSERT_TRUE(status.ok()) << status.message(); nlohmann::json compact_json; @@ -1811,17 +1831,16 @@ TEST_F(WebControllerTest, COMPACT) { TEST_F(WebControllerTest, LOAD) { OString collection_name = "milvus_web_test_load_" + OString(RandomName().c_str()); - GenTable(collection_name, 128, 100, "L2"); + GenTable(client_ptr, conncetion_ptr, collection_name, 128, 100, "L2"); nlohmann::json load_json; load_json["load"]["collection_name"] = collection_name->c_str(); - auto response = client_ptr->op("task", load_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()); // load with a non-existent name load_json["load"]["collection_name"] = "sssssssssssssssssssssssfsfsfsrrrttt"; - response = client_ptr->op("task", load_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()); } +