Files
MaxScale/maxscale-system-test/mysqlmon_rejoin_bad.cpp
Timofey Turenko e1fc0b8734 Squashed commit of the following:
commit 48a0b902b67da46f1eed4afa687bdcb56b59d02f
Author: Timofey Turenko <timofey.turenko@mariadb.com>
Date:   Mon Dec 16 15:35:07 2019 +0200

    Increase timouts in the mxs173_trottle_filter test

commit 81d8083a89421a8004b8024d480ae0f35d715b86
Author: Timofey Turenko <timofey.turenko@mariadb.com>
Date:   Mon Dec 16 14:19:39 2019 +0200

    Increase timeouts in max1071_maxrow test

commit e1039c6132f0e9274b8801165f3f905ede7c9421
Author: Timofey Turenko <timofey.turenko@mariadb.com>
Date:   Mon Dec 16 00:06:53 2019 +0200

    Remove hardcoded 'home/vagrant/' from all maxscale.cnf in system tests

commit 28c8029e060afdcf5159bf802b13dcd5e484d9f1
Author: Timofey Turenko <timofey.turenko@mariadb.com>
Date:   Sun Dec 15 21:31:34 2019 +0200

    Use private IP for Galera congiguration in maxscale-system-tests

commit 66dc36cbf43a5fb92465df31e1295e82865be1fc
Author: Timofey Turenko <timofey.turenko@mariadb.com>
Date:   Sun Dec 15 09:06:28 2019 +0200

    Fix typos in fwf_*.cpp

commit 44c7a4384ddf39596c0254c955aeb6c008a00a35
Author: Timofey Turenko <timofey.turenko@mariadb.com>
Date:   Sun Dec 15 09:05:26 2019 +0200

    Fix typos in fwf_*.cpp

commit 2649017611908a8b0d27090f49722947ac31c4f4
Author: Timofey Turenko <timofey.turenko@mariadb.com>
Date:   Sun Dec 15 09:03:41 2019 +0200

    Fix typos in fwf_*.cpp

commit 5cc87658523e8496eaab17700be8a821af5b0cde
Author: Timofey Turenko <timofey.turenko@mariadb.com>
Date:   Sat Dec 14 23:54:53 2019 +0200

    Fix typo in fwf_copy_rules.cpp

commit fb1accc36cb9d79691469f63cb4535f3bc38dedd
Author: Timofey Turenko <timofey.turenko@mariadb.com>
Date:   Sat Dec 14 23:52:51 2019 +0200

    More hardcoded 'vagrant' removals

commit 77e49d474b4abe767629ff87b01f08137773d761
Author: Timofey Turenko <timofey.turenko@mariadb.com>
Date:   Sat Dec 14 23:35:09 2019 +0200

    Fix hardcoded 'vagrant' user in fwf* tests

    Several firewall filter tests has hardcoded 'vagrant' as a user name for
    access user on the VM. Changed to node->access_user.

commit ed5ab1487f37822db6a7478f76c0f3652776c389
Author: Timofey Turenko <timofey.turenko@mariadb.com>
Date:   Sat Dec 14 22:50:35 2019 +0200

    Fix IP vs IP_private

    Many tests use IP instead of IP_private which makes them failed in the
    AWS or GCloud environment.
    The same applies to get_conn_num() etc functions.

commit 0558aac23d303a675dc12d05b1766e698753b444
Author: Timofey Turenko <timofey.turenko@mariadb.com>
Date:   Thu Aug 15 12:02:01 2019 +0300

    fix IP -> IP_private for some mysqlmon* testst

commit 5d9c70970d970eb995c8774d0088bd1c54ab76fe
Author: Timofey Turenko <timofey.turenko@mariadb.com>
Date:   Sat Dec 14 20:20:51 2019 +0200

    Replace IP to IP_private in the maxscale-system-tests

commit b06cf3329af59ff100748691991213fe639f29e6
Author: Timofey Turenko <timofey.turenko@mariadb.com>
Date:   Tue Nov 19 11:52:33 2019 +0200

    Remove spaces from value which were read from *_network_config

    MDBCI can put spaces around values in the *_network_config file which
    can cause ssh connection failures in the tests. To fix it removing all
    spaces from all values which were read from *_network_config

commit b3904f019847ef1db9d4ec9714ad9ef869fa0b01
Author: Timofey Turenko <timofey.turenko@mariadb.com>
Date:   Thu Dec 12 23:36:31 2019 +0200

    Increate default timeout for all system tests
2019-12-16 15:41:52 +02:00

145 lines
5.4 KiB
C++

