diff --git a/CHANGELOG.md b/CHANGELOG.md index b4846ab93112aae3f83af0bc46d64efd8fd8e397..abb94a552cbc6524b9b823eda7854854f78b5995 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,6 +90,7 @@ Please mark all change in change log and use the issue from GitHub - \#1448 General proto api for NNS libraries - \#1480 Add return code for AVX512 selection - \#1524 Update config "preload_table" description +- \#1544 Update resources name in HTTP module ## Task - \#1327 Exclude third-party code from codebeat diff --git a/core/src/config/handler/ConfigHandler.h b/core/src/config/handler/ConfigHandler.h index 84e6e91dec3fa2a20eff06a2d6d380ff702350c4..8f31757a7e7d2511abd4f82d409aed36b91988b6 100644 --- a/core/src/config/handler/ConfigHandler.h +++ b/core/src/config/handler/ConfigHandler.h @@ -14,7 +14,6 @@ #include #include "server/Config.h" -#include "utils/Log.h" namespace milvus { namespace server { diff --git a/core/src/server/Config.cpp b/core/src/server/Config.cpp index 855e8bd1f73f748b971f7be48f51bd0ec4121dee..f0b88fa98c8362d4c898b02e31066904b6f74845 100644 --- a/core/src/server/Config.cpp +++ b/core/src/server/Config.cpp @@ -549,9 +549,14 @@ Config::UpdateFileConfigFromMem(const std::string& parent_key, const std::string // convert value string to standard string stored in yaml file std::string value_str; if (child_key == CONFIG_CACHE_CACHE_INSERT_DATA || child_key == CONFIG_STORAGE_S3_ENABLE || - child_key == CONFIG_METRIC_ENABLE_MONITOR || child_key == CONFIG_GPU_RESOURCE_ENABLE) { - value_str = - (value == "True" || value == "true" || value == "On" || value == "on" || value == "1") ? "true" : "false"; + child_key == CONFIG_METRIC_ENABLE_MONITOR || child_key == CONFIG_GPU_RESOURCE_ENABLE || + child_key == CONFIG_WAL_ENABLE || child_key == CONFIG_WAL_RECOVERY_ERROR_IGNORE) { + bool ok = false; + status = StringHelpFunctions::ConvertToBoolean(value, ok); + if (!status.ok()) { + return status; + } + value_str = ok ? "true" : "false"; } else if (child_key == CONFIG_GPU_RESOURCE_SEARCH_RESOURCES || child_key == CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES) { std::vector vec; @@ -593,7 +598,6 @@ Config::UpdateFileConfigFromMem(const std::string& parent_key, const std::string } // values of gpu resources are sequences, need to remove old here - std::regex reg("\\S*"); if (child_key == CONFIG_GPU_RESOURCE_SEARCH_RESOURCES || child_key == CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES) { while (getline(conf_fin, line)) { if (line.find("- gpu") != std::string::npos) @@ -1853,7 +1857,8 @@ Config::SetDBConfigBackendUrl(const std::string& value) { Status Config::SetDBConfigPreloadTable(const std::string& value) { CONFIG_CHECK(CheckDBConfigPreloadTable(value)); - return SetConfigValueInMem(CONFIG_DB, CONFIG_DB_PRELOAD_TABLE, value); + std::string cor_value = value == "*" ? "\'*\'" : value; + return SetConfigValueInMem(CONFIG_DB, CONFIG_DB_PRELOAD_TABLE, cor_value); } Status diff --git a/core/src/server/web_impl/controller/WebController.hpp b/core/src/server/web_impl/controller/WebController.hpp index 2d301347f2a46e7db19a040ed0274221ba8e31ea..ab2a26c2caaf2cada88b43886218686982d61ab2 100644 --- a/core/src/server/web_impl/controller/WebController.hpp +++ b/core/src/server/web_impl/controller/WebController.hpp @@ -208,14 +208,14 @@ class WebController : public oatpp::web::server::api::ApiController { ADD_CORS(TablesOptions) - ENDPOINT("OPTIONS", "/tables", TablesOptions) { + ENDPOINT("OPTIONS", "/collections", TablesOptions) { return createResponse(Status::CODE_204, "No Content"); } ADD_CORS(CreateTable) - ENDPOINT("POST", "/tables", CreateTable, BODY_DTO(TableRequestDto::ObjectWrapper, body)) { - TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "POST \'/tables\'"); + ENDPOINT("POST", "/collections", CreateTable, BODY_DTO(TableRequestDto::ObjectWrapper, body)) { + TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "POST \'/collections\'"); tr.RecordSection("Received request."); WebRequestHandler handler = WebRequestHandler(); @@ -238,8 +238,8 @@ class WebController : public oatpp::web::server::api::ApiController { ADD_CORS(ShowTables) - ENDPOINT("GET", "/tables", ShowTables, QUERIES(const QueryParams&, query_params)) { - TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "GET \'/tables\'"); + ENDPOINT("GET", "/collections", ShowTables, QUERIES(const QueryParams&, query_params)) { + TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "GET \'/collections\'"); tr.RecordSection("Received request."); WebRequestHandler handler = WebRequestHandler(); @@ -265,21 +265,21 @@ class WebController : public oatpp::web::server::api::ApiController { ADD_CORS(TableOptions) - ENDPOINT("OPTIONS", "/tables/{table_name}", TableOptions) { + ENDPOINT("OPTIONS", "/collections/{collection_name}", TableOptions) { return createResponse(Status::CODE_204, "No Content"); } ADD_CORS(GetTable) - ENDPOINT("GET", "/tables/{table_name}", GetTable, - PATH(String, table_name), QUERIES(const QueryParams&, query_params)) { - TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "GET \'/tables/" + table_name->std_str() + "\'"); + ENDPOINT("GET", "/collections/{collection_name}", GetTable, + PATH(String, collection_name), QUERIES(const QueryParams&, query_params)) { + TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "GET \'/collections/" + collection_name->std_str() + "\'"); tr.RecordSection("Received request."); WebRequestHandler handler = WebRequestHandler(); String response_str; - auto status_dto = handler.GetTable(table_name, query_params, response_str); + auto status_dto = handler.GetTable(collection_name, query_params, response_str); std::shared_ptr response; switch (status_dto->code->getValue()) { @@ -302,14 +302,14 @@ class WebController : public oatpp::web::server::api::ApiController { ADD_CORS(DropTable) - ENDPOINT("DELETE", "/tables/{table_name}", DropTable, PATH(String, table_name)) { - TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "DELETE \'/tables/" + table_name->std_str() + "\'"); + ENDPOINT("DELETE", "/collections/{collection_name}", DropTable, PATH(String, collection_name)) { + TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "DELETE \'/collections/" + collection_name->std_str() + "\'"); tr.RecordSection("Received request."); WebRequestHandler handler = WebRequestHandler(); std::shared_ptr response; - auto status_dto = handler.DropTable(table_name); + auto status_dto = handler.DropTable(collection_name); switch (status_dto->code->getValue()) { case StatusCode::SUCCESS: response = createDtoResponse(Status::CODE_204, status_dto); @@ -330,21 +330,21 @@ class WebController : public oatpp::web::server::api::ApiController { ADD_CORS(IndexOptions) - ENDPOINT("OPTIONS", "/tables/{table_name}/indexes", IndexOptions) { + ENDPOINT("OPTIONS", "/collections/{collection_name}/indexes", IndexOptions) { return createResponse(Status::CODE_204, "No Content"); } ADD_CORS(CreateIndex) - ENDPOINT("POST", "/tables/{table_name}/indexes", CreateIndex, - PATH(String, table_name), BODY_STRING(String, body)) { - TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "POST \'/tables/" + table_name->std_str() + "/indexes\'"); + ENDPOINT("POST", "/tables/{collection_name}/indexes", CreateIndex, + PATH(String, collection_name), BODY_STRING(String, body)) { + TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "POST \'/tables/" + collection_name->std_str() + "/indexes\'"); tr.RecordSection("Received request."); auto handler = WebRequestHandler(); std::shared_ptr response; - auto status_dto = handler.CreateIndex(table_name, body); + auto status_dto = handler.CreateIndex(collection_name, body); switch (status_dto->code->getValue()) { case StatusCode::SUCCESS: response = createDtoResponse(Status::CODE_201, status_dto); @@ -365,14 +365,14 @@ class WebController : public oatpp::web::server::api::ApiController { ADD_CORS(GetIndex) - ENDPOINT("GET", "/tables/{table_name}/indexes", GetIndex, PATH(String, table_name)) { - TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "GET \'/tables/" + table_name->std_str() + "/indexes\'"); + ENDPOINT("GET", "/collections/{collection_name}/indexes", GetIndex, PATH(String, collection_name)) { + TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "GET \'/collections/" + collection_name->std_str() + "/indexes\'"); tr.RecordSection("Received request."); auto handler = WebRequestHandler(); OString result; - auto status_dto = handler.GetIndex(table_name, result); + auto status_dto = handler.GetIndex(collection_name, result); std::shared_ptr response; switch (status_dto->code->getValue()) { @@ -395,14 +395,14 @@ class WebController : public oatpp::web::server::api::ApiController { ADD_CORS(DropIndex) - ENDPOINT("DELETE", "/tables/{table_name}/indexes", DropIndex, PATH(String, table_name)) { - TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "DELETE \'/tables/" + table_name->std_str() + "/indexes\'"); + ENDPOINT("DELETE", "/collections/{collection_name}/indexes", DropIndex, PATH(String, collection_name)) { + TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "DELETE \'/collections/" + collection_name->std_str() + "/indexes\'"); tr.RecordSection("Received request."); auto handler = WebRequestHandler(); std::shared_ptr response; - auto status_dto = handler.DropIndex(table_name); + auto status_dto = handler.DropIndex(collection_name); switch (status_dto->code->getValue()) { case StatusCode::SUCCESS: response = createDtoResponse(Status::CODE_204, status_dto); @@ -423,21 +423,21 @@ class WebController : public oatpp::web::server::api::ApiController { ADD_CORS(PartitionsOptions) - ENDPOINT("OPTIONS", "/tables/{table_name}/partitions", PartitionsOptions) { + ENDPOINT("OPTIONS", "/collections/{collection_name}/partitions", PartitionsOptions) { return createResponse(Status::CODE_204, "No Content"); } ADD_CORS(CreatePartition) - ENDPOINT("POST", "/tables/{table_name}/partitions", - CreatePartition, PATH(String, table_name), BODY_DTO(PartitionRequestDto::ObjectWrapper, body)) { - TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "POST \'/tables/" + table_name->std_str() + "/partitions\'"); + ENDPOINT("POST", "/collections/{collection_name}/partitions", + CreatePartition, PATH(String, collection_name), BODY_DTO(PartitionRequestDto::ObjectWrapper, body)) { + TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "POST \'/collections/" + collection_name->std_str() + "/partitions\'"); tr.RecordSection("Received request."); auto handler = WebRequestHandler(); std::shared_ptr response; - auto status_dto = handler.CreatePartition(table_name, body); + auto status_dto = handler.CreatePartition(collection_name, body); switch (status_dto->code->getValue()) { case StatusCode::SUCCESS: response = createDtoResponse(Status::CODE_201, status_dto); @@ -457,9 +457,9 @@ class WebController : public oatpp::web::server::api::ApiController { ADD_CORS(ShowPartitions) - ENDPOINT("GET", "/tables/{table_name}/partitions", ShowPartitions, - PATH(String, table_name), QUERIES(const QueryParams&, query_params)) { - TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "GET \'/tables/" + table_name->std_str() + "/partitions\'"); + ENDPOINT("GET", "/collections/{collection_name}/partitions", ShowPartitions, + PATH(String, collection_name), QUERIES(const QueryParams&, query_params)) { + TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "GET \'/collections/" + collection_name->std_str() + "/partitions\'"); tr.RecordSection("Received request."); auto offset = query_params.get("offset"); @@ -469,7 +469,7 @@ class WebController : public oatpp::web::server::api::ApiController { auto handler = WebRequestHandler(); std::shared_ptr response; - auto status_dto = handler.ShowPartitions(table_name, query_params, partition_list_dto); + auto status_dto = handler.ShowPartitions(collection_name, query_params, partition_list_dto); switch (status_dto->code->getValue()) { case StatusCode::SUCCESS: response = createDtoResponse(Status::CODE_200, partition_list_dto); @@ -488,16 +488,16 @@ class WebController : public oatpp::web::server::api::ApiController { ADD_CORS(DropPartition) - ENDPOINT("DELETE", "/tables/{table_name}/partitions", DropPartition, - PATH(String, table_name), BODY_STRING(String, body)) { + ENDPOINT("DELETE", "/collections/{collection_name}/partitions", DropPartition, + PATH(String, collection_name), BODY_STRING(String, body)) { TimeRecorder tr(std::string(WEB_LOG_PREFIX) + - "DELETE \'/tables/" + table_name->std_str() + "/partitions\'"); + "DELETE \'/collections/" + collection_name->std_str() + "/partitions\'"); tr.RecordSection("Received request."); auto handler = WebRequestHandler(); std::shared_ptr response; - auto status_dto = handler.DropPartition(table_name, body); + auto status_dto = handler.DropPartition(collection_name, body); switch (status_dto->code->getValue()) { case StatusCode::SUCCESS: response = createDtoResponse(Status::CODE_204, status_dto); @@ -517,14 +517,14 @@ class WebController : public oatpp::web::server::api::ApiController { ADD_CORS(ShowSegments) - ENDPOINT("GET", "/tables/{table_name}/segments", ShowSegments, - PATH(String, table_name), QUERIES(const QueryParams&, query_params)) { + ENDPOINT("GET", "/collections/{collection_name}/segments", ShowSegments, + PATH(String, collection_name), QUERIES(const QueryParams&, query_params)) { auto offset = query_params.get("offset"); auto page_size = query_params.get("page_size"); auto handler = WebRequestHandler(); String response; - auto status_dto = handler.ShowSegments(table_name, query_params, response); + auto status_dto = handler.ShowSegments(collection_name, query_params, response); switch (status_dto->code->getValue()) { case StatusCode::SUCCESS: @@ -541,14 +541,14 @@ class WebController : public oatpp::web::server::api::ApiController { * * GetSegmentVector */ - ENDPOINT("GET", "/tables/{table_name}/segments/{segment_name}/{info}", GetSegmentInfo, - PATH(String, table_name), PATH(String, segment_name), PATH(String, info), QUERIES(const QueryParams&, query_params)) { + ENDPOINT("GET", "/collections/{collection_name}/segments/{segment_name}/{info}", GetSegmentInfo, + PATH(String, collection_name), PATH(String, segment_name), PATH(String, info), QUERIES(const QueryParams&, query_params)) { auto offset = query_params.get("offset"); auto page_size = query_params.get("page_size"); auto handler = WebRequestHandler(); String response; - auto status_dto = handler.GetSegmentInfo(table_name, segment_name, info, query_params, response); + auto status_dto = handler.GetSegmentInfo(collection_name, segment_name, info, query_params, response); switch (status_dto->code->getValue()) { case StatusCode::SUCCESS: @@ -562,7 +562,7 @@ class WebController : public oatpp::web::server::api::ApiController { ADD_CORS(VectorsOptions) - ENDPOINT("OPTIONS", "/tables/{table_name}/vectors", VectorsOptions) { + ENDPOINT("OPTIONS", "/collections/{collection_name}/vectors", VectorsOptions) { return createResponse(Status::CODE_204, "No Content"); } @@ -571,11 +571,11 @@ class WebController : public oatpp::web::server::api::ApiController { * * GetVectorByID ?id= */ - ENDPOINT("GET", "/tables/{table_name}/vectors", GetVectors, - PATH(String, table_name), QUERIES(const QueryParams&, query_params)) { + ENDPOINT("GET", "/collections/{collection_name}/vectors", GetVectors, + PATH(String, collection_name), QUERIES(const QueryParams&, query_params)) { auto handler = WebRequestHandler(); String response; - auto status_dto = handler.GetVector(table_name, query_params, response); + auto status_dto = handler.GetVector(collection_name, query_params, response); switch (status_dto->code->getValue()) { case StatusCode::SUCCESS: @@ -589,16 +589,16 @@ class WebController : public oatpp::web::server::api::ApiController { ADD_CORS(Insert) - ENDPOINT("POST", "/tables/{table_name}/vectors", Insert, - PATH(String, table_name), BODY_STRING(String, body)) { - TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "POST \'/tables/" + table_name->std_str() + "/vectors\'"); + ENDPOINT("POST", "/collections/{collection_name}/vectors", Insert, + PATH(String, collection_name), BODY_STRING(String, body)) { + TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "POST \'/collections/" + collection_name->std_str() + "/vectors\'"); tr.RecordSection("Received request."); auto ids_dto = VectorIdsDto::createShared(); WebRequestHandler handler = WebRequestHandler(); std::shared_ptr response; - auto status_dto = handler.Insert(table_name, body, ids_dto); + auto status_dto = handler.Insert(collection_name, body, ids_dto); switch (status_dto->code->getValue()) { case StatusCode::SUCCESS: response = createDtoResponse(Status::CODE_201, ids_dto); @@ -621,16 +621,16 @@ class WebController : public oatpp::web::server::api::ApiController { * Search * Delete by ID * */ - ENDPOINT("PUT", "/tables/{table_name}/vectors", VectorsOp, - PATH(String, table_name), BODY_STRING(String, body)) { - TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "PUT \'/tables/" + table_name->std_str() + "/vectors\'"); + ENDPOINT("PUT", "/collections/{collection_name}/vectors", VectorsOp, + PATH(String, collection_name), BODY_STRING(String, body)) { + TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "PUT \'/collections/" + collection_name->std_str() + "/vectors\'"); tr.RecordSection("Received request."); WebRequestHandler handler = WebRequestHandler(); OString result; std::shared_ptr response; - auto status_dto = handler.VectorsOp(table_name, body, result); + auto status_dto = handler.VectorsOp(collection_name, body, result); switch (status_dto->code->getValue()) { case StatusCode::SUCCESS: response = createResponse(Status::CODE_200, result); @@ -674,11 +674,6 @@ class WebController : public oatpp::web::server::api::ApiController { ADD_CORS(SystemOp) - /** - * Load - * Compact - * Flush - */ ENDPOINT("PUT", "/system/{Op}", SystemOp, PATH(String, Op), BODY_STRING(String, body_str)) { TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "PUT \'/system/" + Op->std_str() + "\'"); tr.RecordSection("Received request."); diff --git a/core/src/server/web_impl/dto/TableDto.hpp b/core/src/server/web_impl/dto/TableDto.hpp index 64781a978daac985d20ccc87adcb9cdd8a61e3f7..d5e533c737ebbde66701c1b2d69aa603bf5ee9bf 100644 --- a/core/src/server/web_impl/dto/TableDto.hpp +++ b/core/src/server/web_impl/dto/TableDto.hpp @@ -25,7 +25,7 @@ namespace web { class TableRequestDto : public oatpp::data::mapping::type::Object { DTO_INIT(TableRequestDto, Object) - DTO_FIELD(String, table_name, "table_name"); + DTO_FIELD(String, collection_name, "collection_name"); DTO_FIELD(Int64, dimension, "dimension"); DTO_FIELD(Int64, index_file_size, "index_file_size") = VALUE_TABLE_INDEX_FILE_SIZE_DEFAULT; DTO_FIELD(String, metric_type, "metric_type") = VALUE_TABLE_METRIC_TYPE_DEFAULT; @@ -34,7 +34,7 @@ class TableRequestDto : public oatpp::data::mapping::type::Object { class TableFieldsDto : public oatpp::data::mapping::type::Object { DTO_INIT(TableFieldsDto, Object) - DTO_FIELD(String, table_name); + DTO_FIELD(String, collection_name); DTO_FIELD(Int64, dimension); DTO_FIELD(Int64, index_file_size); DTO_FIELD(String, metric_type); @@ -46,13 +46,13 @@ class TableFieldsDto : public oatpp::data::mapping::type::Object { class TableListDto : public OObject { DTO_INIT(TableListDto, Object) - DTO_FIELD(List::ObjectWrapper, table_names); + DTO_FIELD(List::ObjectWrapper, collection_names); }; class TableListFieldsDto : public OObject { DTO_INIT(TableListFieldsDto, Object) - DTO_FIELD(List::ObjectWrapper, tables); + DTO_FIELD(List::ObjectWrapper, collections); DTO_FIELD(Int64, count) = 0; }; diff --git a/core/src/server/web_impl/dto/VectorDto.hpp b/core/src/server/web_impl/dto/VectorDto.hpp index 7bb39b2e545ef78b58c8d4cb8da1c4229a05fbcb..01b73fdc5134199d4989d30a74ad35f368cd0022 100644 --- a/core/src/server/web_impl/dto/VectorDto.hpp +++ b/core/src/server/web_impl/dto/VectorDto.hpp @@ -20,26 +20,6 @@ namespace web { #include OATPP_CODEGEN_BEGIN(DTO) -class SearchRequestDto : public OObject { - DTO_INIT(SearchRequestDto, Object) - - DTO_FIELD(Int64, topk); - DTO_FIELD(Int64, nprobe); - DTO_FIELD(List::ObjectWrapper, tags); - DTO_FIELD(List::ObjectWrapper, file_ids); - DTO_FIELD(List::ObjectWrapper>::ObjectWrapper, records); - DTO_FIELD(List::ObjectWrapper>::ObjectWrapper, records_bin); -}; - -class InsertRequestDto : public oatpp::data::mapping::type::Object { - DTO_INIT(InsertRequestDto, Object) - - DTO_FIELD(String, tag) = VALUE_PARTITION_TAG_DEFAULT; - DTO_FIELD(List::ObjectWrapper>::ObjectWrapper, records); - DTO_FIELD(List::ObjectWrapper>::ObjectWrapper, records_bin); - DTO_FIELD(List::ObjectWrapper, ids); -}; - class VectorIdsDto : public oatpp::data::mapping::type::Object { DTO_INIT(VectorIdsDto, Object) diff --git a/core/src/server/web_impl/handler/WebRequestHandler.cpp b/core/src/server/web_impl/handler/WebRequestHandler.cpp index f9bf7409db8cce047637a19e38e4a0fe2d95a4fd..92d68e77ca44b30d1c94cc6559ff8e7a043a8e03 100644 --- a/core/src/server/web_impl/handler/WebRequestHandler.cpp +++ b/core/src/server/web_impl/handler/WebRequestHandler.cpp @@ -109,6 +109,26 @@ WebRequestHandler::ParseQueryStr(const OQueryParams& query_params, const std::st return Status::OK(); } +Status +WebRequestHandler::ParseQueryBool(const OQueryParams& query_params, const std::string& key, bool& value, + bool nullable) { + auto query = query_params.get(key.c_str()); + if (nullptr != query.get() && query->getSize() > 0) { + std::string value_str = query->std_str(); + if (!ValidationUtil::ValidateStringIsBool(value_str).ok()) { + return Status(ILLEGAL_QUERY_PARAM, "Query param \'all_required\' must be a bool"); + } + value = value_str == "True" || value_str == "true"; + return Status::OK(); + } + + if (!nullable) { + return Status(QUERY_PARAM_LOSS, "Query param \"" + key + "\" is required"); + } + + return Status::OK(); +} + void WebRequestHandler::AddStatusToJson(nlohmann::json& json, int64_t code, const std::string& msg) { json["code"] = (int64_t)code; @@ -142,9 +162,9 @@ WebRequestHandler::ParsePartitionStat(const milvus::server::PartitionStat& par_s } Status -WebRequestHandler::IsBinaryTable(const std::string& table_name, bool& bin) { +WebRequestHandler::IsBinaryTable(const std::string& collection_name, bool& bin) { TableSchema schema; - auto status = request_handler_.DescribeTable(context_ptr_, table_name, schema); + auto status = request_handler_.DescribeTable(context_ptr_, collection_name, schema); if (status.ok()) { auto metric = engine::MetricType(schema.metric_type_); bin = engine::MetricType::HAMMING == metric || engine::MetricType::JACCARD == metric || @@ -187,26 +207,26 @@ WebRequestHandler::CopyRecordsFromJson(const nlohmann::json& json, engine::Vecto ///////////////////////// WebRequestHandler methods /////////////////////////////////////// Status -WebRequestHandler::GetTableMetaInfo(const std::string& table_name, nlohmann::json& json_out) { +WebRequestHandler::GetTableMetaInfo(const std::string& collection_name, nlohmann::json& json_out) { TableSchema schema; - auto status = request_handler_.DescribeTable(context_ptr_, table_name, schema); + auto status = request_handler_.DescribeTable(context_ptr_, collection_name, schema); if (!status.ok()) { return status; } int64_t count; - status = request_handler_.CountTable(context_ptr_, table_name, count); + status = request_handler_.CountTable(context_ptr_, collection_name, count); if (!status.ok()) { return status; } IndexParam index_param; - status = request_handler_.DescribeIndex(context_ptr_, table_name, index_param); + status = request_handler_.DescribeIndex(context_ptr_, collection_name, index_param); if (!status.ok()) { return status; } - json_out["table_name"] = schema.table_name_; + json_out["collection_name"] = schema.table_name_; json_out["dimension"] = schema.dimension_; json_out["index_file_size"] = schema.index_file_size_; json_out["index"] = IndexMap.at(engine::EngineType(index_param.index_type_)); @@ -218,15 +238,15 @@ WebRequestHandler::GetTableMetaInfo(const std::string& table_name, nlohmann::jso } Status -WebRequestHandler::GetTableStat(const std::string& table_name, nlohmann::json& json_out) { - struct TableInfo table_info; - auto status = request_handler_.ShowTableInfo(context_ptr_, table_name, table_info); +WebRequestHandler::GetTableStat(const std::string& collection_name, nlohmann::json& json_out) { + struct TableInfo collection_info; + auto status = request_handler_.ShowTableInfo(context_ptr_, collection_name, collection_info); if (status.ok()) { - json_out["count"] = table_info.total_row_num_; + json_out["count"] = collection_info.total_row_num_; std::vector par_stat_json; - for (auto& par : table_info.partitions_stat_) { + for (auto& par : collection_info.partitions_stat_) { nlohmann::json par_json; ParsePartitionStat(par, par_json); par_stat_json.push_back(par_json); @@ -238,10 +258,10 @@ WebRequestHandler::GetTableStat(const std::string& table_name, nlohmann::json& j } Status -WebRequestHandler::GetSegmentVectors(const std::string& table_name, const std::string& segment_name, int64_t page_size, - int64_t offset, nlohmann::json& json_out) { +WebRequestHandler::GetSegmentVectors(const std::string& collection_name, const std::string& segment_name, + int64_t page_size, int64_t offset, nlohmann::json& json_out) { std::vector vector_ids; - auto status = request_handler_.GetVectorIDs(context_ptr_, table_name, segment_name, vector_ids); + auto status = request_handler_.GetVectorIDs(context_ptr_, collection_name, segment_name, vector_ids); if (!status.ok()) { return status; } @@ -251,7 +271,7 @@ WebRequestHandler::GetSegmentVectors(const std::string& table_name, const std::s auto ids = std::vector(vector_ids.begin() + ids_begin, vector_ids.begin() + ids_end); nlohmann::json vectors_json; - status = GetVectorsByIDs(table_name, ids, vectors_json); + status = GetVectorsByIDs(collection_name, ids, vectors_json); nlohmann::json result_json; if (vectors_json.empty()) { @@ -267,10 +287,10 @@ WebRequestHandler::GetSegmentVectors(const std::string& table_name, const std::s } Status -WebRequestHandler::GetSegmentIds(const std::string& table_name, const std::string& segment_name, int64_t page_size, +WebRequestHandler::GetSegmentIds(const std::string& collection_name, const std::string& segment_name, int64_t page_size, int64_t offset, nlohmann::json& json_out) { std::vector vector_ids; - auto status = request_handler_.GetVectorIDs(context_ptr_, table_name, segment_name, vector_ids); + auto status = request_handler_.GetVectorIDs(context_ptr_, collection_name, segment_name, vector_ids); if (status.ok()) { auto ids_begin = std::min(vector_ids.size(), (size_t)offset); auto ids_end = std::min(vector_ids.size(), (size_t)(offset + page_size)); @@ -310,12 +330,12 @@ WebRequestHandler::Cmd(const std::string& cmd, std::string& result_str) { Status WebRequestHandler::PreLoadTable(const nlohmann::json& json, std::string& result_str) { - if (!json.contains("table_name")) { - return Status(BODY_FIELD_LOSS, "Field \"load\" must contains table_name"); + if (!json.contains("collection_name")) { + return Status(BODY_FIELD_LOSS, "Field \"load\" must contains collection_name"); } - auto table_name = json["table_name"]; - auto status = request_handler_.PreloadTable(context_ptr_, table_name.get()); + auto collection_name = json["collection_name"]; + auto status = request_handler_.PreloadTable(context_ptr_, collection_name.get()); if (status.ok()) { nlohmann::json result; AddStatusToJson(result, status.code(), status.message()); @@ -327,17 +347,17 @@ WebRequestHandler::PreLoadTable(const nlohmann::json& json, std::string& result_ Status WebRequestHandler::Flush(const nlohmann::json& json, std::string& result_str) { - if (!json.contains("table_names")) { - return Status(BODY_FIELD_LOSS, "Field \"flush\" must contains table_names"); + if (!json.contains("collection_names")) { + return Status(BODY_FIELD_LOSS, "Field \"flush\" must contains collection_names"); } - auto table_names = json["table_names"]; - if (!table_names.is_array()) { - return Status(BODY_FIELD_LOSS, "Field \"table_names\" must be and array"); + auto collection_names = json["collection_names"]; + if (!collection_names.is_array()) { + return Status(BODY_FIELD_LOSS, "Field \"collection_names\" must be and array"); } std::vector names; - for (auto& name : table_names) { + for (auto& name : collection_names) { names.emplace_back(name.get()); } @@ -353,16 +373,16 @@ WebRequestHandler::Flush(const nlohmann::json& json, std::string& result_str) { Status WebRequestHandler::Compact(const nlohmann::json& json, std::string& result_str) { - if (!json.contains("table_name")) { - return Status(BODY_FIELD_LOSS, "Field \"compact\" must contains table_names"); + if (!json.contains("collection_name")) { + return Status(BODY_FIELD_LOSS, "Field \"compact\" must contains collection_names"); } - auto table_name = json["table_name"]; - if (!table_name.is_string()) { - return Status(BODY_FIELD_LOSS, "Field \"table_names\" must be a string"); + auto collection_name = json["collection_name"]; + if (!collection_name.is_string()) { + return Status(BODY_FIELD_LOSS, "Field \"collection_names\" must be a string"); } - auto name = table_name.get(); + auto name = collection_name.get(); auto status = request_handler_.Compact(context_ptr_, name); @@ -463,7 +483,7 @@ WebRequestHandler::SetConfig(const nlohmann::json& json, std::string& result_str } Status -WebRequestHandler::Search(const std::string& table_name, const nlohmann::json& json, std::string& result_str) { +WebRequestHandler::Search(const std::string& collection_name, const nlohmann::json& json, std::string& result_str) { if (!json.contains("topk")) { return Status(BODY_FIELD_LOSS, "Field \'topk\' is required"); } @@ -497,7 +517,7 @@ WebRequestHandler::Search(const std::string& table_name, const nlohmann::json& j } bool bin_flag = false; - auto status = IsBinaryTable(table_name, bin_flag); + auto status = IsBinaryTable(collection_name, bin_flag); if (!status.ok()) { return status; } @@ -513,7 +533,7 @@ WebRequestHandler::Search(const std::string& table_name, const nlohmann::json& j } TopKQueryResult result; - status = request_handler_.Search(context_ptr_, table_name, vectors_data, topk, json["params"], partition_tags, + status = request_handler_.Search(context_ptr_, collection_name, vectors_data, topk, json["params"], partition_tags, file_id_vec, result); if (!status.ok()) { @@ -547,7 +567,8 @@ WebRequestHandler::Search(const std::string& table_name, const nlohmann::json& j } Status -WebRequestHandler::DeleteByIDs(const std::string& table_name, const nlohmann::json& json, std::string& result_str) { +WebRequestHandler::DeleteByIDs(const std::string& collection_name, const nlohmann::json& json, + std::string& result_str) { std::vector vector_ids; if (!json.contains("ids")) { return Status(BODY_FIELD_LOSS, "Field \"delete\" must contains \"ids\""); @@ -565,7 +586,7 @@ WebRequestHandler::DeleteByIDs(const std::string& table_name, const nlohmann::js vector_ids.emplace_back(std::stol(id_str)); } - auto status = request_handler_.DeleteByID(context_ptr_, table_name, vector_ids); + auto status = request_handler_.DeleteByID(context_ptr_, collection_name, vector_ids); nlohmann::json result_json; AddStatusToJson(result_json, status.code(), status.message()); @@ -575,13 +596,13 @@ WebRequestHandler::DeleteByIDs(const std::string& table_name, const nlohmann::js } Status -WebRequestHandler::GetVectorsByIDs(const std::string& table_name, const std::vector& ids, +WebRequestHandler::GetVectorsByIDs(const std::string& collection_name, const std::vector& ids, nlohmann::json& json_out) { std::vector vector_batch; for (size_t i = 0; i < ids.size(); i++) { auto vec_ids = std::vector(ids.begin() + i, ids.begin() + i + 1); engine::VectorsData vectors_data; - auto status = request_handler_.GetVectorByID(context_ptr_, table_name, vec_ids, vectors_data); + auto status = request_handler_.GetVectorByID(context_ptr_, collection_name, vec_ids, vectors_data); if (!status.ok()) { return status; } @@ -589,7 +610,7 @@ WebRequestHandler::GetVectorsByIDs(const std::string& table_name, const std::vec } bool bin; - auto status = IsBinaryTable(table_name, bin); + auto status = IsBinaryTable(collection_name, bin); if (!status.ok()) { return status; } @@ -879,30 +900,31 @@ WebRequestHandler::SetGpuConfig(const GPUConfigDto::ObjectWrapper& gpu_config_dt * Table { */ StatusDto::ObjectWrapper -WebRequestHandler::CreateTable(const TableRequestDto::ObjectWrapper& table_schema) { - if (nullptr == table_schema->table_name.get()) { - RETURN_STATUS_DTO(BODY_FIELD_LOSS, "Field \'table_name\' is missing") +WebRequestHandler::CreateTable(const TableRequestDto::ObjectWrapper& collection_schema) { + if (nullptr == collection_schema->collection_name.get()) { + RETURN_STATUS_DTO(BODY_FIELD_LOSS, "Field \'collection_name\' is missing") } - if (nullptr == table_schema->dimension.get()) { + if (nullptr == collection_schema->dimension.get()) { RETURN_STATUS_DTO(BODY_FIELD_LOSS, "Field \'dimension\' is missing") } - if (nullptr == table_schema->index_file_size.get()) { + if (nullptr == collection_schema->index_file_size.get()) { RETURN_STATUS_DTO(BODY_FIELD_LOSS, "Field \'index_file_size\' is missing") } - if (nullptr == table_schema->metric_type.get()) { + if (nullptr == collection_schema->metric_type.get()) { RETURN_STATUS_DTO(BODY_FIELD_LOSS, "Field \'metric_type\' is missing") } - if (MetricNameMap.find(table_schema->metric_type->std_str()) == MetricNameMap.end()) { + if (MetricNameMap.find(collection_schema->metric_type->std_str()) == MetricNameMap.end()) { RETURN_STATUS_DTO(ILLEGAL_METRIC_TYPE, "metric_type is illegal") } - auto status = request_handler_.CreateTable( - context_ptr_, table_schema->table_name->std_str(), table_schema->dimension, table_schema->index_file_size, - static_cast(MetricNameMap.at(table_schema->metric_type->std_str()))); + auto status = + request_handler_.CreateTable(context_ptr_, collection_schema->collection_name->std_str(), + collection_schema->dimension, collection_schema->index_file_size, + static_cast(MetricNameMap.at(collection_schema->metric_type->std_str()))); ASSIGN_RETURN_STATUS_DTO(status) } @@ -926,45 +948,41 @@ WebRequestHandler::ShowTables(const OQueryParams& query_params, OString& result) } bool all_required = false; - auto required = query_params.get("all_required"); - if (nullptr != required.get()) { - auto required_str = required->std_str(); - if (!ValidationUtil::ValidateStringIsBool(required_str).ok()) { - RETURN_STATUS_DTO(ILLEGAL_QUERY_PARAM, "Query param \'all_required\' must be a bool") - } - all_required = required_str == "True" || required_str == "true"; + ParseQueryBool(query_params, "all_required", all_required); + if (!status.ok()) { + RETURN_STATUS_DTO(status.code(), status.message().c_str()); } - std::vector tables; - status = request_handler_.ShowTables(context_ptr_, tables); + std::vector collections; + status = request_handler_.ShowTables(context_ptr_, collections); if (!status.ok()) { ASSIGN_RETURN_STATUS_DTO(status) } if (all_required) { offset = 0; - page_size = tables.size(); + page_size = collections.size(); } else { - offset = std::min((size_t)offset, tables.size()); - page_size = std::min(tables.size() - offset, (size_t)page_size); + offset = std::min((size_t)offset, collections.size()); + page_size = std::min(collections.size() - offset, (size_t)page_size); } - nlohmann::json tables_json; + nlohmann::json collections_json; for (int64_t i = offset; i < page_size + offset; i++) { - nlohmann::json table_json; - status = GetTableMetaInfo(tables.at(i), table_json); + nlohmann::json collection_json; + status = GetTableMetaInfo(collections.at(i), collection_json); if (!status.ok()) { ASSIGN_RETURN_STATUS_DTO(status) } - tables_json.push_back(table_json); + collections_json.push_back(collection_json); } nlohmann::json result_json; - result_json["count"] = tables.size(); - if (tables_json.empty()) { - result_json["tables"] = std::vector(); + result_json["count"] = collections.size(); + if (collections_json.empty()) { + result_json["collections"] = std::vector(); } else { - result_json["tables"] = tables_json; + result_json["collections"] = collections_json; } result = result_json.dump().c_str(); @@ -973,9 +991,9 @@ WebRequestHandler::ShowTables(const OQueryParams& query_params, OString& result) } StatusDto::ObjectWrapper -WebRequestHandler::GetTable(const OString& table_name, const OQueryParams& query_params, OString& result) { - if (nullptr == table_name.get()) { - RETURN_STATUS_DTO(PATH_PARAM_LOSS, "Path param \'table_name\' is required!"); +WebRequestHandler::GetTable(const OString& collection_name, const OQueryParams& query_params, OString& result) { + if (nullptr == collection_name.get()) { + RETURN_STATUS_DTO(PATH_PARAM_LOSS, "Path param \'collection_name\' is required!"); } std::string stat; @@ -986,11 +1004,11 @@ WebRequestHandler::GetTable(const OString& table_name, const OQueryParams& query if (!stat.empty() && stat == "stat") { nlohmann::json json; - status = GetTableStat(table_name->std_str(), json); + status = GetTableStat(collection_name->std_str(), json); result = status.ok() ? json.dump().c_str() : "NULL"; } else { nlohmann::json json; - status = GetTableMetaInfo(table_name->std_str(), json); + status = GetTableMetaInfo(collection_name->std_str(), json); result = status.ok() ? json.dump().c_str() : "NULL"; } @@ -998,8 +1016,8 @@ WebRequestHandler::GetTable(const OString& table_name, const OQueryParams& query } StatusDto::ObjectWrapper -WebRequestHandler::DropTable(const OString& table_name) { - auto status = request_handler_.DropTable(context_ptr_, table_name->std_str()); +WebRequestHandler::DropTable(const OString& collection_name) { + auto status = request_handler_.DropTable(context_ptr_, collection_name->std_str()); ASSIGN_RETURN_STATUS_DTO(status) } @@ -1035,9 +1053,9 @@ WebRequestHandler::CreateIndex(const OString& table_name, const OString& body) { } StatusDto::ObjectWrapper -WebRequestHandler::GetIndex(const OString& table_name, OString& result) { +WebRequestHandler::GetIndex(const OString& collection_name, OString& result) { IndexParam param; - auto status = request_handler_.DescribeIndex(context_ptr_, table_name->std_str(), param); + auto status = request_handler_.DescribeIndex(context_ptr_, collection_name->std_str(), param); if (status.ok()) { nlohmann::json json_out; @@ -1051,8 +1069,8 @@ WebRequestHandler::GetIndex(const OString& table_name, OString& result) { } StatusDto::ObjectWrapper -WebRequestHandler::DropIndex(const OString& table_name) { - auto status = request_handler_.DropIndex(context_ptr_, table_name->std_str()); +WebRequestHandler::DropIndex(const OString& collection_name) { + auto status = request_handler_.DropIndex(context_ptr_, collection_name->std_str()); ASSIGN_RETURN_STATUS_DTO(status) } @@ -1062,19 +1080,19 @@ WebRequestHandler::DropIndex(const OString& table_name) { * Partition { */ StatusDto::ObjectWrapper -WebRequestHandler::CreatePartition(const OString& table_name, const PartitionRequestDto::ObjectWrapper& param) { +WebRequestHandler::CreatePartition(const OString& collection_name, const PartitionRequestDto::ObjectWrapper& param) { if (nullptr == param->partition_tag.get()) { RETURN_STATUS_DTO(BODY_FIELD_LOSS, "Field \'partition_tag\' is required") } auto status = - request_handler_.CreatePartition(context_ptr_, table_name->std_str(), param->partition_tag->std_str()); + request_handler_.CreatePartition(context_ptr_, collection_name->std_str(), param->partition_tag->std_str()); ASSIGN_RETURN_STATUS_DTO(status) } StatusDto::ObjectWrapper -WebRequestHandler::ShowPartitions(const OString& table_name, const OQueryParams& query_params, +WebRequestHandler::ShowPartitions(const OString& collection_name, const OQueryParams& query_params, PartitionListDto::ObjectWrapper& partition_list_dto) { int64_t offset = 0; auto status = ParseQueryInteger(query_params, "offset", offset); @@ -1104,7 +1122,7 @@ WebRequestHandler::ShowPartitions(const OString& table_name, const OQueryParams& } std::vector partitions; - status = request_handler_.ShowPartitions(context_ptr_, table_name->std_str(), partitions); + status = request_handler_.ShowPartitions(context_ptr_, collection_name->std_str(), partitions); if (!status.ok()) { ASSIGN_RETURN_STATUS_DTO(status) } @@ -1132,7 +1150,7 @@ WebRequestHandler::ShowPartitions(const OString& table_name, const OQueryParams& } StatusDto::ObjectWrapper -WebRequestHandler::DropPartition(const OString& table_name, const OString& body) { +WebRequestHandler::DropPartition(const OString& collection_name, const OString& body) { std::string tag; try { auto json = nlohmann::json::parse(body->std_str()); @@ -1142,7 +1160,7 @@ WebRequestHandler::DropPartition(const OString& table_name, const OString& body) } catch (nlohmann::detail::type_error& e) { RETURN_STATUS_DTO(BODY_PARSE_FAIL, e.what()) } - auto status = request_handler_.DropPartition(context_ptr_, table_name->std_str(), tag); + auto status = request_handler_.DropPartition(context_ptr_, collection_name->std_str(), tag); ASSIGN_RETURN_STATUS_DTO(status) } @@ -1152,7 +1170,7 @@ WebRequestHandler::DropPartition(const OString& table_name, const OString& body) * Segment { */ StatusDto::ObjectWrapper -WebRequestHandler::ShowSegments(const OString& table_name, const OQueryParams& query_params, OString& response) { +WebRequestHandler::ShowSegments(const OString& collection_name, const OQueryParams& query_params, OString& response) { int64_t offset = 0; auto status = ParseQueryInteger(query_params, "offset", offset); if (!status.ok()) { @@ -1185,7 +1203,7 @@ WebRequestHandler::ShowSegments(const OString& table_name, const OQueryParams& q } TableInfo info; - status = request_handler_.ShowTableInfo(context_ptr_, table_name->std_str(), info); + status = request_handler_.ShowTableInfo(context_ptr_, collection_name->std_str(), info); if (!status.ok()) { ASSIGN_RETURN_STATUS_DTO(status) } @@ -1236,7 +1254,7 @@ WebRequestHandler::ShowSegments(const OString& table_name, const OQueryParams& q } StatusDto::ObjectWrapper -WebRequestHandler::GetSegmentInfo(const OString& table_name, const OString& segment_name, const OString& info, +WebRequestHandler::GetSegmentInfo(const OString& collection_name, const OString& segment_name, const OString& info, const OQueryParams& query_params, OString& result) { int64_t offset = 0; auto status = ParseQueryInteger(query_params, "offset", offset); @@ -1260,10 +1278,10 @@ WebRequestHandler::GetSegmentInfo(const OString& table_name, const OString& segm nlohmann::json json; // Get vectors if (re == "vectors") { - status = GetSegmentVectors(table_name->std_str(), segment_name->std_str(), page_size, offset, json); + status = GetSegmentVectors(collection_name->std_str(), segment_name->std_str(), page_size, offset, json); // Get vector ids } else if (re == "ids") { - status = GetSegmentIds(table_name->std_str(), segment_name->std_str(), page_size, offset, json); + status = GetSegmentIds(collection_name->std_str(), segment_name->std_str(), page_size, offset, json); } result = status.ok() ? json.dump().c_str() : "NULL"; @@ -1276,14 +1294,14 @@ WebRequestHandler::GetSegmentInfo(const OString& table_name, const OString& segm * Vector { */ StatusDto::ObjectWrapper -WebRequestHandler::Insert(const OString& table_name, const OString& body, VectorIdsDto::ObjectWrapper& ids_dto) { +WebRequestHandler::Insert(const OString& collection_name, const OString& body, VectorIdsDto::ObjectWrapper& ids_dto) { if (nullptr == body.get() || body->getSize() == 0) { RETURN_STATUS_DTO(BODY_FIELD_LOSS, "Request payload is required.") } // step 1: copy vectors bool bin_flag; - auto status = IsBinaryTable(table_name->std_str(), bin_flag); + auto status = IsBinaryTable(collection_name->std_str(), bin_flag); if (!status.ok()) { ASSIGN_RETURN_STATUS_DTO(status) } @@ -1318,7 +1336,7 @@ WebRequestHandler::Insert(const OString& table_name, const OString& body, Vector } // step 4: construct result - status = request_handler_.Insert(context_ptr_, table_name->std_str(), vectors, tag); + status = request_handler_.Insert(context_ptr_, collection_name->std_str(), vectors, tag); if (status.ok()) { ids_dto->ids = ids_dto->ids->createShared(); for (auto& id : vectors.id_array_) { @@ -1330,7 +1348,7 @@ WebRequestHandler::Insert(const OString& table_name, const OString& body, Vector } StatusDto::ObjectWrapper -WebRequestHandler::GetVector(const OString& table_name, const OQueryParams& query_params, OString& response) { +WebRequestHandler::GetVector(const OString& collection_name, const OQueryParams& query_params, OString& response) { int64_t id = 0; auto status = ParseQueryInteger(query_params, "id", id, false); if (!status.ok()) { @@ -1340,7 +1358,7 @@ WebRequestHandler::GetVector(const OString& table_name, const OQueryParams& quer std::vector ids = {id}; engine::VectorsData vectors; nlohmann::json vectors_json; - status = GetVectorsByIDs(table_name->std_str(), ids, vectors_json); + status = GetVectorsByIDs(collection_name->std_str(), ids, vectors_json); if (!status.ok()) { response = "NULL"; ASSIGN_RETURN_STATUS_DTO(status) @@ -1360,7 +1378,7 @@ WebRequestHandler::GetVector(const OString& table_name, const OQueryParams& quer } StatusDto::ObjectWrapper -WebRequestHandler::VectorsOp(const OString& table_name, const OString& payload, OString& response) { +WebRequestHandler::VectorsOp(const OString& collection_name, const OString& payload, OString& response) { auto status = Status::OK(); std::string result_str; @@ -1368,9 +1386,9 @@ WebRequestHandler::VectorsOp(const OString& table_name, const OString& payload, nlohmann::json payload_json = nlohmann::json::parse(payload->std_str()); if (payload_json.contains("delete")) { - status = DeleteByIDs(table_name->std_str(), payload_json["delete"], result_str); + status = DeleteByIDs(collection_name->std_str(), payload_json["delete"], result_str); } else if (payload_json.contains("search")) { - status = Search(table_name->std_str(), payload_json["search"], result_str); + status = Search(collection_name->std_str(), payload_json["search"], result_str); } else { status = Status(ILLEGAL_BODY, "Unknown body"); } diff --git a/core/src/server/web_impl/handler/WebRequestHandler.h b/core/src/server/web_impl/handler/WebRequestHandler.h index c6673984304c11bd00122e68712fbd810dfaec3d..d3e47affb9ccc80f7eb50d9673768bd8f25ca9a4 100644 --- a/core/src/server/web_impl/handler/WebRequestHandler.h +++ b/core/src/server/web_impl/handler/WebRequestHandler.h @@ -84,6 +84,9 @@ class WebRequestHandler { Status ParseQueryStr(const OQueryParams& query_params, const std::string& key, std::string& value, bool nullable = true); + Status + ParseQueryBool(const OQueryParams& query_params, const std::string& key, bool& value, bool nullable = true); + private: void AddStatusToJson(nlohmann::json& json, int64_t code, const std::string& msg); diff --git a/core/src/utils/StringHelpFunctions.cpp b/core/src/utils/StringHelpFunctions.cpp index 05f7679363763ec09f8c5beb3ffb2080748f0982..cd2a74712b381c4c72be4640d6f2f2dfcb9b1208 100644 --- a/core/src/utils/StringHelpFunctions.cpp +++ b/core/src/utils/StringHelpFunctions.cpp @@ -12,9 +12,12 @@ #include "utils/StringHelpFunctions.h" #include +#include #include #include +#include "utils/ValidationUtil.h" + namespace milvus { namespace server { @@ -148,11 +151,21 @@ StringHelpFunctions::IsRegexMatch(const std::string& target_str, const std::stri // regex match std::regex pattern(pattern_str); std::smatch results; - if (std::regex_match(target_str, results, pattern)) { - return true; - } else { - return false; + return std::regex_match(target_str, results, pattern); +} + +Status +StringHelpFunctions::ConvertToBoolean(const std::string& str, bool& value) { + auto status = ValidationUtil::ValidateStringIsBool(str); + if (!status.ok()) { + return status; } + + std::string s = str; + std::transform(s.begin(), s.end(), s.begin(), ::tolower); + value = s == "true" || s == "on" || s == "yes" || s == "1"; + + return Status::OK(); } } // namespace server diff --git a/core/src/utils/StringHelpFunctions.h b/core/src/utils/StringHelpFunctions.h index 85dc5b95552ae301606f370f83a5c97e4c9aaaf7..0f1226a8c21d78db4a69b4e1646527e21cb92ebe 100644 --- a/core/src/utils/StringHelpFunctions.h +++ b/core/src/utils/StringHelpFunctions.h @@ -64,6 +64,12 @@ class StringHelpFunctions { // regex grammar reference: http://www.cplusplus.com/reference/regex/ECMAScript/ static bool IsRegexMatch(const std::string& target_str, const std::string& pattern); + + // conversion rules refer to ValidationUtil::ValidateStringIsBool() + // "true", "on", "yes", "1" ==> true + // "false", "off", "no", "0", "" ==> false + static Status + ConvertToBoolean(const std::string& str, bool& value); }; } // namespace server diff --git a/core/unittest/server/test_web.cpp b/core/unittest/server/test_web.cpp index e5d6b70963a1da1cb6728caf14c28b8b7fe26997..073e08ec91eaae4ed140a888bbdd1bb9530854b5 100644 --- a/core/unittest/server/test_web.cpp +++ b/core/unittest/server/test_web.cpp @@ -41,6 +41,7 @@ #include "server/web_impl/handler/WebRequestHandler.h" #include "unittest/server/utils.h" #include "utils/CommonUtil.h" +#include "version.h" #include "wrapper/VecIndex.h" @@ -237,14 +238,14 @@ class WebHandlerTest : public testing::Test { protected: void - GenTable(const std::string& table_name, int64_t dim, int64_t index_size, const std::string& metric) { - auto table_dto = milvus::server::web::TableRequestDto::createShared(); - table_dto->table_name = table_name.c_str(); - table_dto->dimension = dim; - table_dto->index_file_size = index_size; - table_dto->metric_type = metric.c_str(); - - auto status_dto = handler->CreateTable(table_dto); + GenTable(const std::string& collection_name, int64_t dim, int64_t index_size, const std::string& metric) { + auto collection_dto = milvus::server::web::TableRequestDto::createShared(); + collection_dto->collection_name = collection_name.c_str(); + collection_dto->dimension = dim; + collection_dto->index_file_size = index_size; + collection_dto->metric_type = metric.c_str(); + + handler->CreateTable(collection_dto); } protected: @@ -256,66 +257,66 @@ class WebHandlerTest : public testing::Test { TEST_F(WebHandlerTest, TABLE) { handler->RegisterRequestHandler(milvus::server::RequestHandler()); - auto table_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); + auto collection_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); - auto table_dto = milvus::server::web::TableRequestDto::createShared(); - table_dto->table_name = table_name; - table_dto->dimension = TABLE_DIM + 100000; - table_dto->index_file_size = INDEX_FILE_SIZE; - table_dto->metric_type = "L2"; + auto collection_dto = milvus::server::web::TableRequestDto::createShared(); + collection_dto->collection_name = collection_name; + collection_dto->dimension = TABLE_DIM + 100000; + collection_dto->index_file_size = INDEX_FILE_SIZE; + collection_dto->metric_type = "L2"; // invalid dimension - auto status_dto = handler->CreateTable(table_dto); + auto status_dto = handler->CreateTable(collection_dto); ASSERT_EQ(StatusCode::ILLEGAL_DIMENSION, status_dto->code->getValue()); // invalid index file size - table_dto->dimension = TABLE_DIM; - table_dto->index_file_size = -1; - status_dto = handler->CreateTable(table_dto); + collection_dto->dimension = TABLE_DIM; + collection_dto->index_file_size = -1; + status_dto = handler->CreateTable(collection_dto); ASSERT_EQ(StatusCode::ILLEGAL_ARGUMENT, status_dto->code->getValue()); // invalid metric type - table_dto->index_file_size = INDEX_FILE_SIZE; - table_dto->metric_type = "L1"; - status_dto = handler->CreateTable(table_dto); + collection_dto->index_file_size = INDEX_FILE_SIZE; + collection_dto->metric_type = "L1"; + status_dto = handler->CreateTable(collection_dto); ASSERT_EQ(StatusCode::ILLEGAL_METRIC_TYPE, status_dto->code->getValue()); - // create table successfully - table_dto->metric_type = "L2"; - status_dto = handler->CreateTable(table_dto); + // create collection successfully + collection_dto->metric_type = "L2"; + status_dto = handler->CreateTable(collection_dto); ASSERT_EQ(0, status_dto->code->getValue()); sleep(3); - status_dto = handler->DropTable(table_name); + status_dto = handler->DropTable(collection_name); ASSERT_EQ(0, status_dto->code->getValue()); - // drop table which not exists. - status_dto = handler->DropTable(table_name + "57575yfhfdhfhdh436gdsgpppdgsgv3233"); + // drop collection which not exists. + status_dto = handler->DropTable(collection_name + "57575yfhfdhfhdh436gdsgpppdgsgv3233"); ASSERT_EQ(StatusCode::TABLE_NOT_EXISTS, status_dto->code->getValue()); } TEST_F(WebHandlerTest, HAS_TABLE_TEST) { handler->RegisterRequestHandler(milvus::server::RequestHandler()); - auto table_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); + auto collection_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); - GenTable(table_name->std_str(), 10, 10, "L2"); + GenTable(collection_name->std_str(), 10, 10, "L2"); milvus::server::web::OQueryParams query_params; OString response; - auto status_dto = handler->GetTable(table_name, query_params, response); + auto status_dto = handler->GetTable(collection_name, query_params, response); ASSERT_EQ(0, status_dto->code->getValue()); } TEST_F(WebHandlerTest, GET_TABLE) { handler->RegisterRequestHandler(milvus::server::RequestHandler()); - auto table_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); - GenTable(table_name->std_str(), 10, 10, "L2"); + auto collection_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); + GenTable(collection_name->std_str(), 10, 10, "L2"); milvus::server::web::OQueryParams query_params; OString result; - auto status_dto = handler->GetTable(table_name, query_params, result); + auto status_dto = handler->GetTable(collection_name, query_params, result); ASSERT_EQ(0, status_dto->code->getValue()); auto result_json = nlohmann::json::parse(result->std_str()); @@ -327,13 +328,13 @@ TEST_F(WebHandlerTest, GET_TABLE) { TEST_F(WebHandlerTest, INSERT_COUNT) { handler->RegisterRequestHandler(milvus::server::RequestHandler()); - auto table_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); - GenTable(table_name->std_str(), 16, 10, "L2"); + auto collection_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); + GenTable(collection_name->std_str(), 16, 10, "L2"); nlohmann::json body_json; body_json["vectors"] = RandomRecordsJson(16, 1000); auto ids_dto = milvus::server::web::VectorIdsDto::createShared(); - auto status_dto = handler->Insert(table_name, body_json.dump().c_str(), ids_dto); + auto status_dto = handler->Insert(collection_name, body_json.dump().c_str(), ids_dto); ASSERT_EQ(0, status_dto->code->getValue()); ASSERT_EQ(1000, ids_dto->ids->count()); @@ -342,7 +343,7 @@ TEST_F(WebHandlerTest, INSERT_COUNT) { milvus::server::web::OQueryParams query_params; query_params.put("fields", "num"); OString result; - status_dto = handler->GetTable(table_name, query_params, result); + status_dto = handler->GetTable(collection_name, query_params, result); ASSERT_EQ(0, status_dto->code->getValue()); auto result_json = nlohmann::json::parse(result->std_str()); @@ -352,80 +353,80 @@ TEST_F(WebHandlerTest, INSERT_COUNT) { TEST_F(WebHandlerTest, INDEX) { handler->RegisterRequestHandler(milvus::server::RequestHandler()); - auto table_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); - GenTable(table_name->std_str(), 16, 10, "L2"); + auto collection_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); + GenTable(collection_name->std_str(), 16, 10, "L2"); nlohmann::json index_json; index_json["index_type"] = "FLAT"; index_json["params"] = nlohmann::json::parse("{ \"nlist\": 10 }"); - auto status_dto = handler->CreateIndex(table_name, index_json.dump().c_str()); + auto status_dto = handler->CreateIndex(collection_name, index_json.dump().c_str()); ASSERT_EQ(0, status_dto->code->getValue()); - status_dto = handler->DropIndex(table_name); + status_dto = handler->DropIndex(collection_name); ASSERT_EQ(0, status_dto->code->getValue()); // drop index - status_dto = handler->DropIndex(table_name); + status_dto = handler->DropIndex(collection_name); ASSERT_EQ(0, status_dto->code->getValue()); // invalid index_type index_json["index_type"] = "AAA"; - status_dto = handler->CreateIndex(table_name, index_json.dump().c_str()); + status_dto = handler->CreateIndex(collection_name, index_json.dump().c_str()); ASSERT_NE(0, status_dto->code->getValue()); ASSERT_EQ(StatusCode::ILLEGAL_INDEX_TYPE, status_dto->code->getValue()); // invalid nlist index_json["index_type"] = "IVFFLAT"; index_json["params"] = nlohmann::json::parse("{ \"nlist\": -1 }"); - status_dto = handler->CreateIndex(table_name, index_json.dump().c_str()); -// ASSERT_NE(0, status_dto->code->getValue()); -// ASSERT_EQ(StatusCode::ILLEGAL_NLIST, status_dto->code->getValue()); + status_dto = handler->CreateIndex(collection_name, index_json.dump().c_str()); + ASSERT_NE(0, status_dto->code->getValue()); + ASSERT_EQ(StatusCode::ILLEGAL_ARGUMENT, status_dto->code->getValue()); } TEST_F(WebHandlerTest, PARTITION) { handler->RegisterRequestHandler(milvus::server::RequestHandler()); - auto table_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); - GenTable(table_name->std_str(), 16, 10, "L2"); + auto collection_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); + GenTable(collection_name->std_str(), 16, 10, "L2"); auto partition_dto = milvus::server::web::PartitionRequestDto::createShared(); partition_dto->partition_tag = "test"; - auto status_dto = handler->CreatePartition(table_name, partition_dto); + auto status_dto = handler->CreatePartition(collection_name, partition_dto); ASSERT_EQ(0, status_dto->code->getValue()); auto partitions_dto = milvus::server::web::PartitionListDto::createShared(); OQueryParams query_params; query_params.put("offset", "0"); query_params.put("page_size", "10"); - status_dto = handler->ShowPartitions(table_name, query_params, partitions_dto); + status_dto = handler->ShowPartitions(collection_name, query_params, partitions_dto); ASSERT_EQ(milvus::server::web::SUCCESS, status_dto->code->getValue()); ASSERT_EQ(2, partitions_dto->partitions->count()); - status_dto = handler->DropPartition(table_name, "{\"partition_tag\": \"test\"}"); + status_dto = handler->DropPartition(collection_name, "{\"partition_tag\": \"test\"}"); ASSERT_EQ(0, status_dto->code->getValue()); // Show all partitions - status_dto = handler->ShowPartitions(table_name, query_params, partitions_dto); + status_dto = handler->ShowPartitions(collection_name, query_params, partitions_dto); ASSERT_EQ(milvus::server::web::SUCCESS, status_dto->code->getValue()); query_params.put("all_required", "true"); - status_dto = handler->ShowPartitions(table_name, query_params, partitions_dto); + status_dto = handler->ShowPartitions(collection_name, query_params, partitions_dto); ASSERT_EQ(milvus::server::web::SUCCESS, status_dto->code->getValue()); } TEST_F(WebHandlerTest, SEARCH) { handler->RegisterRequestHandler(milvus::server::RequestHandler()); - auto table_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); - GenTable(table_name->std_str(), TABLE_DIM, 10, "L2"); + auto collection_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); + GenTable(collection_name->std_str(), TABLE_DIM, 10, "L2"); nlohmann::json insert_json; insert_json["vectors"] = RandomRecordsJson(TABLE_DIM, 1000); auto ids_dto = milvus::server::web::VectorIdsDto::createShared(); - auto status_dto = handler->Insert(table_name, insert_json.dump().c_str(), ids_dto); + auto status_dto = handler->Insert(collection_name, insert_json.dump().c_str(), ids_dto); ASSERT_EQ(milvus::server::web::SUCCESS, status_dto->code->getValue()); nlohmann::json search_pram_json; @@ -437,7 +438,7 @@ TEST_F(WebHandlerTest, SEARCH) { search_json["search"] = search_pram_json; OString result = ""; - status_dto = handler->VectorsOp(table_name, search_json.dump().c_str(), result); + status_dto = handler->VectorsOp(collection_name, search_json.dump().c_str(), result); ASSERT_EQ(0, status_dto->code->getValue()) << status_dto->message->std_str(); } @@ -449,27 +450,28 @@ TEST_F(WebHandlerTest, SYSTEM_INFO) { auto status_dto = handler->SystemInfo("status", query_params, result); ASSERT_EQ(0, status_dto->code->getValue()); -// ASSERT_EQ("OK", cmd_dto->reply->std_str()); status_dto = handler->SystemInfo("version", query_params, result); ASSERT_EQ(0, status_dto->code->getValue()); -// ASSERT_EQ("0.7.0", cmd_dto->reply->std_str()); + auto result_json = nlohmann::json::parse(result->c_str()); + ASSERT_TRUE(result_json.contains("reply")); + ASSERT_EQ(MILVUS_VERSION, result_json["reply"].get()); } TEST_F(WebHandlerTest, FLUSH) { handler->RegisterRequestHandler(milvus::server::RequestHandler()); - auto table_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); - GenTable(table_name->std_str(), 16, 10, "L2"); + auto collection_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); + GenTable(collection_name->std_str(), 16, 10, "L2"); nlohmann::json body_json; body_json["vectors"] = RandomRecordsJson(16, 1000); auto ids_dto = milvus::server::web::VectorIdsDto::createShared(); - auto status_dto = handler->Insert(table_name, body_json.dump().c_str(), ids_dto); + auto status_dto = handler->Insert(collection_name, body_json.dump().c_str(), ids_dto); ASSERT_EQ(0, status_dto->code->getValue()) << status_dto->message->std_str(); nlohmann::json flush_json; - flush_json["flush"]["table_names"] = {table_name->std_str()}; + flush_json["flush"]["collection_names"] = {collection_name->std_str()}; OString result; status_dto = handler->SystemOp("task", flush_json.dump().c_str(), result); ASSERT_EQ(milvus::server::web::SUCCESS, status_dto->code->getValue()); @@ -478,17 +480,17 @@ TEST_F(WebHandlerTest, FLUSH) { TEST_F(WebHandlerTest, COMPACT) { handler->RegisterRequestHandler(milvus::server::RequestHandler()); - auto table_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); - GenTable(table_name->std_str(), 16, 10, "L2"); + auto collection_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); + GenTable(collection_name->std_str(), 16, 10, "L2"); nlohmann::json body_json; body_json["vectors"] = RandomRecordsJson(16, 1000); auto ids_dto = milvus::server::web::VectorIdsDto::createShared(); - auto status_dto = handler->Insert(table_name, body_json.dump().c_str(), ids_dto); + auto status_dto = handler->Insert(collection_name, body_json.dump().c_str(), ids_dto); ASSERT_EQ(0, status_dto->code->getValue()) << status_dto->message->std_str(); nlohmann::json compact_json; - compact_json["compact"]["table_name"] = table_name->std_str(); + compact_json["compact"]["collection_name"] = collection_name->std_str(); OString result; status_dto = handler->SystemOp("task", compact_json.dump().c_str(), result); ASSERT_EQ(milvus::server::web::SUCCESS, status_dto->code->getValue()); @@ -630,55 +632,55 @@ class TestClient : public oatpp::web::client::ApiClient { BODY_DTO(milvus::server::web::GPUConfigDto::ObjectWrapper, body)) #endif - API_CALL("OPTIONS", "/tables", optionsTables) + API_CALL("OPTIONS", "/collections", optionsTables) - API_CALL("POST", "/tables", createTable, BODY_DTO(milvus::server::web::TableRequestDto::ObjectWrapper, body)) + API_CALL("POST", "/collections", createTable, BODY_DTO(milvus::server::web::TableRequestDto::ObjectWrapper, body)) - API_CALL("GET", "/tables", showTables, QUERY(String, offset), QUERY(String, page_size)) + API_CALL("GET", "/collections", showTables, QUERY(String, offset), QUERY(String, page_size)) - API_CALL("OPTIONS", "/tables/{table_name}", optionsTable, PATH(String, table_name, "table_name")) + API_CALL("OPTIONS", "/collections/{collection_name}", optionsTable, PATH(String, collection_name, "collection_name")) - API_CALL("GET", "/tables/{table_name}", getTable, PATH(String, table_name, "table_name"), QUERY(String, info)) + API_CALL("GET", "/collections/{collection_name}", getTable, PATH(String, collection_name, "collection_name"), QUERY(String, info)) - API_CALL("DELETE", "/tables/{table_name}", dropTable, PATH(String, table_name, "table_name")) + API_CALL("DELETE", "/collections/{collection_name}", dropTable, PATH(String, collection_name, "collection_name")) - API_CALL("OPTIONS", "/tables/{table_name}/indexes", optionsIndexes, PATH(String, table_name, "table_name")) + API_CALL("OPTIONS", "/collections/{collection_name}/indexes", optionsIndexes, PATH(String, collection_name, "collection_name")) API_CALL("POST", "/tables/{table_name}/indexes", createIndex, PATH(String, table_name, "table_name"), BODY_STRING(OString, body)) - API_CALL("GET", "/tables/{table_name}/indexes", getIndex, PATH(String, table_name, "table_name")) + API_CALL("GET", "/collections/{collection_name}/indexes", getIndex, PATH(String, collection_name, "collection_name")) - API_CALL("DELETE", "/tables/{table_name}/indexes", dropIndex, PATH(String, table_name, "table_name")) + API_CALL("DELETE", "/collections/{collection_name}/indexes", dropIndex, PATH(String, collection_name, "collection_name")) - API_CALL("OPTIONS", "/tables/{table_name}/partitions", optionsPartitions, PATH(String, table_name, "table_name")) + API_CALL("OPTIONS", "/collections/{collection_name}/partitions", optionsPartitions, PATH(String, collection_name, "collection_name")) - API_CALL("POST", "/tables/{table_name}/partitions", createPartition, PATH(String, table_name, "table_name"), + API_CALL("POST", "/collections/{collection_name}/partitions", createPartition, PATH(String, collection_name, "collection_name"), BODY_DTO(milvus::server::web::PartitionRequestDto::ObjectWrapper, body)) - API_CALL("GET", "/tables/{table_name}/partitions", showPartitions, PATH(String, table_name, "table_name"), + API_CALL("GET", "/collections/{collection_name}/partitions", showPartitions, PATH(String, collection_name, "collection_name"), QUERY(String, offset), QUERY(String, page_size)) - API_CALL("DELETE", "/tables/{table_name}/partitions", dropPartition, - PATH(String, table_name, "table_name"), BODY_STRING(String, body)) + API_CALL("DELETE", "/collections/{collection_name}/partitions", dropPartition, + PATH(String, collection_name, "collection_name"), BODY_STRING(String, body)) - API_CALL("GET", "/tables/{table_name}/segments", showSegments, PATH(String, table_name, "table_name"), + API_CALL("GET", "/collections/{collection_name}/segments", showSegments, PATH(String, collection_name, "collection_name"), QUERY(String, offset), QUERY(String, page_size), QUERY(String, partition_tag)) - API_CALL("GET", "/tables/{table_name}/segments/{segment_name}/{info}", getSegmentInfo, - PATH(String, table_name, "table_name"), PATH(String, segment_name, "segment_name"), + API_CALL("GET", "/collections/{collection_name}/segments/{segment_name}/{info}", getSegmentInfo, + PATH(String, collection_name, "collection_name"), PATH(String, segment_name, "segment_name"), PATH(String, info, "info"), QUERY(String, offset), QUERY(String, page_size)) - API_CALL("OPTIONS", "/tables/{table_name}/vectors", optionsVectors, PATH(String, table_name, "table_name")) + API_CALL("OPTIONS", "/collections/{collection_name}/vectors", optionsVectors, PATH(String, collection_name, "collection_name")) - API_CALL("GET", "/tables/{table_name}/vectors", getVectors, - PATH(String, table_name, "table_name"), QUERY(String, id)) + API_CALL("GET", "/collections/{collection_name}/vectors", getVectors, + PATH(String, collection_name, "collection_name"), QUERY(String, id)) - API_CALL("POST", "/tables/{table_name}/vectors", insert, - PATH(String, table_name, "table_name"), BODY_STRING(String, body)) + API_CALL("POST", "/collections/{collection_name}/vectors", insert, + PATH(String, collection_name, "collection_name"), BODY_STRING(String, body)) - API_CALL("PUT", "/tables/{table_name}/vectors", vectorsOp, - PATH(String, table_name, "table_name"), BODY_STRING(String, body)) + API_CALL("PUT", "/collections/{collection_name}/vectors", vectorsOp, + PATH(String, collection_name, "collection_name"), BODY_STRING(String, body)) API_CALL("GET", "/system/{msg}", cmd, PATH(String, cmd_str, "msg"), QUERY(String, action), QUERY(String, target)) @@ -743,23 +745,23 @@ class WebControllerTest : public testing::Test { } void - GenTable(const OString& table_name, int64_t dim, int64_t index_size, const OString& metric) { - auto response = client_ptr->getTable(table_name, "", conncetion_ptr); + 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 table_dto = milvus::server::web::TableRequestDto::createShared(); - table_dto->table_name = table_name; - table_dto->dimension = dim; - table_dto->index_file_size = index_size; - table_dto->metric_type = metric; - client_ptr->createTable(table_dto, conncetion_ptr); + 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& table_name) { + FlushTable(const std::string& collection_name) { nlohmann::json flush_json; - flush_json["flush"]["table_names"] = {table_name}; + 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()); @@ -769,9 +771,9 @@ class WebControllerTest : public testing::Test { } milvus::Status - FlushTable(const OString& table_name) { + FlushTable(const OString& collection_name) { nlohmann::json flush_json; - flush_json["flush"]["table_names"] = {table_name->std_str()}; + 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()); @@ -781,7 +783,7 @@ class WebControllerTest : public testing::Test { } milvus::Status - InsertData(const OString& table_name, int64_t dim, int64_t count, std::string tag = "", bool bin = false) { + InsertData(const OString& collection_name, int64_t dim, int64_t count, std::string tag = "", bool bin = false) { nlohmann::json insert_json; if (bin) @@ -793,16 +795,16 @@ class WebControllerTest : public testing::Test { insert_json["partition_tag"] = tag; } - auto response = client_ptr->insert(table_name, insert_json.dump().c_str(), conncetion_ptr); + 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(table_name); + return FlushTable(collection_name); } milvus::Status - InsertData(const OString& table_name, int64_t dim, int64_t count, + 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; @@ -819,19 +821,19 @@ class WebControllerTest : public testing::Test { insert_json["partition_tag"] = tag; } - auto response = client_ptr->insert(table_name, insert_json.dump().c_str(), conncetion_ptr); + 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(table_name); + return FlushTable(collection_name); } milvus::Status - GenPartition(const OString& table_name, const OString& tag) { + 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(table_name, par_param); + 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()); } @@ -869,14 +871,14 @@ class WebControllerTest : public testing::Test { protected: void - GenTable(const std::string& table_name, int64_t dim, int64_t index_file_size, int64_t metric_type) { - auto table_dto = milvus::server::web::TableRequestDto::createShared(); - table_dto->table_name = OString(table_name.c_str()); - table_dto->dimension = dim; - table_dto->index_file_size = index_file_size; - table_dto->metric_type = metric_type; - - client_ptr->createTable(table_dto, conncetion_ptr); + 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); } }; @@ -899,85 +901,85 @@ TEST_F(WebControllerTest, OPTIONS) { response = client_ptr->optionsIndexes("test", conncetion_ptr); ASSERT_EQ(OStatus::CODE_204.code, response->getStatusCode()); - response = client_ptr->optionsPartitions("table_name", conncetion_ptr); + response = client_ptr->optionsPartitions("collection_name", conncetion_ptr); ASSERT_EQ(OStatus::CODE_204.code, response->getStatusCode()); - response = client_ptr->optionsTable("table", conncetion_ptr); + response = client_ptr->optionsTable("collection", conncetion_ptr); ASSERT_EQ(OStatus::CODE_204.code, response->getStatusCode()); response = client_ptr->optionsTables(conncetion_ptr); ASSERT_EQ(OStatus::CODE_204.code, response->getStatusCode()); - response = client_ptr->optionsVectors("table", conncetion_ptr); + response = client_ptr->optionsVectors("collection", conncetion_ptr); ASSERT_EQ(OStatus::CODE_204.code, response->getStatusCode()); } TEST_F(WebControllerTest, CREATE_TABLE) { - auto table_dto = milvus::server::web::TableRequestDto::createShared(); - auto response = client_ptr->createTable(table_dto, conncetion_ptr); + auto collection_dto = milvus::server::web::TableRequestDto::createShared(); + auto response = client_ptr->createTable(collection_dto, conncetion_ptr); ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()); auto error_dto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(milvus::server::web::StatusCode::BODY_FIELD_LOSS, error_dto->code) << error_dto->message->std_str(); - OString table_name = "web_test_create_table" + OString(RandomName().c_str()); + OString collection_name = "web_test_create_collection" + OString(RandomName().c_str()); - table_dto->table_name = table_name; - response = client_ptr->createTable(table_dto, conncetion_ptr); + collection_dto->collection_name = collection_name; + response = client_ptr->createTable(collection_dto, conncetion_ptr); ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()); error_dto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(milvus::server::web::StatusCode::BODY_FIELD_LOSS, error_dto->code) << error_dto->message->std_str(); - table_dto->dimension = 128; - table_dto->index_file_size = 10; - table_dto->metric_type = "L2"; + collection_dto->dimension = 128; + collection_dto->index_file_size = 10; + collection_dto->metric_type = "L2"; - response = client_ptr->createTable(table_dto, conncetion_ptr); + response = client_ptr->createTable(collection_dto, conncetion_ptr); ASSERT_EQ(OStatus::CODE_201.code, response->getStatusCode()); auto result_dto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(milvus::server::web::StatusCode::SUCCESS, result_dto->code->getValue()) << result_dto->message->std_str(); - // invalid table name - table_dto->table_name = "9090&*&()"; - response = client_ptr->createTable(table_dto, conncetion_ptr); + // invalid collection name + collection_dto->collection_name = "9090&*&()"; + response = client_ptr->createTable(collection_dto, conncetion_ptr); ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()); } TEST_F(WebControllerTest, GET_TABLE_META) { - OString table_name = "web_test_create_table" + OString(RandomName().c_str()); - GenTable(table_name, 10, 10, "L2"); + OString collection_name = "web_test_create_collection" + OString(RandomName().c_str()); + GenTable(collection_name, 10, 10, "L2"); OQueryParams params; - auto response = client_ptr->getTable(table_name, "", conncetion_ptr); + auto response = client_ptr->getTable(collection_name, "", conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()); auto result_dto = response->readBodyToDto(object_mapper.get()); - ASSERT_EQ(table_name->std_str(), result_dto->table_name->std_str()); + ASSERT_EQ(collection_name->std_str(), result_dto->collection_name->std_str()); ASSERT_EQ(10, result_dto->dimension); ASSERT_EQ("L2", result_dto->metric_type->std_str()); ASSERT_EQ(10, result_dto->index_file_size->getValue()); ASSERT_EQ("FLAT", result_dto->index->std_str()); - // invalid table name - table_name = "57474dgdfhdfhdh dgd"; - response = client_ptr->getTable(table_name, "", conncetion_ptr); + // invalid collection name + collection_name = "57474dgdfhdfhdh dgd"; + response = client_ptr->getTable(collection_name, "", conncetion_ptr); ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()); auto status_sto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(milvus::server::web::StatusCode::ILLEGAL_TABLE_NAME, status_sto->code->getValue()); - table_name = "test_table_not_found_000000000111010101002020203020aaaaa3030435"; - response = client_ptr->getTable(table_name, "", conncetion_ptr); + collection_name = "test_collection_not_found_000000000111010101002020203020aaaaa3030435"; + response = client_ptr->getTable(collection_name, "", conncetion_ptr); ASSERT_EQ(OStatus::CODE_404.code, response->getStatusCode()); } TEST_F(WebControllerTest, GET_TABLE_STAT) { - OString table_name = "web_test_get_table_stat" + OString(RandomName().c_str()); - GenTable(table_name, 128, 5, "L2"); + OString collection_name = "web_test_get_collection_stat" + OString(RandomName().c_str()); + GenTable(collection_name, 128, 5, "L2"); for (size_t i = 0; i < 5; i++) { - InsertData(table_name, 128, 1000); + InsertData(collection_name, 128, 1000); } - auto response = client_ptr->getTable(table_name, "stat", conncetion_ptr); + auto response = client_ptr->getTable(collection_name, "stat", conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()); auto result_json = nlohmann::json::parse(response->readBodyToString()->c_str()); ASSERT_TRUE(result_json.contains("count")); @@ -1001,13 +1003,13 @@ TEST_F(WebControllerTest, GET_TABLE_STAT) { } TEST_F(WebControllerTest, SHOW_TABLES) { - // test query table limit 1 + // test query collection limit 1 auto response = client_ptr->showTables("1", "1", conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()); auto result_dto = response->readBodyToDto(object_mapper.get()); ASSERT_GE(result_dto->count->getValue(), 0); - // test query table empty + // test query collection empty response = client_ptr->showTables("0", "0", conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()); @@ -1029,65 +1031,65 @@ TEST_F(WebControllerTest, SHOW_TABLES) { } TEST_F(WebControllerTest, DROP_TABLE) { - auto table_name = "table_drop_test" + OString(RandomName().c_str()); - GenTable(table_name, 128, 100, "L2"); + auto collection_name = "collection_drop_test" + OString(RandomName().c_str()); + GenTable(collection_name, 128, 100, "L2"); sleep(1); - auto response = client_ptr->dropTable(table_name, conncetion_ptr); + auto response = client_ptr->dropTable(collection_name, conncetion_ptr); ASSERT_EQ(OStatus::CODE_204.code, response->getStatusCode()); - table_name = "table_drop_test_not_exists_" + OString(RandomName().c_str()); - response = client_ptr->dropTable(table_name, conncetion_ptr); + collection_name = "collection_drop_test_not_exists_" + OString(RandomName().c_str()); + response = client_ptr->dropTable(collection_name, conncetion_ptr); ASSERT_EQ(OStatus::CODE_404.code, response->getStatusCode()); auto error_dto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(milvus::server::web::StatusCode::TABLE_NOT_EXISTS, error_dto->code->getValue()); } TEST_F(WebControllerTest, INSERT) { - auto table_name = "test_insert_table_test" + OString(RandomName().c_str()); + auto collection_name = "test_insert_collection_test" + OString(RandomName().c_str()); const int64_t dim = 64; - GenTable(table_name, dim, 100, "L2"); + GenTable(collection_name, dim, 100, "L2"); nlohmann::json insert_json; insert_json["vectors"] = RandomRecordsJson(dim, 20); - auto response = client_ptr->insert(table_name, insert_json.dump().c_str(), conncetion_ptr); + auto response = client_ptr->insert(collection_name, insert_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_201.code, response->getStatusCode()); auto result_dto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(20, result_dto->ids->count()); - response = client_ptr->insert(table_name + "ooowrweindexsgs", insert_json.dump().c_str(), conncetion_ptr); + response = client_ptr->insert(collection_name + "ooowrweindexsgs", insert_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_404.code, response->getStatusCode()); - response = client_ptr->dropTable(table_name, conncetion_ptr); + response = client_ptr->dropTable(collection_name, conncetion_ptr); ASSERT_EQ(OStatus::CODE_204.code, response->getStatusCode()); } TEST_F(WebControllerTest, INSERT_BIN) { - auto table_name = "test_insert_bin_table_test" + OString(RandomName().c_str()); + auto collection_name = "test_insert_bin_collection_test" + OString(RandomName().c_str()); const int64_t dim = 64; - GenTable(table_name, dim, 100, "HAMMING"); + GenTable(collection_name, dim, 100, "HAMMING"); nlohmann::json insert_json; insert_json["vectors"] = RandomBinRecordsJson(dim, 20); - auto response = client_ptr->insert(table_name, insert_json.dump().c_str(), conncetion_ptr); + 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(table_name); + auto status = FlushTable(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(table_name, conncetion_ptr); + response = client_ptr->dropTable(collection_name, conncetion_ptr); ASSERT_EQ(OStatus::CODE_204.code, response->getStatusCode()); } TEST_F(WebControllerTest, INSERT_IDS) { - auto table_name = "test_insert_table_test" + OString(RandomName().c_str()); + auto collection_name = "test_insert_collection_test" + OString(RandomName().c_str()); const int64_t dim = 64; - GenTable(table_name, dim, 100, "L2"); + GenTable(collection_name, dim, 100, "L2"); std::vector ids; for (size_t i = 0; i < 20; i++) { @@ -1098,63 +1100,63 @@ TEST_F(WebControllerTest, INSERT_IDS) { insert_json["vectors"] = RandomRecordsJson(dim, 20); insert_json["ids"] = ids; - auto response = client_ptr->insert(table_name, insert_json.dump().c_str(), conncetion_ptr); + 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 result_dto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(20, result_dto->ids->count()); - response = client_ptr->dropTable(table_name, conncetion_ptr); + response = client_ptr->dropTable(collection_name, conncetion_ptr); ASSERT_EQ(OStatus::CODE_204.code, response->getStatusCode()); } TEST_F(WebControllerTest, INDEX) { - auto table_name = "test_insert_table_test" + OString(RandomName().c_str()); - GenTable(table_name, 64, 100, "L2"); + auto collection_name = "test_insert_collection_test" + OString(RandomName().c_str()); + GenTable(collection_name, 64, 100, "L2"); // test index with imcomplete param nlohmann::json index_json; - auto response = client_ptr->createIndex(table_name, index_json.dump().c_str(), conncetion_ptr); + auto response = client_ptr->createIndex(collection_name, index_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()); index_json["index_type"] = milvus::server::web::IndexMap.at(milvus::engine::EngineType::FAISS_IDMAP); // missing index `params` - response = client_ptr->createIndex(table_name, index_json.dump().c_str(), conncetion_ptr); + response = client_ptr->createIndex(collection_name, index_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()); index_json["params"] = nlohmann::json::parse("{\"nlist\": 10}"); - response = client_ptr->createIndex(table_name, index_json.dump().c_str(), conncetion_ptr); + response = client_ptr->createIndex(collection_name, index_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_201.code, response->getStatusCode()); // drop index - response = client_ptr->dropIndex(table_name, conncetion_ptr); + response = client_ptr->dropIndex(collection_name, conncetion_ptr); ASSERT_EQ(OStatus::CODE_204.code, response->getStatusCode()); // create index without existing table - response = client_ptr->createIndex(table_name + "fgafafafafafUUUUUUa124254", index_json.dump().c_str(), conncetion_ptr); + response = client_ptr->createIndex(collection_name + "fgafafafafafUUUUUUa124254", index_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_404.code, response->getStatusCode()); // invalid index type index_json["index_type"] = "J46"; - response = client_ptr->createIndex(table_name, index_json.dump().c_str(), conncetion_ptr); + response = client_ptr->createIndex(collection_name, index_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()); auto result_dto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(milvus::server::web::StatusCode::ILLEGAL_INDEX_TYPE, result_dto->code); // drop index - response = client_ptr->dropIndex(table_name, conncetion_ptr); + response = client_ptr->dropIndex(collection_name, conncetion_ptr); ASSERT_EQ(OStatus::CODE_204.code, response->getStatusCode()); // insert data and create index - auto status = InsertData(table_name, 64, 200); + auto status = InsertData(collection_name, 64, 200); ASSERT_TRUE(status.ok()) << status.message(); index_json["index_type"] = milvus::server::web::IndexMap.at(milvus::engine::EngineType::FAISS_IVFFLAT); - response = client_ptr->createIndex(table_name, index_json.dump().c_str(), conncetion_ptr); + response = client_ptr->createIndex(collection_name, index_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_201.code, response->getStatusCode()); // get index - response = client_ptr->getIndex(table_name, conncetion_ptr); + response = client_ptr->getIndex(collection_name, conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()); auto result_index_json = nlohmann::json::parse(response->readBodyToString()->c_str()); ASSERT_TRUE(result_index_json.contains("index_type")); @@ -1169,82 +1171,82 @@ TEST_F(WebControllerTest, INDEX) { ASSERT_EQ(10, nlist_json.get()); // get index of table which not exists - response = client_ptr->getIndex(table_name + "dfaedXXXdfdfet4t343aa4", conncetion_ptr); + response = client_ptr->getIndex(collection_name + "dfaedXXXdfdfet4t343aa4", conncetion_ptr); ASSERT_EQ(OStatus::CODE_404.code, response->getStatusCode()); auto error_dto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(milvus::server::web::StatusCode::TABLE_NOT_EXISTS, error_dto->code->getValue()); } TEST_F(WebControllerTest, PARTITION) { - const OString table_name = "test_controller_partition_" + OString(RandomName().c_str()); - GenTable(table_name, 64, 100, "L2"); + const OString collection_name = "test_controller_partition_" + OString(RandomName().c_str()); + GenTable(collection_name, 64, 100, "L2"); auto par_param = milvus::server::web::PartitionRequestDto::createShared(); - auto response = client_ptr->createPartition(table_name, par_param); + auto response = client_ptr->createPartition(collection_name, par_param); ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()); auto error_dto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(milvus::server::web::StatusCode::BODY_FIELD_LOSS, error_dto->code); - response = client_ptr->createPartition(table_name, par_param); + response = client_ptr->createPartition(collection_name, par_param); ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()); error_dto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(milvus::server::web::StatusCode::BODY_FIELD_LOSS, error_dto->code); par_param->partition_tag = "tag01"; - response = client_ptr->createPartition(table_name, par_param); + response = client_ptr->createPartition(collection_name, par_param); ASSERT_EQ(OStatus::CODE_201.code, response->getStatusCode()); auto create_result_dto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(milvus::server::web::StatusCode::SUCCESS, create_result_dto->code); - response = client_ptr->createPartition(table_name + "afafanotgitdiexists", par_param); + response = client_ptr->createPartition(collection_name + "afafanotgitdiexists", par_param); ASSERT_EQ(OStatus::CODE_404.code, response->getStatusCode()); error_dto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(milvus::server::web::StatusCode::TABLE_NOT_EXISTS, error_dto->code); - // insert 200 vectors into table with tag = 'tag01' - auto status = InsertData(table_name, 64, 200, "tag01"); + // insert 200 vectors into collection with tag = 'tag01' + auto status = InsertData(collection_name, 64, 200, "tag01"); ASSERT_TRUE(status.ok()) << status.message(); // Show all partitins - response = client_ptr->showPartitions(table_name, "0", "10", conncetion_ptr); + response = client_ptr->showPartitions(collection_name, "0", "10", conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()); auto result_dto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(2, result_dto->partitions->count()); ASSERT_EQ("tag01", result_dto->partitions->get(1)->partition_tag->std_str()); - response = client_ptr->showPartitions(table_name, "0", "-1", conncetion_ptr); + response = client_ptr->showPartitions(collection_name, "0", "-1", conncetion_ptr); ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()); - response = client_ptr->showPartitions(table_name, "0.1", "7", conncetion_ptr); + response = client_ptr->showPartitions(collection_name, "0.1", "7", conncetion_ptr); ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()); - response = client_ptr->showPartitions(table_name, "0", "1.6", conncetion_ptr); + response = client_ptr->showPartitions(collection_name, "0", "1.6", conncetion_ptr); ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()); - response = client_ptr->showPartitions(table_name, "567a", "1", conncetion_ptr); + response = client_ptr->showPartitions(collection_name, "567a", "1", conncetion_ptr); ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()); - // show without existing tables - response = client_ptr->showPartitions(table_name + "dfafaefaluanqibazao990099", "0", "10", conncetion_ptr); + // show without existing collections + response = client_ptr->showPartitions(collection_name + "dfafaefaluanqibazao990099", "0", "10", conncetion_ptr); ASSERT_EQ(OStatus::CODE_404.code, response->getStatusCode()); error_dto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(milvus::server::web::StatusCode::TABLE_NOT_EXISTS, error_dto->code->getValue()); - response = client_ptr->dropPartition(table_name, "{\"partition_tag\": \"tag01\"}", conncetion_ptr); + response = client_ptr->dropPartition(collection_name, "{\"partition_tag\": \"tag01\"}", conncetion_ptr); ASSERT_EQ(OStatus::CODE_204.code, response->getStatusCode()); - // drop without existing tables - response = client_ptr->dropPartition(table_name + "565755682353464aaasafdsfagagqq1223", + // drop without existing collections + response = client_ptr->dropPartition(collection_name + "565755682353464aaasafdsfagagqq1223", "{\"partition_tag\": \"tag01\"}", conncetion_ptr); ASSERT_EQ(OStatus::CODE_404.code, response->getStatusCode()); } TEST_F(WebControllerTest, SHOW_SEGMENTS) { - OString table_name = OString("test_milvus_web_segments_test_") + RandomName().c_str(); + OString collection_name = OString("test_milvus_web_segments_test_") + RandomName().c_str(); - GenTable(table_name, 256, 1, "L2"); + GenTable(collection_name, 256, 1, "L2"); - auto status = InsertData(table_name, 256, 2000); + auto status = InsertData(collection_name, 256, 2000); ASSERT_TRUE(status.ok()) << status.message(); - auto response = client_ptr->showSegments(table_name, "0", "10", "", conncetion_ptr); + auto response = client_ptr->showSegments(collection_name, "0", "10", "", conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()) << response->readBodyToString()->c_str(); // validate result @@ -1259,14 +1261,14 @@ TEST_F(WebControllerTest, SHOW_SEGMENTS) { } TEST_F(WebControllerTest, GET_SEGMENT_INFO) { - OString table_name = OString("test_milvus_web_get_segment_info_test_") + RandomName().c_str(); + OString collection_name = OString("test_milvus_web_get_segment_info_test_") + RandomName().c_str(); - GenTable(table_name, 16, 1, "L2"); + GenTable(collection_name, 16, 1, "L2"); - auto status = InsertData(table_name, 16, 2000); + auto status = InsertData(collection_name, 16, 2000); ASSERT_TRUE(status.ok()) << status.message(); - auto response = client_ptr->showSegments(table_name, "0", "10", "", conncetion_ptr); + auto response = client_ptr->showSegments(collection_name, "0", "10", "", conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()) << response->readBodyToString()->c_str(); // validate result @@ -1277,7 +1279,7 @@ TEST_F(WebControllerTest, GET_SEGMENT_INFO) { // get segment ids - response = client_ptr->getSegmentInfo(table_name, segment_name.c_str(), "ids", "0", "10"); + response = client_ptr->getSegmentInfo(collection_name, segment_name.c_str(), "ids", "0", "10"); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()) << response->readBodyToString()->c_str(); auto ids_result_json = nlohmann::json::parse(response->readBodyToString()->c_str()); @@ -1287,7 +1289,7 @@ TEST_F(WebControllerTest, GET_SEGMENT_INFO) { ASSERT_EQ(10, ids_json.size()); // get segment vectors - response = client_ptr->getSegmentInfo(table_name, segment_name.c_str(), "vectors", "0", "10"); + response = client_ptr->getSegmentInfo(collection_name, segment_name.c_str(), "vectors", "0", "10"); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()) << response->readBodyToString()->c_str(); auto vecs_result_json = nlohmann::json::parse(response->readBodyToString()->c_str()); @@ -1296,32 +1298,32 @@ TEST_F(WebControllerTest, GET_SEGMENT_INFO) { ASSERT_TRUE(vecs_json.is_array()); ASSERT_EQ(10, vecs_json.size()); - // non-existent table - response = client_ptr->getSegmentInfo(table_name + "_non_existent", segment_name.c_str(), "ids", "0", "10"); + // non-existent collection + response = client_ptr->getSegmentInfo(collection_name + "_non_existent", segment_name.c_str(), "ids", "0", "10"); ASSERT_EQ(OStatus::CODE_404.code, response->getStatusCode()) << response->readBodyToString()->c_str(); } TEST_F(WebControllerTest, SEGMENT_FILTER) { - OString table_name = OString("test_milvus_web_segment_filter_test_") + RandomName().c_str(); - GenTable(table_name, 16, 1, "L2"); + OString collection_name = OString("test_milvus_web_segment_filter_test_") + RandomName().c_str(); + GenTable(collection_name, 16, 1, "L2"); - auto status = InsertData(table_name, 16, 1000); + auto status = InsertData(collection_name, 16, 1000); ASSERT_TRUE(status.ok()) << status.message(); - status = GenPartition(table_name, "tag01"); + status = GenPartition(collection_name, "tag01"); ASSERT_TRUE(status.ok()) << status.message(); - status = InsertData(table_name, 16, 1000, "tag01"); + status = InsertData(collection_name, 16, 1000, "tag01"); ASSERT_TRUE(status.ok()) << status.message(); - status = GenPartition(table_name, "tag02"); + status = GenPartition(collection_name, "tag02"); ASSERT_TRUE(status.ok()) << status.message(); - status = InsertData(table_name, 16, 1000, "tag02"); + status = InsertData(collection_name, 16, 1000, "tag02"); ASSERT_TRUE(status.ok()) << status.message(); // show segments filtering tag - auto response = client_ptr->showSegments(table_name, "0", "10", "_default", conncetion_ptr); + auto response = client_ptr->showSegments(collection_name, "0", "10", "_default", conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()) << response->readBodyToString()->c_str(); auto result_json = nlohmann::json::parse(response->readBodyToString()->c_str()); @@ -1337,41 +1339,41 @@ TEST_F(WebControllerTest, SEGMENT_FILTER) { } TEST_F(WebControllerTest, SEARCH) { - const OString table_name = "test_search_table_test" + OString(RandomName().c_str()); - GenTable(table_name, 64, 100, "L2"); + const OString collection_name = "test_search_collection_test" + OString(RandomName().c_str()); + GenTable(collection_name, 64, 100, "L2"); - // Insert 200 vectors into table - auto status = InsertData(table_name, 64, 200); + // Insert 200 vectors into collection + auto status = InsertData(collection_name, 64, 200); ASSERT_TRUE(status.ok()) << status.message(); // Create partition and insert 200 vectors into it auto par_param = milvus::server::web::PartitionRequestDto::createShared(); par_param->partition_tag = "tag" + OString(RandomName().c_str()); - auto response = client_ptr->createPartition(table_name, par_param); + auto response = client_ptr->createPartition(collection_name, par_param); ASSERT_EQ(OStatus::CODE_201.code, response->getStatusCode()) << "Error: " << response->getStatusDescription()->std_str(); - status = InsertData(table_name, 64, 200, par_param->partition_tag->std_str()); + status = InsertData(collection_name, 64, 200, par_param->partition_tag->std_str()); ASSERT_TRUE(status.ok()) << status.message(); // Test search nlohmann::json search_json; - response = client_ptr->vectorsOp(table_name, search_json.dump().c_str(), conncetion_ptr); + response = client_ptr->vectorsOp(collection_name, search_json.dump().c_str(), conncetion_ptr); auto error_dto = response->readBodyToDto(object_mapper.get()); ASSERT_NE(milvus::server::web::StatusCode::SUCCESS, error_dto->code); search_json["search"]["params"]["nprobe"] = 1; - response = client_ptr->vectorsOp(table_name, search_json.dump().c_str(), conncetion_ptr); + response = client_ptr->vectorsOp(collection_name, search_json.dump().c_str(), conncetion_ptr); error_dto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(milvus::server::web::StatusCode::BODY_FIELD_LOSS, error_dto->code); search_json["search"]["topk"] = 1; - response = client_ptr->vectorsOp(table_name, search_json.dump().c_str(), conncetion_ptr); + response = client_ptr->vectorsOp(collection_name, search_json.dump().c_str(), conncetion_ptr); error_dto = response->readBodyToDto(object_mapper.get()); ASSERT_NE(milvus::server::web::StatusCode::SUCCESS, error_dto->code); search_json["search"]["vectors"] = RandomRecordsJson(64, 10); - response = client_ptr->vectorsOp(table_name, search_json.dump().c_str(), conncetion_ptr); + response = client_ptr->vectorsOp(collection_name, search_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()); auto result_json = nlohmann::json::parse(response->readBodyToString()->std_str()); @@ -1391,52 +1393,52 @@ TEST_F(WebControllerTest, SEARCH) { par_json.push_back(par_param->partition_tag->std_str()); search_json["search"]["partition_tags"] = par_json; - response = client_ptr->vectorsOp(table_name, search_json.dump().c_str(), conncetion_ptr); + response = client_ptr->vectorsOp(collection_name, search_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()); - // Test search without existing table - response = client_ptr->vectorsOp(table_name + "999piyanning", search_json.dump().c_str(), conncetion_ptr); + // Test search without existing collection + response = client_ptr->vectorsOp(collection_name + "999piyanning", search_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_404.code, response->getStatusCode()); error_dto = response->readBodyToDto(object_mapper.get()); ASSERT_EQ(milvus::server::web::StatusCode::TABLE_NOT_EXISTS, error_dto->code->getValue()); } TEST_F(WebControllerTest, SEARCH_BIN) { - const OString table_name = "test_search_bin_table_test" + OString(RandomName().c_str()); - GenTable(table_name, 64, 100, "HAMMING"); + const OString collection_name = "test_search_bin_collection_test" + OString(RandomName().c_str()); + GenTable(collection_name, 64, 100, "HAMMING"); - // Insert 200 vectors into table - auto status = InsertData(table_name, 64, 200, "", true); + // Insert 200 vectors into collection + auto status = InsertData(collection_name, 64, 200, "", true); ASSERT_TRUE(status.ok()) << status.message(); // Create partition and insert 200 vectors into it auto par_param = milvus::server::web::PartitionRequestDto::createShared(); par_param->partition_tag = "tag" + OString(RandomName().c_str()); - auto response = client_ptr->createPartition(table_name, par_param); + auto response = client_ptr->createPartition(collection_name, par_param); ASSERT_EQ(OStatus::CODE_201.code, response->getStatusCode()) << "Error: " << response->readBodyToString()->std_str(); - status = InsertData(table_name, 64, 200, par_param->partition_tag->std_str(), true); + status = InsertData(collection_name, 64, 200, par_param->partition_tag->std_str(), true); ASSERT_TRUE(status.ok()) << status.message(); // Test search nlohmann::json search_json; - response = client_ptr->vectorsOp(table_name, search_json.dump().c_str(), conncetion_ptr); + response = client_ptr->vectorsOp(collection_name, search_json.dump().c_str(), conncetion_ptr); auto result_dto = response->readBodyToDto(object_mapper.get()); ASSERT_NE(milvus::server::web::StatusCode::SUCCESS, result_dto->code); search_json["search"]["params"]["nprobe"] = 1; - response = client_ptr->vectorsOp(table_name, search_json.dump().c_str(), conncetion_ptr); + response = client_ptr->vectorsOp(collection_name, search_json.dump().c_str(), conncetion_ptr); result_dto = response->readBodyToDto(object_mapper.get()); ASSERT_NE(milvus::server::web::StatusCode::SUCCESS, result_dto->code); search_json["search"]["topk"] = 1; - response = client_ptr->vectorsOp(table_name, search_json.dump().c_str(), conncetion_ptr); + response = client_ptr->vectorsOp(collection_name, search_json.dump().c_str(), conncetion_ptr); result_dto = response->readBodyToDto(object_mapper.get()); ASSERT_NE(milvus::server::web::StatusCode::SUCCESS, result_dto->code); search_json["search"]["vectors"] = RandomBinRecordsJson(64, 10); - response = client_ptr->vectorsOp(table_name, search_json.dump().c_str(), conncetion_ptr); + response = client_ptr->vectorsOp(collection_name, search_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()); // validate search result @@ -1452,7 +1454,7 @@ TEST_F(WebControllerTest, SEARCH_BIN) { // Test search with tags search_json["search"]["partition_tags"] = std::vector(); search_json["search"]["partition_tags"].push_back(par_param->partition_tag->std_str()); - response = client_ptr->vectorsOp(table_name, search_json.dump().c_str(), conncetion_ptr); + response = client_ptr->vectorsOp(collection_name, search_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()); } @@ -1463,16 +1465,16 @@ TEST_F(WebControllerTest, SEARCH_BIN) { // ASSERT_TRUE(config_status.ok()) << config_status.message(); //#endif // -// const OString table_name = "test_search_by_id_table_test_" + OString(RandomName().c_str()); -// GenTable(table_name, 64, 100, "L2"); +// const OString collection_name = "test_search_by_id_collection_test_" + OString(RandomName().c_str()); +// GenTable(collection_name, 64, 100, "L2"); // -// // Insert 100 vectors into table +// // Insert 100 vectors into collection // std::vector ids; // for (size_t i = 0; i < 100; i++) { // ids.emplace_back(i); // } // -// auto status = InsertData(table_name, 64, 100, ids); +// auto status = InsertData(collection_name, 64, 100, ids); // ASSERT_TRUE(status.ok()) << status.message(); // // nlohmann::json search_json; @@ -1480,7 +1482,7 @@ TEST_F(WebControllerTest, SEARCH_BIN) { // search_json["search"]["nprobe"] = 1; // search_json["search"]["vector_id"] = ids.at(0); // -// auto response = client_ptr->vectorsOp(table_name, search_json.dump().c_str(), conncetion_ptr); +// auto response = client_ptr->vectorsOp(collection_name, search_json.dump().c_str(), conncetion_ptr); // ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()) << response->readBodyToString()->c_str(); // // // validate search result @@ -1502,21 +1504,21 @@ TEST_F(WebControllerTest, SEARCH_BIN) { //} TEST_F(WebControllerTest, GET_VECTOR_BY_ID) { - const OString table_name = "test_milvus_web_get_vector_by_id_test_" + OString(RandomName().c_str()); - GenTable(table_name, 64, 100, "L2"); + const OString collection_name = "test_milvus_web_get_vector_by_id_test_" + OString(RandomName().c_str()); + GenTable(collection_name, 64, 100, "L2"); - // Insert 100 vectors into table + // Insert 100 vectors into collection std::vector ids; for (size_t i = 0; i < 100; i++) { ids.emplace_back(i); } - auto status = InsertData(table_name, 64, 100, ids); + auto status = InsertData(collection_name, 64, 100, ids); ASSERT_TRUE(status.ok()) << status.message(); /* test task load */ auto id_str = std::to_string(ids.at(0)); - auto response = client_ptr->getVectors(table_name, id_str.c_str(), conncetion_ptr); + auto response = client_ptr->getVectors(collection_name, id_str.c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()) << response->readBodyToString()->c_str(); // validate result @@ -1540,19 +1542,19 @@ TEST_F(WebControllerTest, GET_VECTOR_BY_ID) { ASSERT_EQ(64, vec.size()); - // non-existent table - response = client_ptr->getVectors(table_name + "_non_existent", id_str.c_str(), conncetion_ptr); + // non-existent collection + response = client_ptr->getVectors(collection_name + "_non_existent", id_str.c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_404.code, response->getStatusCode()) << response->readBodyToString()->c_str(); } TEST_F(WebControllerTest, DELETE_BY_ID) { - const OString table_name = "test_search_bin_table_test" + OString(RandomName().c_str()); - GenTable(table_name, 64, 100, "L2"); + const OString collection_name = "test_search_bin_collection_test" + OString(RandomName().c_str()); + GenTable(collection_name, 64, 100, "L2"); - // Insert 200 vectors into table + // Insert 200 vectors into collection nlohmann::json insert_json; insert_json["vectors"] = RandomRecordsJson(64, 2000); - auto response = client_ptr->insert(table_name, insert_json.dump().c_str(), conncetion_ptr); + auto response = client_ptr->insert(collection_name, insert_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_201.code, response->getStatusCode()) << response->readBodyToString()->c_str(); auto insert_result_json = nlohmann::json::parse(response->readBodyToString()->c_str()); @@ -1570,11 +1572,11 @@ TEST_F(WebControllerTest, DELETE_BY_ID) { nlohmann::json delete_json; delete_json["delete"]["ids"] = delete_ids; - response = client_ptr->vectorsOp(table_name, delete_json.dump().c_str(), conncetion_ptr); + response = client_ptr->vectorsOp(collection_name, delete_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()) << response->readBodyToString()->c_str(); - // non-existent table - response = client_ptr->vectorsOp(table_name + "_non_existent", delete_json.dump().c_str(), conncetion_ptr); + // non-existent collection + response = client_ptr->vectorsOp(collection_name + "_non_existent", delete_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_404.code, response->getStatusCode()) << response->readBodyToString()->c_str(); } @@ -1589,7 +1591,7 @@ TEST_F(WebControllerTest, CMD) { response = client_ptr->cmd("mode", "", "", conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()); - response = client_ptr->cmd("tasktable", "", "", conncetion_ptr); + response = client_ptr->cmd("taskcollection", "", "", conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()); response = client_ptr->cmd("info", "", "", conncetion_ptr); @@ -1623,17 +1625,17 @@ TEST_F(WebControllerTest, CONFIG) { auto result_json = nlohmann::json::parse(response->readBodyToString()->c_str()); ASSERT_TRUE(result_json.contains("restart_required")); - OString table_name = "milvus_test_webcontroller_test_preload_table"; - GenTable(table_name, 16, 10, "L2"); + OString collection_name = "milvus_test_webcontroller_test_preload_collection"; + GenTable(collection_name, 16, 10, "L2"); - OString table_name_s = "milvus_test_webcontroller_test_preload_table_s"; - GenTable(table_name_s, 16, 10, "L2"); + OString collection_name_s = "milvus_test_webcontroller_test_preload_collection_s"; + GenTable(collection_name_s, 16, 10, "L2"); - OString body_str = "{\"db_config\": {\"preload_table\": \"" + table_name + "\"}}"; + OString body_str = "{\"db_config\": {\"preload_table\": \"" + collection_name + "\"}}"; response = client_ptr->op("config", body_str, conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()) << response->readBodyToString()->c_str(); - body_str = "{\"db_config\": {\"preload_table\": \"" + table_name + "," + table_name_s + "\"}}"; + body_str = "{\"db_config\": {\"preload_table\": \"" + collection_name + "," + collection_name_s + "\"}}"; response = client_ptr->op("config", body_str, conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()) << response->readBodyToString()->c_str(); auto set_result_json = nlohmann::json::parse(response->readBodyToString()->c_str()); @@ -1762,53 +1764,53 @@ TEST_F(WebControllerTest, DEVICES_CONFIG) { } TEST_F(WebControllerTest, FLUSH) { - auto table_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); - GenTable(table_name, 16, 10, "L2"); + auto collection_name = milvus::server::web::OString(TABLE_NAME) + RandomName().c_str(); + GenTable(collection_name, 16, 10, "L2"); - auto status = InsertData(table_name, 16, 1000); + auto status = InsertData(collection_name, 16, 1000); ASSERT_TRUE(status.ok()) << status.message(); nlohmann::json flush_json; - flush_json["flush"]["table_names"] = {table_name->std_str()}; + flush_json["flush"]["collection_names"] = {collection_name->std_str()}; auto response = client_ptr->op("task", flush_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()); // invalid payload format - flush_json["flush"]["table_names"] = table_name->std_str(); + flush_json["flush"]["collection_names"] = collection_name->std_str(); response = client_ptr->op("task", flush_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()); // non-existent name - flush_json["flush"]["table_names"] = {"afafaf444353"}; + flush_json["flush"]["collection_names"] = {"afafaf444353"}; response = client_ptr->op("task", flush_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_400.code, response->getStatusCode()); } TEST_F(WebControllerTest, COMPACT) { - auto table_name = milvus::server::web::OString("milvus_web_test_compact_") + RandomName().c_str(); - GenTable(table_name, 16, 10, "L2"); + auto collection_name = milvus::server::web::OString("milvus_web_test_compact_") + RandomName().c_str(); + GenTable(collection_name, 16, 10, "L2"); - auto status = InsertData(table_name, 16, 1000); + auto status = InsertData(collection_name, 16, 1000); ASSERT_TRUE(status.ok()) << status.message(); nlohmann::json compact_json; - compact_json["compact"]["table_name"] = table_name->std_str(); + compact_json["compact"]["collection_name"] = collection_name->std_str(); auto response = client_ptr->op("task", compact_json.dump().c_str(), conncetion_ptr); ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()) << response->readBodyToString()->c_str(); } TEST_F(WebControllerTest, LOAD) { - OString table_name = "milvus_web_test_load_" + OString(RandomName().c_str()); - GenTable(table_name, 128, 100, "L2"); + OString collection_name = "milvus_web_test_load_" + OString(RandomName().c_str()); + GenTable(collection_name, 128, 100, "L2"); nlohmann::json load_json; - load_json["load"]["table_name"] = table_name->c_str(); + 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"]["table_name"] = "sssssssssssssssssssssssfsfsfsrrrttt"; + 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());