MXS-1678: Add test case
Added test case that checks that relay master status is not lost when IO thread is stopped.
This commit is contained in:
@ -530,6 +530,10 @@ add_test_executable(mxs1543.cpp mxs1543 avro LABELS REPL_BACKEND)
|
|||||||
# https://jira.mariadb.org/browse/MXS-1585
|
# https://jira.mariadb.org/browse/MXS-1585
|
||||||
add_test_executable(mxs1585.cpp mxs1585 mxs1585 LABELS REPL_BACKEND)
|
add_test_executable(mxs1585.cpp mxs1585 mxs1585 LABELS REPL_BACKEND)
|
||||||
|
|
||||||
|
# MXS-1678: Stopping IO thread on relay master causes it to be promoted as master
|
||||||
|
# https://jira.mariadb.org/browse/MXS-1678
|
||||||
|
add_test_executable(mxs1678_relay_master.cpp mxs1678_relay_master replication LABELS REPL_BACKEND)
|
||||||
|
|
||||||
# 'namedserverfilter' test
|
# 'namedserverfilter' test
|
||||||
add_test_executable(namedserverfilter.cpp namedserverfilter namedserverfilter LABELS namedserverfilter LIGHT REPL_BACKEND)
|
add_test_executable(namedserverfilter.cpp namedserverfilter namedserverfilter LABELS namedserverfilter LIGHT REPL_BACKEND)
|
||||||
|
|
||||||
|
|||||||
86
maxscale-system-test/mxs1678_relay_master.cpp
Normal file
86
maxscale-system-test/mxs1678_relay_master.cpp
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/**
|
||||||
|
* MXS-1678: Stopping IO thread on relay master causes it to be promoted as master
|
||||||
|
*
|
||||||
|
* https://jira.mariadb.org/browse/MXS-1678
|
||||||
|
*/
|
||||||
|
#include "testconnections.h"
|
||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
typedef std::set<std::string> StringSet;
|
||||||
|
|
||||||
|
// Note: This is backported from 2.2 and can be replaced with MaxScales::get_server_status once merged
|
||||||
|
StringSet state(TestConnections& test, const char* name)
|
||||||
|
{
|
||||||
|
StringSet rval;
|
||||||
|
char* res = test.ssh_maxscale_output(true, "maxadmin list servers|grep \'%s\'", name);
|
||||||
|
char* pipe = strrchr(res, '|');
|
||||||
|
|
||||||
|
if (res && pipe)
|
||||||
|
{
|
||||||
|
pipe++;
|
||||||
|
char* tok = strtok(pipe, ",");
|
||||||
|
|
||||||
|
while (tok)
|
||||||
|
{
|
||||||
|
char* p = tok;
|
||||||
|
char *end = strchr(tok, '\n');
|
||||||
|
if (!end)
|
||||||
|
{
|
||||||
|
end = strchr(tok, '\0');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trim leading whitespace
|
||||||
|
while (p < end && isspace(*p))
|
||||||
|
{
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trim trailing whitespace
|
||||||
|
while (end > tok && isspace(*end))
|
||||||
|
{
|
||||||
|
*end-- = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
rval.insert(p);
|
||||||
|
tok = strtok(NULL, ",\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(res);
|
||||||
|
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
TestConnections test(argc, argv);
|
||||||
|
test.repl->connect();
|
||||||
|
execute_query(test.repl->nodes[3], "STOP SLAVE");
|
||||||
|
execute_query(test.repl->nodes[3], "CHANGE MASTER TO MASTER_HOST='%s', MASTER_PORT=%d",
|
||||||
|
test.repl->IP_private[2], test.repl->port[2]);
|
||||||
|
execute_query(test.repl->nodes[3], "START SLAVE");
|
||||||
|
|
||||||
|
StringSet master = {"Master", "Running"};
|
||||||
|
StringSet slave = {"Slave", "Running"};
|
||||||
|
StringSet relay_master = {"Relay Master", "Slave", "Running"};
|
||||||
|
|
||||||
|
test.tprintf("Checking before stopping IO thread");
|
||||||
|
test.add_result(state(test, "server1") != master, "server1 is not a master");
|
||||||
|
test.add_result(state(test, "server2") != slave, "server2 is not a slave");
|
||||||
|
test.add_result(state(test, "server3") != relay_master, "server3 is not a relay master");
|
||||||
|
test.add_result(state(test, "server4") != slave, "server4 is not a slave");
|
||||||
|
|
||||||
|
execute_query(test.repl->nodes[2], "STOP SLAVE IO_THREAD");
|
||||||
|
sleep(10);
|
||||||
|
|
||||||
|
test.tprintf("Checking after stopping IO thread");
|
||||||
|
test.add_result(state(test, "server1") != master, "server1 is not a master");
|
||||||
|
test.add_result(state(test, "server2") != slave, "server2 is not a slave");
|
||||||
|
test.add_result(state(test, "server3") != relay_master, "server3 is not a relay master");
|
||||||
|
test.add_result(state(test, "server4") != slave, "server4 is not a slave");
|
||||||
|
|
||||||
|
test.repl->fix_replication();
|
||||||
|
return test.global_result;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user