MXS-1643: Add test case

Added test case that checks that the correct state changes are made and no
extra events are triggered.

Also cleaned up the log checking function.
This commit is contained in:
Markus Mäkelä 2018-02-05 18:06:12 +02:00
parent 90fdbf8860
commit 6132ebd24f
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
4 changed files with 132 additions and 14 deletions

View File

@ -594,6 +594,10 @@ add_test_executable(mxs1543.cpp mxs1543 avro LABELS REPL_BACKEND)
# https://jira.mariadb.org/browse/MXS-1585
add_test_executable(mxs1585.cpp mxs1585 mxs1585 LABELS REPL_BACKEND)
# MXS-1643: Too many monitor events are triggered
# https://jira.mariadb.org/browse/MXS-1643
add_test_executable(mxs1643_extra_events.cpp mxs1643_extra_events mxs1643_extra_events LABELS REPL_BACKEND)
# 'namedserverfilter' test
add_test_executable(namedserverfilter.cpp namedserverfilter namedserverfilter LABELS namedserverfilter LIGHT REPL_BACKEND)

View File

@ -0,0 +1,67 @@
[maxscale]
threads=###threads###
[MySQL-Monitor]
type=monitor
module=mysqlmon
servers= server1,server2,server3,server4
user=maxskysql
passwd= skysql
monitor_interval=1000
detect_standalone_master=true
failcount=1
allow_cluster_recovery=true
replication_user=repl
replication_password=repl
backend_connect_timeout=3
backend_read_timeout=3
backend_write_timeout=3
auto_failover=true
auto_rejoin=true
[RW Split Router]
type=service
router= readwritesplit
servers=server1,server2,server3,server4
user=maxskysql
passwd=skysql
[RW Split Listener]
type=listener
service=RW Split Router
protocol=MySQLClient
port=4006
[CLI]
type=service
router=cli
[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
socket=default
[server1]
type=server
address=###node_server_IP_1###
port=###node_server_port_1###
protocol=MySQLBackend
[server2]
type=server
address=###node_server_IP_2###
port=###node_server_port_2###
protocol=MySQLBackend
[server3]
type=server
address=###node_server_IP_3###
port=###node_server_port_3###
protocol=MySQLBackend
[server4]
type=server
address=###node_server_IP_4###
port=###node_server_port_4###
protocol=MySQLBackend

View File

@ -0,0 +1,39 @@
/**
* MXS-1643: Too many monitor events are triggered
*
* https://jira.mariadb.org/browse/MXS-1643
*/
#include "testconnections.h"
int main(int argc, char** argv)
{
Mariadb_nodes::require_gtid(true);
TestConnections test(argc, argv);
// Check that master gets the slave status when set into read-only mode
test.tprintf("Set master into read-only mode");
test.repl->connect();
execute_query(test.repl->nodes[0], "SET GLOBAL read_only=ON");
sleep(10);
test.tprintf("Check that the current master now has the slave label");
test.check_log_err(0, "[Master, Running] -> [Running]", false);
test.check_log_err(0, "[Master, Running] -> [Slave, Running]", true);
execute_query(test.repl->nodes[0], "SET GLOBAL read_only=OFF");
sleep(5);
test.maxscales->ssh_node_f(0, true, "truncate -s 0 /var/log/maxscale/maxscale.log");
// Check that the Master and Slave status aren't both set
test.tprintf("Block master and wait for monitor to detect it.");
test.repl->block_node(0);
sleep(10);
test.tprintf("Check that the new master doesn't have both slave and master labels");
test.check_log_err(0, "[Slave, Running] -> [Master, Slave, Running]", false);
test.check_log_err(0, "[Slave, Running] -> [Master, Running]", true);
test.repl->unblock_node(0);
test.tprintf("Cleanup");
test.repl->execute_query_all_nodes( "STOP ALL SLAVES; RESET SLAVE ALL;");
test.repl->fix_replication();
return test.global_result;
}

View File

@ -1111,55 +1111,63 @@ void TestConnections::check_log_err(int m, const char * err_msg, bool expected)
char * err_log_content;
tprintf("Getting logs\n");
if (verbose)
{
tprintf("Getting logs");
}
char sys1[4096];
char dest[1024];
char log_file[64];
set_timeout(100);
set_timeout(500);
sprintf(dest, "maxscale_log_%03d/", m);
sprintf(&sys1[0], "mkdir -p maxscale_log_%03d; rm -f %s*.log",
m, dest);
//tprintf("Executing: %s\n", sys1);
system(sys1);
set_timeout(50);
sprintf(sys1, "%s/*", maxscales->maxscale_log_dir[m]);
maxscales->copy_from_node(m, sys1, dest);
tprintf("Reading maxscale.log\n");
sprintf(log_file, "maxscale_log_%03d/maxscale.log", m);
if ( ( read_log(log_file, &err_log_content) != 0) || (strlen(err_log_content) < 2) )
if (verbose)
{
tprintf("Reading maxscale1.log\n");
tprintf("Reading maxscale.log");
}
sprintf(log_file, "maxscale_log_%03d/maxscale.log", m);
if (read_log(log_file, &err_log_content) != 0 || strlen(err_log_content) < 2)
{
if (verbose)
{
tprintf("Reading maxscale1.log");
}
sprintf(log_file, "maxscale_log_%03d/maxscale1.log", m);
free(err_log_content);
if (read_log(log_file, &err_log_content) != 0)
{
add_result(1, "Error reading log\n");
add_result(1, "Error reading log");
}
}
//printf("\n\n%s\n\n", err_log_content);
if (err_log_content != NULL)
{
if (expected)
{
if (strstr(err_log_content, err_msg) == NULL)
{
add_result(1, "There is NO \"%s\" error in the log\n", err_msg);
add_result(1, "There is NO \"%s\" error in the log", err_msg);
}
else
{
tprintf("There is proper \"%s \" error in the log\n", err_msg);
tprintf("There is a proper \"%s \" error in the log", err_msg);
}
}
else
{
if (strstr(err_log_content, err_msg) != NULL)
{
add_result(1, "There is UNEXPECTED error \"%s\" error in the log\n", err_msg);
add_result(1, "There is an UNEXPECTED \"%s\" error in the log", err_msg);
}
else
{
tprintf("There are no unxpected errors \"%s \" error in the log\n", err_msg);
tprintf("There are no unxpected \"%s \" errors in the log", err_msg);
}
}