Add basic router alteration test

The test checks that alterations to routers work and are persisted.
This commit is contained in:
Markus Mäkelä 2018-07-07 21:48:44 +03:00
parent 1e68261bce
commit 616fb30818
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
2 changed files with 59 additions and 0 deletions

View File

@ -524,6 +524,9 @@ add_test_executable(mxs922_scaling.cpp mxs922_scaling mxs922_base LABELS maxscal
# Dynamic listener SSL test
add_test_executable(mxs922_listener_ssl.cpp mxs922_listener_ssl mxs922_base LABELS maxscale REPL_BACKEND)
# Alter routers at runtime
add_test_executable(alter_router.cpp alter_router replication LABELS maxscale REPL_BACKEND)
# Test of MaxRows filter
add_test_executable(mxs1071_maxrows.cpp mxs1071_maxrows maxrows LABELS maxrowsfilter REPL_BACKEND)

View File

@ -0,0 +1,56 @@
/**
* Test runtime modification of router options
*/
#include "testconnections.h"
int main(int argc, char** argv)
{
TestConnections test(argc, argv);
test.maxscales->wait_for_monitor();
// Open a connection before and after setting master_failure_mode to fail_on_write
Connection first = test.maxscales->rwsplit();
Connection second = test.maxscales->rwsplit();
Connection third = test.maxscales->rwsplit();
test.maxscales->wait_for_monitor();
first.connect();
test.maxscales->ssh_node_f(0, true, "maxctrl alter service RW-Split-Router master_failure_mode fail_on_write");
second.connect();
// Check that writes work for both connections
test.assert(first.query("SELECT @@last_insert_id"),
"Write to first connection should work: %s", first.error());
test.assert(second.query("SELECT @@last_insert_id"),
"Write to second connection should work: %s", second.error());
// Block the master
test.repl->block_node(0);
test.maxscales->wait_for_monitor();
// Check that reads work for the newer connection and fail for the older one
test.assert(!first.query("SELECT 1"),
"Read to first connection should fail.");
test.assert(second.query("SELECT 1"),
"Read to second connection should work: %s", second.error());
// Unblock the master, restart Maxscale and check that changes are persisted
test.repl->unblock_node(0);
test.maxscales->wait_for_monitor();
test.maxscales->restart();
third.connect();
test.assert(third.query("SELECT @@last_insert_id"),
"Write to third connection should work: %s", third.error());
test.repl->block_node(0);
test.maxscales->wait_for_monitor();
test.assert(third.query("SELECT 1"),
"Read to third connection should work: %s", third.error());
test.repl->unblock_node(0);
return test.global_result;
}