コード例 #1
0
int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    char sql[10240];

    Test->connect_maxscale();
    create_t1(Test->conn_rwsplit);

    Test->tprintf("INSERTing data\n");
    for (int i = 0; i < 2000; i++)
    {
        Test->set_timeout(20);
        create_insert_string(sql, 100, i);
        Test->try_query(Test->conn_rwsplit, sql);
    }
    Test->tprintf("done, sleeping\n");
    Test->stop_timeout();
    sleep(20);
    Test->tprintf("Trying SELECT\n");
    Test->set_timeout(30);
    Test->try_query(Test->conn_rwsplit, (char *) "SELECT * FROM t1");

    Test->check_maxscale_alive();
    int rval = Test->global_result;
    delete Test;
    return rval;
}
コード例 #2
0
int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    Test->set_timeout(10);

    Test->connect_maxscale();

    Test->set_timeout(10);
    Test->tprintf("Trying USE db against RWSplit\n");
    Test->try_query(Test->conn_rwsplit, (char *) "USE mysql");
    Test->try_query(Test->conn_rwsplit, (char *) "USE test");
    Test->set_timeout(10);
    Test->tprintf("Trying USE db against ReadConn master\n");
    Test->try_query(Test->conn_master, (char *) "USE mysql");
    Test->try_query(Test->conn_master, (char *) "USE test");
    Test->set_timeout(10);
    Test->tprintf("Trying USE db against ReadConn slave\n");
    Test->try_query(Test->conn_master, (char *) "USE mysql");
    Test->try_query(Test->conn_slave, (char *) "USE test");

    Test->set_timeout(10);
    Test->close_maxscale_connections();

    Test->check_maxscale_alive();
    int rval = Test->global_result;
    delete Test;
    return rval;
}
コード例 #3
0
int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    Test->set_timeout(10);
    int i;

    Test->repl->connect();
    Test->connect_maxscale();

    Test->tprintf("Trying SHOW VARIABLES to different Maxscale services\n");
    fflush(stdout);
    Test->tprintf("RWSplit\n");
    for (i = 0; i < 100; i++)
    {
        Test->set_timeout(5);
        Test->try_query(Test->conn_rwsplit, (char *) "SHOW VARIABLES;");
    }
    Test->tprintf("ReadConn master\n");
    for (i = 0; i < 100; i++)
    {
        Test->set_timeout(5);
        Test->try_query(Test->conn_master, (char *) "SHOW VARIABLES;");
    }
    Test->tprintf("ReadConn slave\n");
    for (i = 0; i < 100; i++)
    {
        Test->set_timeout(5);
        Test->try_query(Test->conn_slave, (char *) "SHOW VARIABLES;");
    }

    Test->tprintf("All in one loop\n");
    for (i = 0; i < 100; i++)
    {
        Test->set_timeout(5);
        Test->try_query(Test->conn_rwsplit, (char *) "SHOW VARIABLES;");
        Test->try_query(Test->conn_master, (char *) "SHOW VARIABLES;");
        Test->try_query(Test->conn_slave, (char *) "SHOW VARIABLES;");
    }

    Test->set_timeout(10);
    Test->close_maxscale_connections();
    Test->repl->close_connections();

    Test->check_maxscale_alive();

    int rval = Test->global_result;
    delete Test;
    return rval;
}
コード例 #4
0
int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    Test->set_timeout(30);

    Test->ssh_maxscale(true, "maxkeys");
    Test->ssh_maxscale(true, "sudo chown maxscale:maxscale /var/lib/maxscale/.secrets");

    try_password(Test, (char *) "aaa$aaa");
    try_password(Test, (char *) "#¤&");
    try_password(Test, (char *) "пароль");

    Test->check_maxscale_alive();
    int rval = Test->global_result;
    delete Test;
    return rval;
}
コード例 #5
0
int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);

    Test->tprintf("Trying 11 connections with RWSplit\n");
    check_max_conn(0, 10, Test);
    Test->tprintf("Trying 21 connections with Readconn master\n");
    check_max_conn(1, 20, Test);
    Test->tprintf("Trying 26 connections with Readconnn slave\n");
    check_max_conn(2, 25, Test);

    sleep(10);

    Test->check_maxscale_alive();
    int rval = Test->global_result;
    delete Test;
    return rval;
}
コード例 #6
0
int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    Test->set_timeout(20);
    int i, j;
    MYSQL * conn;

    int N_cmd = 2;
    char * fail_cmd[N_cmd - 1];

    int N_ports = 3;
    int ports[N_ports];

    fail_cmd[0] = (char *) "fail backendfd";
    fail_cmd[1] = (char *) "fail clientfd";

    ports[0] = Test->rwsplit_port;
    ports[1] = Test->readconn_master_port;
    ports[2] = Test->readconn_slave_port;

    for (i = 0; i < N_cmd; i++)
    {
        for (j = 0; j < N_ports; j++)
        {
            Test->tprintf("Executing MaxAdmin command '%s'\n", fail_cmd[i]);
            if (execute_maxadmin_command(Test->maxscale_IP, (char *) "admin", Test->maxadmin_password, fail_cmd[i]) != 0)
            {
                Test->add_result(1, "MaxAdmin command failed\n");
            }
            else
            {
                printf("Trying query against %d\n", ports[j]);
                conn = open_conn(ports[j], Test->maxscale_IP, Test->maxscale_user, Test->maxscale_user, Test->ssl);
                Test->try_query(conn, (char *) "show processlist;");
            }
        }
    }

    Test->check_maxscale_alive();
    int rval = Test->global_result;
    delete Test;
    return rval;
}
int main(int argc, char *argv[])
{
    TestConnections *test = new TestConnections(argc, argv);
    Config config(test);

    config.create_all_listeners();
    config.create_all_listeners();
    test->check_maxscale_processes(1);

    config.create_monitor("mysql-monitor", "mysqlmon", 500);
    config.reset();

    sleep(1);

    test->check_maxscale_alive();
    int rval = test->global_result;
    delete test;
    return rval;
}
int main(int argc, char *argv[])
{

    TestConnections * Test = new TestConnections(argc, argv);
    int master;
    long int q;
    int threads_num = 25;

    long int selects[256];
    long int inserts[256];
    long int new_selects[256];
    long int new_inserts[256];
    long int i1, i2;

    Test->set_timeout(20);
    master = Test->find_master_maxadmin(Test->galera);

    if (master >= 0)
    {
        Test->tprintf("Master node is %d (server%d)\n", master, master + 1);
        Test->set_timeout(20);

        if (Test->smoke)
        {
            threads_num = 15;
        }
        Test->galera->connect();
        for (int i = 0; i < Test->galera->N; i++)
        {
            execute_query(Test->galera->nodes[i], (char *) "set global max_connections = 300;");
            execute_query(Test->galera->nodes[i], (char *) "set global max_connect_errors = 100000;");
        }
        Test->galera->close_connections();

        Test->set_timeout(1200);
        load(&new_inserts[0], &new_selects[0], &selects[0], &inserts[0], threads_num, Test, &i1, &i2, 1, true, true);

        long int avr = (i1 + i2 ) / (Test->galera->N);
        Test->tprintf("average number of quries per node %ld\n", avr);
        long int min_q = avr / 3;
        long int max_q = avr * 3;
        Test->tprintf("Acceplable value for every node from %ld until %ld\n", min_q, max_q);

        for (int i = 0; i < Test->galera->N; i++)
        {
            if ( i != master)
            {
                q = new_selects[i] - selects[i];
                if ((q > max_q) || (q < min_q))
                {
                    Test->add_result(1, "number of queries for node %d is %ld\n", i + 1, q);
                }
            }
        }

        if ((new_selects[master] - selects[master]) > avr / 3 )
        {
            Test->add_result(1,
                             "number of queries for master greater then 30%% of averange number of queries per node\n");
        }

        Test->tprintf("Restoring nodes\n");
        Test->galera->connect();
        for (int i = 0; i < Test->galera->N; i++)
        {
            execute_query(Test->galera->nodes[i], (char *) "flush hosts;");
            execute_query(Test->galera->nodes[i], (char *) "set global max_connections = 151;");
        }
        Test->galera->close_connections();

        Test->check_maxscale_alive();
    }
    else
    {
        Test->add_result(1, "Master is not found\n");
    }

    int rval = Test->global_result;
    delete Test;
    return rval;
}
int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    Test->set_timeout(10);

    Test->connect_maxscale();

    Test->set_timeout(10);
    Test->try_query(Test->conn_rwsplit, (char *) "SET @a=1");
    Test->stop_timeout();
    sleep(1);
    Test->set_timeout(20);
    Test->tprintf("Blocking first slave\n");
    Test->repl->block_node(1);
    Test->stop_timeout();
    sleep(5);
    Test->set_timeout(10);
    Test->tprintf("Unblocking first slave and blocking second slave\n");

    Test->repl->unblock_node(1);
    Test->stop_timeout();
    sleep(5);
    Test->repl->block_node(2);
    Test->stop_timeout();
    sleep(5);
    Test->set_timeout(20);

    int retries;

    for (retries = 0; retries < 10; retries++)
    {
        char server1_status[256];
        Test->get_maxadmin_param((char *) "show server server2", (char *) "Status", server1_status);
        if (strstr(server1_status, "Running"))
        {
            break;
        }
        sleep(1);
    }

    Test->add_result(retries == 10, "Slave is not recovered, slave status is not Running\n");

    Test->repl->connect();
    int real_id = Test->repl->get_server_id(1);

    char server_id[200] = "";
    find_field(Test->conn_rwsplit, "SELECT @@server_id", "@@server_id", server_id);
    int queried_id = atoi(server_id);

    Test->add_result(queried_id != real_id, "The query server ID '%d' does not match the one from server '%d'. "
                     "Slave was not recovered.", queried_id, real_id);

    char userval[200] = "";
    find_field(Test->conn_rwsplit, "SELECT @a", "@a", userval);

    Test->add_result(atoi(userval) != 1, "User variable @a is not 1, it is '%s'", userval);

    Test->tprintf("Unblocking second slave\n");
    Test->repl->unblock_node(2);

    Test->check_maxscale_alive();
    int rval = Test->global_result;
    delete Test;
    return rval;
}