refactored tests (#147)

This commit is contained in:
Timofey Turenko
2017-12-08 12:23:04 +02:00
committed by GitHub
parent c6daf8c26b
commit 3c88bf1ec6
253 changed files with 5265 additions and 3649 deletions

View File

@ -15,13 +15,14 @@
int main(int argc, char *argv[])
{
int exit_code;
TestConnections * test = new TestConnections(argc, argv);
test->tprintf(" Create the test table and insert some data ");
test->connect_maxscale();
test->try_query(test->conn_rwsplit, "CREATE OR REPLACE TABLE test.t1 (id int)");
test->try_query(test->conn_rwsplit, "INSERT INTO test.t1 VALUES (1)");
test->close_maxscale_connections();
test->maxscales->connect_maxscale(0);
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->maxscales->close_maxscale_connections(0);
test->tprintf(" Block all but one node ");
test->repl->block_node(0);
@ -34,12 +35,12 @@ int main(int argc, char *argv[])
sleep(15);
test->tprintf(" Connect and insert should work ");
char *output = test->ssh_maxscale_output(true, "maxadmin list servers");
char *output = test->maxscales->ssh_node_output(0, "maxadmin list servers", true, &exit_code);
test->tprintf("%s", output);
free(output);
test->connect_maxscale();
test->try_query(test->conn_rwsplit, "INSERT INTO test.t1 VALUES (1)");
test->close_maxscale_connections();
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->tprintf(" Unblock nodes ");
test->repl->unblock_node(0);
@ -52,18 +53,18 @@ int main(int argc, char *argv[])
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->connect_maxscale();
test->try_query(test->conn_rwsplit, "INSERT INTO test.t1 VALUES (1)");
test->maxscales->connect_maxscale(0);
test->try_query(test->maxscales->conn_rwsplit[0], "INSERT INTO test.t1 VALUES (1)");
char maxscale_id[256], real_id[256];
find_field(test->conn_rwsplit, "SELECT @@server_id", "@@server_id", maxscale_id);
find_field(test->maxscales->conn_rwsplit[0], "SELECT @@server_id", "@@server_id", maxscale_id);
test->repl->connect();
find_field(test->repl->nodes[3], "SELECT @@server_id", "@@server_id", real_id);
test->add_result(strcmp(maxscale_id, real_id) != 0,
"@@server_id is different: %s != %s", maxscale_id, real_id);
test->close_maxscale_connections();
test->maxscales->close_maxscale_connections(0);
test->tprintf(" Check that MaxScale is running ");
test->check_maxscale_alive();
test->check_maxscale_alive(0);
int rval = test->global_result;
delete test;