Update replication-manager test
The test now checks whether replication-manager launched by a script works. This is closer to how one of the original blog posts define the setup.
This commit is contained in:
@ -12,6 +12,8 @@ monitor_interval=1000
|
|||||||
detect_standalone_master=true
|
detect_standalone_master=true
|
||||||
failcount=2
|
failcount=2
|
||||||
allow_cluster_recovery=true
|
allow_cluster_recovery=true
|
||||||
|
events=master_down
|
||||||
|
script=/home/vagrant/replication-manager --hosts=$LIST --user=skysql:skysql --rpluser=skysql:skysql --switchover-at-sync=false --log-level=3 --logfile=/tmp/mrm.log switchover
|
||||||
|
|
||||||
[RW Split Router]
|
[RW Split Router]
|
||||||
type=service
|
type=service
|
||||||
|
@ -21,9 +21,9 @@ void get_output(TestConnections& test)
|
|||||||
test.tprintf("%s", output);
|
test.tprintf("%s", output);
|
||||||
free(output);
|
free(output);
|
||||||
|
|
||||||
test.tprintf("replication-manager output:");
|
test.tprintf("MaxScale output:");
|
||||||
output = test.ssh_maxscale_output(true,
|
output = test.ssh_maxscale_output(true,
|
||||||
"cat /var/log/replication-manager.log && sudo truncate -s 0 /var/log/replication-manager.log");
|
"cat /var/log/maxscale/maxscale.log && sudo truncate -s 0 /var/log/maxscale/maxscale.log");
|
||||||
test.tprintf("%s", output);
|
test.tprintf("%s", output);
|
||||||
free(output);
|
free(output);
|
||||||
}
|
}
|
||||||
@ -66,6 +66,21 @@ void check(TestConnections& test)
|
|||||||
mysql_close(conn);
|
mysql_close(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_server_id(TestConnections& test)
|
||||||
|
{
|
||||||
|
MYSQL *conn = test.open_rwsplit_connection();
|
||||||
|
int id = -1;
|
||||||
|
char str[1024];
|
||||||
|
|
||||||
|
if (find_field(conn, "SELECT @@server_id", "@@server_id", str) == 0)
|
||||||
|
{
|
||||||
|
id = atoi(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
mysql_close(conn);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
static bool interactive = false;
|
static bool interactive = false;
|
||||||
|
|
||||||
void get_input()
|
void get_input()
|
||||||
@ -83,21 +98,25 @@ int main(int argc, char** argv)
|
|||||||
prepare();
|
prepare();
|
||||||
|
|
||||||
TestConnections test(argc, argv);
|
TestConnections test(argc, argv);
|
||||||
test.tprintf("Installing replication-manager");
|
|
||||||
int rc = system("./manage_mrm.sh install > manage_mrm.log");
|
|
||||||
if (!WIFEXITED(rc) || WEXITSTATUS(rc) != 0)
|
|
||||||
{
|
|
||||||
test.tprintf("Failed to install replication-manager, see manage_mrm.log for more details");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait a few seconds
|
// TODO: Figure out how to do this without having replication-manager pre-installed on the system
|
||||||
sleep(5);
|
//
|
||||||
|
// test.tprintf("Installing replication-manager");
|
||||||
|
// int rc = system("./manage_mrm.sh install > manage_mrm.log");
|
||||||
|
// if (!WIFEXITED(rc) || WEXITSTATUS(rc) != 0)
|
||||||
|
// {
|
||||||
|
// test.tprintf("Failed to install replication-manager, see manage_mrm.log for more details");
|
||||||
|
// return -1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Wait a few seconds
|
||||||
|
// sleep(5);
|
||||||
|
|
||||||
test.tprintf("Creating table and inserting data");
|
test.tprintf("Creating table and inserting data");
|
||||||
get_input();
|
get_input();
|
||||||
test.connect_maxscale();
|
test.connect_maxscale();
|
||||||
test.try_query(test.conn_rwsplit, "CREATE OR REPLACE TABLE test.t1(id INT)");
|
test.try_query(test.conn_rwsplit, "CREATE OR REPLACE TABLE test.t1(id INT)");
|
||||||
|
test.repl->sync_slaves();
|
||||||
|
|
||||||
check(test);
|
check(test);
|
||||||
get_output(test);
|
get_output(test);
|
||||||
@ -127,31 +146,34 @@ int main(int argc, char** argv)
|
|||||||
check(test);
|
check(test);
|
||||||
get_output(test);
|
get_output(test);
|
||||||
|
|
||||||
test.tprintf("Starting all nodes and wait for replication-manager to fix the replication");
|
|
||||||
get_input();
|
|
||||||
|
|
||||||
test.repl->start_node(0, (char*)"");
|
test.tprintf("Fix replication and recreate table");
|
||||||
sleep(5);
|
test.close_maxscale_connections();
|
||||||
test.repl->start_node(1, (char*)"");
|
test.repl->fix_replication();
|
||||||
sleep(5);
|
test.connect_maxscale();
|
||||||
test.repl->start_node(2, (char*)"");
|
test.try_query(test.conn_rwsplit, "CREATE OR REPLACE TABLE test.t1(id INT)");
|
||||||
sleep(5);
|
test.repl->sync_slaves();
|
||||||
|
inserts = 0;
|
||||||
|
|
||||||
check(test);
|
check(test);
|
||||||
get_output(test);
|
get_output(test);
|
||||||
|
|
||||||
test.tprintf("Dropping tables");
|
test.tprintf("Disable replication on a slave and kill master, check that it is not promoted");
|
||||||
get_input();
|
execute_query(test.repl->nodes[1], "STOP SLAVE; RESET SLAVE; RESET SLAVE ALL;");
|
||||||
test.close_maxscale_connections();
|
test.repl->stop_node(0);
|
||||||
test.connect_maxscale();
|
sleep(10);
|
||||||
test.try_query(test.conn_rwsplit, "DROP TABLE test.t1");
|
|
||||||
test.close_maxscale_connections();
|
|
||||||
|
|
||||||
|
check(test);
|
||||||
get_output(test);
|
get_output(test);
|
||||||
|
|
||||||
test.tprintf("Removing replication-manager");
|
int id = get_server_id(test);
|
||||||
get_input();
|
test.add_result(id == test.repl->get_server_id(1), "Invalid slave should not be used");
|
||||||
system("./manage_mrm.sh remove >> manage_mrm.log");
|
|
||||||
|
// TODO: Figure this also out, remove the component if it's not needed
|
||||||
|
// test.tprintf("Removing replication-manager");
|
||||||
|
// get_input();
|
||||||
|
// system("./manage_mrm.sh remove >> manage_mrm.log");
|
||||||
|
|
||||||
test.repl->fix_replication();
|
test.repl->fix_replication();
|
||||||
return test.global_result;
|
return test.global_result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user