Extend router alteration test
Extended the test to cover modifications to readconnroute as well as do checks on detection of invalid parameters. Also allowed modifications to router_options at runtime.
This commit is contained in:
parent
c4be3f75c0
commit
6d663c79ac
@ -3,10 +3,14 @@
|
||||
*/
|
||||
|
||||
#include "testconnections.h"
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <functional>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
#define TEST(a) {#a, a}
|
||||
|
||||
void alter_readwritesplit(TestConnections& test)
|
||||
{
|
||||
TestConnections test(argc, argv);
|
||||
test.maxscales->wait_for_monitor();
|
||||
|
||||
// Open a connection before and after setting master_failure_mode to fail_on_write
|
||||
@ -51,6 +55,63 @@ int main(int argc, char** argv)
|
||||
"Read to third connection should work: %s", third.error());
|
||||
|
||||
test.repl->unblock_node(0);
|
||||
test.maxscales->wait_for_monitor();
|
||||
}
|
||||
|
||||
void alter_readconnroute(TestConnections& test)
|
||||
{
|
||||
test.repl->connect();
|
||||
std::string master_id = test.repl->get_server_id_str(0);
|
||||
test.repl->disconnect();
|
||||
|
||||
Connection conn = test.maxscales->readconn_master();
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
conn.connect();
|
||||
Row row = conn.row("SELECT @@server_id");
|
||||
conn.disconnect();
|
||||
test.assert(row[0] == master_id, "First connection should use master: %s != %s",
|
||||
row[0].c_str(), master_id.c_str());
|
||||
}
|
||||
|
||||
int rc = test.maxscales->ssh_node_f(0, true, "maxctrl alter service Read-Connection-Router-Master router_options slave");
|
||||
test.assert(rc == 0, "Readconnroute alteration should work");
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
conn.connect();
|
||||
Row row = conn.row("SELECT @@server_id");
|
||||
conn.disconnect();
|
||||
test.assert(row[0] != master_id, "Second connection should not use master: %s == %s",
|
||||
row[0].c_str(), master_id.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void alter_unsupported(TestConnections& test)
|
||||
{
|
||||
int rc = test.maxscales->ssh_node_f(0, true, "maxctrl alter service RW-Split-Router unknown parameter");
|
||||
test.assert(rc != 0, "Unknown router parameter should be detected");
|
||||
rc = test.maxscales->ssh_node_f(0, true, "maxctrl alter service RW-Split-Router filters Regex");
|
||||
test.assert(rc != 0, "Unsupported router parameter should be detected");
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
TestConnections test(argc, argv);
|
||||
|
||||
std::vector<std::pair<const char*, std::function<void (TestConnections&)>>> tests =
|
||||
{
|
||||
TEST(alter_readwritesplit),
|
||||
TEST(alter_readconnroute),
|
||||
TEST(alter_unsupported)
|
||||
};
|
||||
|
||||
for (auto& a: tests)
|
||||
{
|
||||
std::cout << a.first << std::endl;
|
||||
a.second(test);
|
||||
}
|
||||
|
||||
return test.global_result;
|
||||
}
|
||||
|
@ -651,7 +651,8 @@ bool runtime_alter_service(SERVICE *service, const char* zKey, const char* zValu
|
||||
valid = true;
|
||||
serviceSetRetryOnFailure(service, value.c_str());
|
||||
}
|
||||
else if (config_param_is_valid(module->parameters, key.c_str(), value.c_str(), NULL))
|
||||
else if (config_param_is_valid(module->parameters, key.c_str(), value.c_str(), NULL) ||
|
||||
key == CN_ROUTER_OPTIONS)
|
||||
{
|
||||
if (service->router->configureInstance && service->capabilities & RCAP_TYPE_RUNTIME_CONFIG)
|
||||
{
|
||||
@ -1779,7 +1780,6 @@ static bool is_dynamic_param(const std::string& key)
|
||||
{
|
||||
return key != CN_TYPE &&
|
||||
key != CN_ROUTER &&
|
||||
key != CN_ROUTER_OPTIONS &&
|
||||
key != CN_SERVERS;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user