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
		
			
				
	
	
		
			168 lines
		
	
	
		
			6.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			168 lines
		
	
	
		
			6.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
/**
 | 
						|
 * @file mysqlmon_detect_standalone_master.cpp MySQL Monitor Standalone Master Test
 | 
						|
 * - block all nodes, but one
 | 
						|
 * - wait for monitor (monitor_interval), monitor should select remaining node as master
 | 
						|
 * - check maxadmin output
 | 
						|
 * - check that queries work
 | 
						|
 * - unblock backend nodes
 | 
						|
 * - wait for monitor
 | 
						|
 * - check that monitor is still using the same node and that the old nodes are in maintenance mode
 | 
						|
 */
 | 
						|
 | 
						|
#include <iostream>
 | 
						|
#include <sstream>
 | 
						|
#include "testconnections.h"
 | 
						|
#include "fail_switch_rejoin_common.cpp"
 | 
						|
 | 
						|
using std::stringstream;
 | 
						|
using std::cout;
 | 
						|
using std::endl;
 | 
						|
 | 
						|
void check_maxscale(TestConnections& test)
 | 
						|
{
 | 
						|
    test.tprintf("Connecting to Maxscale\n");
 | 
						|
    test.add_result(test.maxscales->connect_maxscale(0), "Can not connect to Maxscale\n");
 | 
						|
    test.tprintf("Trying simple query against all sevices\n");
 | 
						|
    test.tprintf("RWSplit \n");
 | 
						|
    test.try_query(test.maxscales->conn_rwsplit[0], (char*) "show databases;");
 | 
						|
    test.tprintf("ReadConn Master \n");
 | 
						|
    test.try_query(test.maxscales->conn_master[0], (char*) "show databases;");
 | 
						|
}
 | 
						|
 | 
						|
void replicate_from(TestConnections& test, int server_ind, int target_ind)
 | 
						|
{
 | 
						|
    stringstream change_master;
 | 
						|
    change_master << "CHANGE MASTER TO MASTER_HOST = '" << test.repl->IP_private[target_ind]
 | 
						|
                  << "', MASTER_PORT = " << test.repl->port[target_ind] << ", MASTER_USE_GTID = current_pos, "
 | 
						|
                                                             "MASTER_USER='repl', MASTER_PASSWORD='repl';";
 | 
						|
    cout << "Server " << server_ind + 1 << " starting to replicate from server " << target_ind + 1 << endl;
 | 
						|
    if (test.verbose)
 | 
						|
    {
 | 
						|
        cout << "Query is '" << change_master.str() << "'" << endl;
 | 
						|
    }
 | 
						|
    test.try_query(test.repl->nodes[server_ind], "STOP SLAVE;");
 | 
						|
    test.try_query(test.repl->nodes[server_ind], "%s", change_master.str().c_str());
 | 
						|
    test.try_query(test.repl->nodes[server_ind], "START SLAVE;");
 | 
						|
}
 | 
						|
 | 
						|
