int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    int global_result = 0;

    Test->read_env();
    Test->print_env();

    printf("Connecting to RWSplit %s\n", Test->maxscale_IP);
    Test->connect_rwsplit();

    printf("Setup firewall to block mysql on master\n"); fflush(stdout);
    Test->repl->block_node(0);

    printf("Trying query to RWSplit, expecting failure, but not a crash\n"); fflush(stdout);
    execute_query(Test->conn_rwsplit, (char *) "show processlist;");

    printf("Setup firewall back to allow mysql\n"); fflush(stdout);
    Test->repl->unblock_node(0);

    sleep(10);

    global_result += check_maxscale_alive();

    Test->close_rwsplit();


    printf("Reconnecting and trying query to RWSplit\n"); fflush(stdout);
    Test->connect_rwsplit();
    global_result += execute_query(Test->conn_rwsplit, (char *) "show processlist;");
    Test->close_rwsplit();

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

    Test->tprintf("Connecting to RWSplit\n");
    Test->conn_rwsplit = open_conn_no_db(Test->rwsplit_port, Test->maxscale_IP, Test->maxscale_user,
                                         Test->maxscale_password, Test->ssl);
    if (Test->conn_rwsplit == NULL)
    {
        Test->add_result(1, "Error connecting to MaxScale\n");
        delete Test;
        return 1;
    }
    Test->tprintf("Removing 'test' DB\n");
    execute_query(Test->conn_rwsplit, (char *) "DROP DATABASE IF EXISTS test;");
    Test->tprintf("Closing connections and waiting 5 seconds\n");
    Test->close_rwsplit();
    sleep(5);

    Test->tprintf("Connection to non-existing DB (all routers)\n");
    Test->connect_maxscale();
    Test->close_maxscale_connections();

    Test->tprintf("Connecting to RWSplit again to recreate 'test' db\n");
    Test->conn_rwsplit = open_conn_no_db(Test->rwsplit_port, Test->maxscale_IP, Test->maxscale_user,
                                         Test->maxscale_password, Test->ssl);
    if (Test->conn_rwsplit == NULL)
    {
        printf("Error connecting to MaxScale\n");
        delete Test;
        return 1;
    }

    Test->tprintf("Creating and selecting 'test' DB\n");
    Test->try_query(Test->conn_rwsplit, (char *) "CREATE DATABASE test; USE test");
    Test->tprintf("Creating 't1' table\n");
    Test->add_result(create_t1(Test->conn_rwsplit), "Error creation 't1'\n");
    Test->close_rwsplit();

    Test->tprintf("Reconnectiong\n");
    Test->add_result(Test->connect_maxscale(), "error connection to Maxscale\n");
    Test->tprintf("Trying simple operations with t1 \n");
    Test->try_query(Test->conn_rwsplit, (char *) "INSERT INTO t1 (x1, fl) VALUES(0, 1);");
    Test->set_timeout(240);
    Test->add_result(execute_select_query_and_check(Test->conn_rwsplit, (char *) "SELECT * FROM t1;", 1),
                     "Error execution SELECT * FROM t1;\n");

    Test->close_maxscale_connections();

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

    Test->galera->connect();

    tolerance = 0;

    // connect to the MaxScale server (rwsplit)
    Test->connect_rwsplit();

    Test->execute_maxadmin_command((char *) "shutdown monitor \"Galera Monitor\"");

    if (Test->conn_rwsplit == NULL )
    {
        Test->add_result(1, "Can't connect to MaxScale\n");
        int rval = Test->global_result;
        delete Test;
        exit(1);
    }
    else
    {

        Test->try_query(Test->conn_rwsplit, "DROP TABLE IF EXISTS t1;");
        Test->try_query(Test->conn_rwsplit, "create table t1 (x1 int);");

        get_global_status_allnodes(&selects[0], &inserts[0], Test->galera, silent);
        Test->try_query(Test->conn_rwsplit, "select * from t1;");
        get_global_status_allnodes(&new_selects[0], &new_inserts[0], Test->galera, silent);
        print_delta(&new_selects[0], &new_inserts[0], &selects[0], &inserts[0], Test->galera->N);

        Test->try_query(Test->conn_rwsplit, "insert into t1 values(1);");
        get_global_status_allnodes(&new_selects[0], &new_inserts[0], Test->galera, silent);
        print_delta(&new_selects[0], &new_inserts[0], &selects[0], &inserts[0], Test->galera->N);

        // close connections
        Test->close_rwsplit();
    }
    Test->galera->close_connections();

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

    Test->tprintf("Connecting to RWSplit %s\n", Test->maxscale_ip());
    Test->connect_rwsplit();

    unsigned int conn_num;
    unsigned int all_conn = 0;
    Test->tprintf("Sleeping 5 seconds\n");
    sleep(5);
    Test->tprintf("Checking number of connections ot backend servers\n");
    for (int i = 0; i < Test->repl->N; i++)
    {
        conn_num = get_conn_num(Test->repl->nodes[i], Test->maxscale_ip(), Test->maxscale_hostname, (char *) "test");
        Test->tprintf("connections: %u\n", conn_num);
        if ((i == 0) && (conn_num != 1))
        {
            Test->add_result(1, " Master should have only 1 connection, but it has %d connection(s)\n", conn_num);
        }
        all_conn += conn_num;
    }
    if (all_conn != 2)
    {
        Test->add_result(1,
                         "there should be two connections in total: one to master and one to one of slaves, but number of connections is %d\n",
                         all_conn);
    }

    Test->close_rwsplit();
    Test->repl->close_connections();

    int rval = Test->global_result;
    delete Test;
    return rval;
}