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:
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user