未验证 提交 9e0ebae2 编写于 作者: Y yukun 提交者: GitHub

Fix webserver set_config bug (#3425)

* Fix TestSearchDSL multi fields bug
Signed-off-by: Nfishpenguin <kun.yu@zilliz.com>

* Fix set_config bug
Signed-off-by: Nfishpenguin <kun.yu@zilliz.com>
上级 36d06e59
......@@ -541,25 +541,17 @@ WebRequestHandler::SetConfig(const nlohmann::json& json, std::string& result_str
std::vector<std::string> cmds;
for (auto& el : json.items()) {
auto ekey = el.key();
auto evalue = el.value();
if (!evalue.is_object()) {
return Status(ILLEGAL_BODY, "Invalid payload format, the root value must be json map");
}
for (auto& iel : el.value().items()) {
auto ievalue = iel.value();
if (!(ievalue.is_string() || ievalue.is_number() || ievalue.is_boolean())) {
return Status(ILLEGAL_BODY, "Config value must be one of string, numeric or boolean");
}
std::ostringstream ss;
if (ievalue.is_string()) {
std::string vle = ievalue;
ss << "set_config " << el.key() << "." << iel.key() << " " << vle;
} else {
ss << "set_config " << el.key() << "." << iel.key() << " " << ievalue;
}
cmds.emplace_back(ss.str());
std::ostringstream ss;
if (evalue.is_string()) {
std::string vle = evalue;
ss << "set_config " << el.key() << " " << vle;
} else {
ss << "set_config " << el.key() << " " << evalue;
}
cmds.emplace_back(ss.str());
}
std::string msg;
......
......@@ -727,7 +727,13 @@ TEST_F(WebControllerTest, GET_PAGE_ENTITY) {
}
TEST_F(WebControllerTest, SYSTEM_INFO) {
auto response = client_ptr->cmd("config", "", "", connection_ptr);
std::string req = R"(
{
"cache.cache_size": "3221225472b"
})";
auto response = client_ptr->op("config", req.c_str(), connection_ptr);
response = client_ptr->cmd("config", "", "", connection_ptr);
ASSERT_EQ(OStatus::CODE_200.code, response->getStatusCode()) << response->readBodyToString()->c_str();
auto result_json = nlohmann::json::parse(response->readBodyToString()->c_str());
ASSERT_TRUE(result_json.contains("cluster.enable"));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册