This repository has been archived by the owner on Jun 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support table-level slow query on meta server (#314)
- Loading branch information
zhao liwei
authored and
Wu Tao
committed
Sep 20, 2019
1 parent
da71dbd
commit 6eff713
Showing
5 changed files
with
114 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/dist/replication/test/meta_test/unit_test/meta_app_envs_test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2015 Microsoft Corporation | ||
* | ||
* -=- Robust Distributed System Nucleus (rDSN) -=- | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
#include "meta_test_base.h" | ||
|
||
namespace dsn { | ||
namespace replication { | ||
class meta_app_envs_test : public meta_test_base | ||
{ | ||
public: | ||
meta_app_envs_test() {} | ||
|
||
void SetUp() override | ||
{ | ||
meta_test_base::SetUp(); | ||
create_app(app_name); | ||
} | ||
|
||
error_code update_app_envs(const std::vector<std::string> &env_keys, | ||
const std::vector<std::string> &env_vals) | ||
{ | ||
auto req = make_unique<configuration_update_app_env_request>(); | ||
req->__set_app_name(std::move(app_name)); | ||
req->__set_op(std::move(app_env_operation::type::APP_ENV_OP_SET)); | ||
req->__set_keys(env_keys); | ||
req->__set_values(env_vals); | ||
|
||
app_env_rpc rpc(std::move(req), RPC_CM_UPDATE_APP_ENV); // don't need reply | ||
_ss->set_app_envs(rpc); | ||
_ss->wait_all_task(); | ||
return rpc.response().err; | ||
} | ||
|
||
const std::string app_name = "test_app_env"; | ||
const std::string env_slow_query_threshold = "replica.slow_query_threshold"; | ||
}; | ||
|
||
TEST_F(meta_app_envs_test, set_slow_query_threshold) | ||
{ | ||
auto app = find_app(app_name); | ||
|
||
struct test_case | ||
{ | ||
error_code err; | ||
std::string env_value; | ||
std::string expect_env_value; | ||
} tests[] = {{ERR_OK, "30", "30"}, | ||
{ERR_OK, "21", "21"}, | ||
{ERR_OK, "20", "20"}, | ||
{ERR_INVALID_PARAMETERS, "19", "20"}, | ||
{ERR_INVALID_PARAMETERS, "10", "20"}, | ||
{ERR_INVALID_PARAMETERS, "0", "20"}}; | ||
|
||
for (auto test : tests) { | ||
error_code err = update_app_envs({env_slow_query_threshold}, {test.env_value}); | ||
|
||
ASSERT_EQ(err, test.err); | ||
ASSERT_EQ(app->envs.at(env_slow_query_threshold), test.expect_env_value); | ||
} | ||
} | ||
} // namespace replication | ||
} // namespace dsn |