void restore_servers(TestConnections& test, bool events_added)
 | 
						|
{
 | 
						|
    test.repl->unblock_node(0);
 | 
						|
    test.repl->unblock_node(1);
 | 
						|
    test.repl->unblock_node(2);
 | 
						|
    int dummy;
 | 
						|
    char* o1 = test.maxscales->ssh_node_output(0, "maxadmin clear server server1 Maint", true, &dummy);
 | 
						|
    char* o2 = test.maxscales->ssh_node_output(0, "maxadmin clear server server2 Maint", true, &dummy);
 | 
						|
    char* o3 = test.maxscales->ssh_node_output(0, "maxadmin clear server server3 Maint", true, &dummy);
 | 
						|
    free(o1);
 | 
						|
    free(o2);
 | 
						|
    free(o3);
 | 
						|
    if (events_added)
 | 
						|
    {
 | 
						|
        // Events have been added to server4, so it must be the real new master. Then switchover to server1.
 | 
						|
        replicate_from(test, 0, 3);
 | 
						|
        replicate_from(test, 1, 3);
 | 
						|
        replicate_from(test, 2, 3);
 | 
						|
        test.maxscales->wait_for_monitor();
 | 
						|
        o1 = test.maxscales->ssh_node_output(0,
 | 
						|
                                             "maxadmin call command mariadbmon switchover MySQL-Monitor server1 server4",
 | 
						|
                                             true,
 | 
						|
                                             &dummy);
 | 
						|
        test.maxscales->wait_for_monitor();
 | 
						|
        int master_id = get_master_server_id(test);
 | 
						|
        test.expect(master_id == 1, "Switchover failed to set server1 as master.");
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
        // No events added, it should be enough to start slave on server4
 | 
						|
        replicate_from(test, 3, 0);
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
int main(int argc, char* argv[])
 | 
						|
{
 | 
						|
    Mariadb_nodes::require_gtid(true);
 | 
						|
    TestConnections test(argc, argv);
 | 
						|
    test.maxscales->connect_maxscale(0);
 | 
						|
    test.repl->connect();
 | 
						|
    delete_slave_binlogs(test);
 | 
						|
    print_gtids(test);
 | 
						|
    test.tprintf(" Create the test table and insert some data ");
 | 
						|
    test.try_query(test.maxscales->conn_rwsplit[0], "CREATE OR REPLACE TABLE test.t1 (id int)");
 | 
						|
    test.try_query(test.maxscales->conn_rwsplit[0], "INSERT INTO test.t1 VALUES (1)");
 | 
						|
    test.repl->sync_slaves();
 | 
						|
 | 
						|
    print_gtids(test);
 | 
						|
 | 
						|
    test.maxscales->close_maxscale_connections(0);
 | 
						|
    if (test.global_result != 0)
 | 
						|
    {
 | 
						|
        return test.global_result;
 | 
						|
    }
 | 
						|
 | 
						|
    test.tprintf(" Block all but one node, stop slave on server 4 ");
 | 
						|
    test.repl->block_node(0);
 | 
						|
    test.repl->block_node(1);
 | 
						|
    test.repl->block_node(2);
 | 
						|
 | 
						|
    test.try_query(test.repl->nodes[3], "STOP SLAVE;RESET SLAVE ALL;");
 | 
						|
 | 
						|
    test.tprintf(" Wait for the monitor to detect it ");
 | 
						|
    test.maxscales->wait_for_monitor(3);
 | 
						|
 | 
						|
    test.tprintf(" Connect and insert should work ");
 | 
						|
    get_output(test);
 | 
						|
 | 
						|
    int master_id = get_master_server_id(test);
 | 
						|
    test.expect(master_id == 4, "Server 4 should be master, but master is server %d.", master_id);
 | 
						|
 | 
						|
    if (test.global_result != 0)
 | 
						|
    {
 | 
						|
        restore_servers(test, false);
 | 
						|
        return test.global_result;
 | 
						|
    }
 | 
						|
 | 
						|
    test.maxscales->connect_maxscale(0);
 | 
						|
    test.try_query(test.maxscales->conn_rwsplit[0], "INSERT INTO test.t1 VALUES (1)");
 | 
						|
    test.maxscales->close_maxscale_connections(0);
 | 
						|
    test.repl->connect(3);
 | 
						|
    char result_tmp[bufsize];
 | 
						|
    if (find_field(test.repl->nodes[3], GTID_QUERY, GTID_FIELD, result_tmp) == 0)
 | 
						|
    {
 | 
						|
        test.tprintf("Node 3 gtid: %s", result_tmp);
 | 
						|
    }
 | 
						|
 | 
						|
    test.tprintf("Unblock nodes ");
 | 
						|
    test.repl->unblock_node(0);
 | 
						|
    test.repl->unblock_node(1);
 | 
						|
    test.repl->unblock_node(2);
 | 
						|
 | 
						|
    test.tprintf(" Wait for the monitor to detect it ");
 | 
						|
    test.maxscales->wait_for_monitor();
 | 
						|
 | 
						|
    test.tprintf("Check that we are still using the last node to which we failed over "
 | 
						|
                 "to and that the old nodes are in maintenance mode");
 | 
						|
 | 
						|
    test.maxscales->connect_maxscale(0);
 | 
						|
    get_output(test);
 | 
						|
 | 
						|
    test.try_query(test.maxscales->conn_rwsplit[0], "INSERT INTO test.t1 VALUES (1)");
 | 
						|
    master_id = get_master_server_id(test);
 | 
						|
    test.tprintf("Master server id is %d", master_id);
 | 
						|
 | 
						|
    test.repl->connect();
 | 
						|
    int real_id = test.repl->get_server_id(3);
 | 
						|
    test.expect(master_id == real_id, "@@server_id is different: %d != %d", master_id, real_id);
 | 
						|
    print_gtids(test);
 | 
						|
    test.maxscales->close_maxscale_connections(0);
 | 
						|
 | 
						|
    test.tprintf("Check that MaxScale is running");
 | 
						|
    check_maxscale(test);
 | 
						|
    if (test.global_result == 0)
 | 
						|
    {
 | 
						|
        cout << "Test successful, restoring original state." << endl;
 | 
						|
        restore_servers(test, true);
 | 
						|
    }
 | 
						|
    return test.global_result;
 | 
						|
}
 |