/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2023-10-29
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#include <iostream>
#include <vector>
#include "testconnections.h"
#include "fail_switch_rejoin_common.cpp"
using std::string;
using std::cout;
int main(int argc, char** argv)
{
interactive = strcmp(argv[argc - 1], "interactive") == 0;
Mariadb_nodes::require_gtid(true);
TestConnections test(argc, argv);
test.repl->connect();
// Delete binlogs to sync gtid:s
delete_slave_binlogs(test);
// Set up test table
basic_test(test);
// Advance gtid:s a bit to so gtid variables are updated.
MYSQL* maxconn = test.maxscales->open_rwsplit_connection(0);
generate_traffic_and_check(test, maxconn, 10);
test.repl->sync_slaves(0);
test.tprintf(LINE);
print_gtids(test);
test.tprintf(LINE);
char result_tmp[bufsize];
string gtid_begin;
if (find_field(maxconn, GTID_QUERY, GTID_FIELD, result_tmp) == 0)
{
gtid_begin = result_tmp;
}
mysql_close(maxconn);
test.tprintf("Stopping MaxScale...");
// Mess with the slaves to fix situation such that only one slave can be rejoined. Stop maxscale.
if (test.stop_maxscale(0) != 0)
{
test.expect(false, "Could not stop MaxScale.");
return test.global_result;
}
// Leave first of three slaves connected so it's clear which one is the master server.
const char STOP_SLAVE[] = "STOP SLAVE;";
const char RESET_SLAVE[] = "RESET SLAVE ALL;";
const char READ_ONLY_OFF[] = "SET GLOBAL read_only=0;";
const int FIRST_MOD_NODE = 2; // Modify nodes 2 & 3
const int NODE_COUNT = test.repl->N;
MYSQL** nodes = test.repl->nodes;
for (int i = FIRST_MOD_NODE; i < NODE_COUNT; i++)
{
if ((mysql_query(nodes[i], STOP_SLAVE) != 0) || (mysql_query(nodes[i], RESET_SLAVE) != 0)
|| (mysql_query(nodes[i], READ_ONLY_OFF) != 0))
{
test.expect(false, "Could not stop slave connections and/or disable read_only for node %d.", i);
}
}
if (test.ok())
{
// Add more events to node3.
string gtid_node2, gtid_node3;
test.tprintf("Sending more inserts to server 4.");
generate_traffic_and_check(test, nodes[3], 10);
// Save gtids
if (find_field(nodes[2], GTID_QUERY, GTID_FIELD, result_tmp) == 0)
{
gtid_node2 = result_tmp;
}
if (find_field(nodes[3], GTID_QUERY, GTID_FIELD, result_tmp) == 0)
{
gtid_node3 = result_tmp;
}
print_gtids(test);
bool gtids_ok = (gtid_begin == gtid_node2 && gtid_node2 < gtid_node3);
test.expect(gtids_ok, "Gtid:s have not advanced correctly.");
}
test.tprintf("Restarting MaxScale. Server 4 should not rejoin the cluster.");
test.tprintf(LINE);
if (test.start_maxscale(0) != 0)
{
test.expect(false, "Could not start MaxScale.");
return test.global_result;
}
test.maxscales->wait_for_monitor(2);
get_output(test);
if (test.ok())
{
StringSet node2_states = test.get_server_status("server3");
StringSet node3_states = test.get_server_status("server4");
bool states_n2_ok = (node2_states.find("Slave") != node2_states.end());
bool states_n3_ok = (node3_states.find("Slave") == node3_states.end());
test.expect(states_n2_ok, "Node 2 has not rejoined when it should have.");
test.expect(states_n3_ok, "Node 3 rejoined when it shouldn't have.");
}
if (test.ok())
{
// Finally, fix replication by telling the current master to replicate from server4
test.tprintf(
"Setting server 1 to replicate from server 4. Auto-rejoin should redirect servers 2 and 3.");
const char CHANGE_CMD_FMT[] = "CHANGE MASTER TO MASTER_HOST = '%s', MASTER_PORT = %d, "
"MASTER_USE_GTID = current_pos, MASTER_USER='repl', MASTER_PASSWORD = 'repl';";
char change_cmd[256];
snprintf(change_cmd, sizeof(change_cmd), CHANGE_CMD_FMT, test.repl->IP_private[3], test.repl->port[3]);
test.try_query(nodes[0], "%s", change_cmd);
test.try_query(nodes[0], "START SLAVE;");
test.maxscales->wait_for_monitor(2);
get_output(test);
int master_id = get_master_server_id(test);
test.expect(master_id == 4, "Server 4 should be the cluster master.");
StringSet node0_states = test.get_server_status("server1");
bool states_n0_ok = (node0_states.find("Slave") != node0_states.end()
&& node0_states.find("Relay Master") == node0_states.end());
test.expect(states_n0_ok, "Server 1 is not a slave when it should be.");
}
cout << "Reseting cluster...\n";
int ec;
string reset_cmd = "maxadmin call command mysqlmon reset-replication MySQL-Monitor server1";
test.maxscales->ssh_node_output(0, reset_cmd.c_str(), true, &ec);
test.maxscales->wait_for_monitor(1);
test.expect(get_master_server_id(test) == 1, "server1 is not the master when it should. "
"reset-replication must have failed.");
return test.global_result;
}