Merge branch '2.2' into develop
This commit is contained in:
commit
edd5ddcc88
@ -24,10 +24,10 @@ void alter_readwritesplit(TestConnections& test)
|
||||
second.connect();
|
||||
|
||||
// Check that writes work for both connections
|
||||
test.assert(first.query("SELECT @@last_insert_id"),
|
||||
test.expect(first.query("SELECT @@last_insert_id"),
|
||||
"Write to first connection should work: %s",
|
||||
first.error());
|
||||
test.assert(second.query("SELECT @@last_insert_id"),
|
||||
test.expect(second.query("SELECT @@last_insert_id"),
|
||||
"Write to second connection should work: %s",
|
||||
second.error());
|
||||
|
||||
@ -36,9 +36,9 @@ void alter_readwritesplit(TestConnections& test)
|
||||
test.maxscales->wait_for_monitor();
|
||||
|
||||
// Check that reads work for the newer connection and fail for the older one
|
||||
test.assert(!first.query("SELECT 1"),
|
||||
test.expect(!first.query("SELECT 1"),
|
||||
"Read to first connection should fail.");
|
||||
test.assert(second.query("SELECT 1"),
|
||||
test.expect(second.query("SELECT 1"),
|
||||
"Read to second connection should work: %s",
|
||||
second.error());
|
||||
|
||||
@ -48,14 +48,14 @@ void alter_readwritesplit(TestConnections& test)
|
||||
test.maxscales->restart();
|
||||
|
||||
third.connect();
|
||||
test.assert(third.query("SELECT @@last_insert_id"),
|
||||
test.expect(third.query("SELECT @@last_insert_id"),
|
||||
"Write to third connection should work: %s",
|
||||
third.error());
|
||||
|
||||
test.repl->block_node(0);
|
||||
test.maxscales->wait_for_monitor();
|
||||
|
||||
test.assert(third.query("SELECT 1"),
|
||||
test.expect(third.query("SELECT 1"),
|
||||
"Read to third connection should work: %s",
|
||||
third.error());
|
||||
|
||||
@ -76,7 +76,7 @@ void alter_readconnroute(TestConnections& test)
|
||||
conn.connect();
|
||||
Row row = conn.row("SELECT @@server_id");
|
||||
conn.disconnect();
|
||||
test.assert(row[0] == master_id,
|
||||
test.expect(row[0] == master_id,
|
||||
"First connection should use master: %s != %s",
|
||||
row[0].c_str(),
|
||||
master_id.c_str());
|
||||
@ -89,7 +89,7 @@ void alter_readconnroute(TestConnections& test)
|
||||
conn.connect();
|
||||
Row row = conn.row("SELECT @@server_id");
|
||||
conn.disconnect();
|
||||
test.assert(row[0] != master_id,
|
||||
test.expect(row[0] != master_id,
|
||||
"Second connection should not use master: %s == %s",
|
||||
row[0].c_str(),
|
||||
master_id.c_str());
|
||||
@ -100,22 +100,22 @@ void alter_schemarouter(TestConnections& test)
|
||||
{
|
||||
Connection conn = test.maxscales->readconn_slave();
|
||||
conn.connect();
|
||||
test.assert(!conn.query("SELECT 1"), "Query before reconfiguration should fail");
|
||||
test.expect(!conn.query("SELECT 1"), "Query before reconfiguration should fail");
|
||||
conn.disconnect();
|
||||
|
||||
test.check_maxctrl("alter service SchemaRouter ignore_databases_regex '.*'");
|
||||
|
||||
conn.connect();
|
||||
test.assert(conn.query("SELECT 1"), "Query after reconfiguration should work: %s", conn.error());
|
||||
test.expect(conn.query("SELECT 1"), "Query after reconfiguration should work: %s", conn.error());
|
||||
conn.disconnect();
|
||||
}
|
||||
|
||||
void alter_unsupported(TestConnections& test)
|
||||
{
|
||||
int rc = test.maxscales->ssh_node_f(0, true, "maxctrl alter service RW-Split-Router unknown parameter");
|
||||
test.assert(rc != 0, "Unknown router parameter should be detected");
|
||||
test.expect(rc != 0, "Unknown router parameter should be detected");
|
||||
rc = test.maxscales->ssh_node_f(0, true, "maxctrl alter service RW-Split-Router filters Regex");
|
||||
test.assert(rc != 0, "Unsupported router parameter should be detected");
|
||||
test.expect(rc != 0, "Unsupported router parameter should be detected");
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
@ -35,7 +35,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
test.set_timeout(30);
|
||||
test.tprintf("Connecting to all MaxScale services, expecting no errors");
|
||||
test.assert(test.maxscales->connect_maxscale(0) == 0, "Connection should not fail");
|
||||
test.expect(test.maxscales->connect_maxscale(0) == 0, "Connection should not fail");
|
||||
|
||||
test.set_timeout(30);
|
||||
test.tprintf("Trying some queries, expecting no failures");
|
||||
|
@ -88,12 +88,12 @@ void select(TestConnections& test, int* pValue)
|
||||
}
|
||||
while (mysql_next_result(pMysql) == 0);
|
||||
|
||||
test.assert(nRows == 1, "Unexpected number of rows: %u", nRows);
|
||||
test.expect(nRows == 1, "Unexpected number of rows: %u", nRows);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
test.assert(false, "SELECT failed.");
|
||||
test.expect(false, "SELECT failed.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ void run(TestConnections& test)
|
||||
set(test, Cache::POPULATE, true);
|
||||
set(test, Cache::USE, false);
|
||||
select(test, &value);
|
||||
test.assert(value == 1, "Initial value was not 1.");
|
||||
test.expect(value == 1, "Initial value was not 1.");
|
||||
|
||||
// And update the real value.
|
||||
update(test, 2); // Now the cache contains 1 and the db 2.
|
||||
@ -149,14 +149,14 @@ void run(TestConnections& test)
|
||||
set(test, Cache::POPULATE, false);
|
||||
set(test, Cache::USE, false);
|
||||
select(test, &value);
|
||||
test.assert(value == 2, "The value received was not the latest one.");
|
||||
test.expect(value == 2, "The value received was not the latest one.");
|
||||
|
||||
// With @maxscale.cache.use==true we should get the old one, since
|
||||
// it was not updated above as @maxscale.cache.populate==false.
|
||||
set(test, Cache::POPULATE, false);
|
||||
set(test, Cache::USE, true);
|
||||
select(test, &value);
|
||||
test.assert(value == 1, "The value received was not the populated one.");
|
||||
test.expect(value == 1, "The value received was not the populated one.");
|
||||
|
||||
// The hard_ttl is 8, so we sleep(10) seconds to ensure that TTL has passed.
|
||||
cout << "Sleeping 10 seconds." << endl;
|
||||
@ -168,7 +168,7 @@ void run(TestConnections& test)
|
||||
set(test, Cache::POPULATE, false);
|
||||
set(test, Cache::USE, true);
|
||||
select(test, &value);
|
||||
test.assert(value == 2, "The cache was not updated even if TTL was passed.");
|
||||
test.expect(value == 2, "The cache was not updated even if TTL was passed.");
|
||||
|
||||
// Let's update again
|
||||
update(test, 3);
|
||||
@ -177,13 +177,13 @@ void run(TestConnections& test)
|
||||
set(test, Cache::POPULATE, false);
|
||||
set(test, Cache::USE, true);
|
||||
select(test, &value);
|
||||
test.assert(value == 2, "New value %d, although the value in the cache is not stale.", value);
|
||||
test.expect(value == 2, "New value %d, although the value in the cache is not stale.", value);
|
||||
|
||||
// Force an update.
|
||||
set(test, Cache::POPULATE, true);
|
||||
set(test, Cache::USE, false);
|
||||
select(test, &value);
|
||||
test.assert(value == 3, "Did not get new value.");
|
||||
test.expect(value == 3, "Did not get new value.");
|
||||
|
||||
// And check that the cache indeed was updated, but update the DB first.
|
||||
update(test, 4);
|
||||
@ -191,7 +191,7 @@ void run(TestConnections& test)
|
||||
set(test, Cache::POPULATE, false);
|
||||
set(test, Cache::USE, true);
|
||||
select(test, &value);
|
||||
test.assert(value == 3, "Got a newer value than expected.");
|
||||
test.expect(value == 3, "Got a newer value than expected.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,12 +97,12 @@ void select(TestConnections& test, Column column, int* pValue)
|
||||
}
|
||||
while (mysql_next_result(pMysql) == 0);
|
||||
|
||||
test.assert(nRows == 1, "Unexpected number of rows: %u", nRows);
|
||||
test.expect(nRows == 1, "Unexpected number of rows: %u", nRows);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
test.assert(false, "SELECT failed.");
|
||||
test.expect(false, "SELECT failed.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,9 +150,9 @@ void run(TestConnections& test)
|
||||
set(test, Cache::HARD_TTL, 60);
|
||||
// And update the cache.
|
||||
select(test, Column::A, &value);
|
||||
test.assert(value == 1, "Initial value was not 1.");
|
||||
test.expect(value == 1, "Initial value was not 1.");
|
||||
select(test, Column::B, &value);
|
||||
test.assert(value == 1, "Initial value was not 1.");
|
||||
test.expect(value == 1, "Initial value was not 1.");
|
||||
|
||||
// Update the real value.
|
||||
update(test, Column::A, 2); // Now the cache contains 1 and the db 2.
|
||||
@ -165,14 +165,14 @@ void run(TestConnections& test)
|
||||
// is fetched from the server.
|
||||
set(test, Cache::SOFT_TTL, 4);
|
||||
select(test, Column::A, &value);
|
||||
test.assert(value == 2, "The value received was not the latest one.");
|
||||
test.expect(value == 2, "The value received was not the latest one.");
|
||||
|
||||
// With a soft_ttl larger that the amount we slept should mean that
|
||||
// the value in the cache is *not* considered stale and that we
|
||||
// get that value.
|
||||
set(test, Cache::SOFT_TTL, 10);
|
||||
select(test, Column::B, &value);
|
||||
test.assert(value == 1, "The value received was not from the cache.");
|
||||
test.expect(value == 1, "The value received was not from the cache.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// Do the select inside a transacttion so that it gets routed to the master
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "BEGIN");
|
||||
test.assert(execute_query_check_one(test.maxscales->conn_rwsplit[0], "SELECT id FROM test.t1", "2") == 0,
|
||||
test.expect(execute_query_check_one(test.maxscales->conn_rwsplit[0], "SELECT id FROM test.t1", "2") == 0,
|
||||
"Table should contain one row with value 2");
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "COMMIT");
|
||||
|
||||
|
@ -89,7 +89,7 @@ void different_packet_size(TestConnections* Test, bool binlog)
|
||||
|
||||
char* event = create_event_size(size);
|
||||
conn = connect_to_serv(Test, binlog);
|
||||
Test->assert(execute_query_silent(conn, event) == 0, "Query should succeed");
|
||||
Test->expect(execute_query_silent(conn, event) == 0, "Query should succeed");
|
||||
free(event);
|
||||
execute_query_silent(conn, (char*) "DELETE FROM test.large_event");
|
||||
mysql_close(conn);
|
||||
|
@ -163,7 +163,7 @@ bool generate_traffic_and_check(TestConnections& test, MYSQL* conn, int insert_c
|
||||
|
||||
mysql_query(conn, SELECT);
|
||||
MYSQL_RES* res = mysql_store_result(conn);
|
||||
test.assert(res != NULL, "Query did not return a result set");
|
||||
test.expect(res != NULL, "Query did not return a result set");
|
||||
|
||||
if (res)
|
||||
{
|
||||
@ -176,14 +176,14 @@ bool generate_traffic_and_check(TestConnections& test, MYSQL* conn, int insert_c
|
||||
int value_read = strtol(row[0], NULL, 0);
|
||||
if (value_read != expected_val)
|
||||
{
|
||||
test.assert(false, "Query returned %d when %d was expected", value_read, expected_val);
|
||||
test.expect(false, "Query returned %d when %d was expected", value_read, expected_val);
|
||||
rval = false;
|
||||
break;
|
||||
}
|
||||
expected_val++;
|
||||
}
|
||||
int num_rows = expected_val;
|
||||
test.assert(num_rows == inserts,
|
||||
test.expect(num_rows == inserts,
|
||||
"Query returned %d rows when %d rows were expected",
|
||||
num_rows,
|
||||
inserts);
|
||||
|
@ -33,7 +33,7 @@ void reset_replication(TestConnections& test)
|
||||
test.maxscales->wait_for_monitor(2);
|
||||
master_id = get_master_server_id(test);
|
||||
cout << "Master server id is now back to " << master_id << endl;
|
||||
test.assert(master_id == 1, "Switchover back to server1 failed");
|
||||
test.expect(master_id == 1, "Switchover back to server1 failed");
|
||||
}
|
||||
get_output(test);
|
||||
StringSet node_states;
|
||||
@ -43,7 +43,7 @@ void reset_replication(TestConnections& test)
|
||||
servername << "server" << i;
|
||||
node_states = test.get_server_status(servername.str().c_str());
|
||||
bool states_ok = (node_states.find("Slave") != node_states.end());
|
||||
test.assert(states_ok, "Server %d is not replicating.", i);
|
||||
test.expect(states_ok, "Server %d is not replicating.", i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ void check_test_1(TestConnections& test, int node0_id)
|
||||
get_output(test);
|
||||
int master_id = get_master_server_id(test);
|
||||
cout << "Master server id is " << master_id << endl;
|
||||
test.assert(master_id > 0 && master_id != node0_id, "Master did not change or no master detected.");
|
||||
test.expect(master_id > 0 && master_id != node0_id, "Master did not change or no master detected.");
|
||||
if (test.global_result == 0)
|
||||
{
|
||||
check(test);
|
||||
@ -99,7 +99,7 @@ void check_test_2(TestConnections& test)
|
||||
bool success = (master_id > 0
|
||||
&& (master_id == test.repl->get_server_id(2)
|
||||
|| master_id == test.repl->get_server_id(3)));
|
||||
test.assert(success, WRONG_SLAVE);
|
||||
test.expect(success, WRONG_SLAVE);
|
||||
if (test.global_result == 0)
|
||||
{
|
||||
check(test);
|
||||
@ -110,7 +110,7 @@ void check_test_2(TestConnections& test)
|
||||
test.maxscales->wait_for_monitor(2);
|
||||
get_output(test);
|
||||
StringSet node_states = test.get_server_status("server2");
|
||||
test.assert(node_states.find("Slave") != node_states.end(), "Server 2 is not replicating.");
|
||||
test.expect(node_states.find("Slave") != node_states.end(), "Server 2 is not replicating.");
|
||||
if (test.global_result == 0)
|
||||
{
|
||||
reset_replication(test);
|
||||
@ -168,7 +168,7 @@ void check_test_3(TestConnections& test)
|
||||
// Because servers have been restarted, redo connections.
|
||||
test.repl->connect();
|
||||
cout << "Master server id is " << master_id << endl;
|
||||
test.assert(master_id > 0 && master_id == test.repl->get_server_id(3), WRONG_SLAVE);
|
||||
test.expect(master_id > 0 && master_id == test.repl->get_server_id(3), WRONG_SLAVE);
|
||||
print_gtids(test);
|
||||
|
||||
reset_replication(test);
|
||||
|
@ -253,11 +253,11 @@ void test_connecting(TestConnections& test,
|
||||
|
||||
if (!could_connect && should_be_able_to)
|
||||
{
|
||||
test.assert(false, "%s@%s should have been able to connect, but wasn't.", zUser, zHost);
|
||||
test.expect(false, "%s@%s should have been able to connect, but wasn't.", zUser, zHost);
|
||||
}
|
||||
else if (could_connect && !should_be_able_to)
|
||||
{
|
||||
test.assert(false, "%s@%s should NOT have been able to connect, but was.", zUser, zHost);
|
||||
test.expect(false, "%s@%s should NOT have been able to connect, but was.", zUser, zHost);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -361,7 +361,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
test.assert(false, "MaxScale node does not have at least one IP-address.");
|
||||
test.expect(false, "MaxScale node does not have at least one IP-address.");
|
||||
}
|
||||
|
||||
return test.global_result;
|
||||
|
@ -73,17 +73,17 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
test.assert(false, "Could not connect to RWS.");
|
||||
test.expect(false, "Could not connect to RWS.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
test.assert(false, "Could not start MaxScale.");
|
||||
test.expect(false, "Could not start MaxScale.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
test.assert(false, "Could not copy masking file to MaxScale node.");
|
||||
test.expect(false, "Could not copy masking file to MaxScale node.");
|
||||
}
|
||||
|
||||
return test.global_result;
|
||||
|
@ -9,22 +9,22 @@ int main(int argc, char** argv)
|
||||
TestConnections test(argc, argv);
|
||||
|
||||
int rc = test.maxscales->ssh_node_f(0, false, "maxctrl help list servers");
|
||||
test.assert(rc == 0, "`help list servers` should work");
|
||||
test.expect(rc == 0, "`help list servers` should work");
|
||||
|
||||
rc = test.maxscales->ssh_node_f(0, false, "maxctrl --tsv list servers|grep 'Master, Running'");
|
||||
test.assert(rc == 0, "`list servers` should return at least one row with: Master, Running");
|
||||
test.expect(rc == 0, "`list servers` should return at least one row with: Master, Running");
|
||||
|
||||
rc = test.maxscales->ssh_node_f(0, false, "maxctrl set server server1 maintenance");
|
||||
test.assert(rc == 0, "`set server` should work");
|
||||
test.expect(rc == 0, "`set server` should work");
|
||||
|
||||
rc = test.maxscales->ssh_node_f(0, false, "maxctrl --tsv list servers|grep 'Maintenance'");
|
||||
test.assert(rc == 0, "`list servers` should return at least one row with: Maintanance");
|
||||
test.expect(rc == 0, "`list servers` should return at least one row with: Maintanance");
|
||||
|
||||
rc = test.maxscales->ssh_node_f(0, false, "maxctrl clear server server1 maintenance");
|
||||
test.assert(rc == 0, "`clear server` should work");
|
||||
test.expect(rc == 0, "`clear server` should work");
|
||||
|
||||
rc = test.maxscales->ssh_node_f(0, false, "maxctrl --tsv list servers|grep 'Maintenance'");
|
||||
test.assert(rc != 0, "`list servers` should have no rows with: Maintanance");
|
||||
test.expect(rc != 0, "`list servers` should have no rows with: Maintanance");
|
||||
|
||||
test.check_maxscale_alive();
|
||||
return test.global_result;
|
||||
|
@ -28,14 +28,14 @@ int main(int argc, char** argv)
|
||||
connections.emplace_back(query, test.maxscales->open_rwsplit_connection(), "SELECT SLEEP(10)");
|
||||
sleep(1);
|
||||
Row row = get_row(test.maxscales->conn_rwsplit[0], "SELECT @@server_id");
|
||||
test.assert(row == original_row, "Value of @@server_id should not change: %s", row.at(0).c_str());
|
||||
test.expect(row == original_row, "Value of @@server_id should not change: %s", row.at(0).c_str());
|
||||
}
|
||||
|
||||
for (auto& a : connections)
|
||||
{
|
||||
a.join();
|
||||
Row row = get_row(test.maxscales->conn_rwsplit[0], "SELECT @@server_id");
|
||||
test.assert(row == original_row, "Value of @@server_id should not change: %s", row.at(0).c_str());
|
||||
test.expect(row == original_row, "Value of @@server_id should not change: %s", row.at(0).c_str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,22 +35,22 @@ int main(int argc, char** argv)
|
||||
};
|
||||
|
||||
test.maxscales->connect();
|
||||
test.assert(query("DROP TABLE IF EXISTS test.t1") == 0,
|
||||
test.expect(query("DROP TABLE IF EXISTS test.t1") == 0,
|
||||
"DROP TABLE should work.");
|
||||
test.assert(query("CREATE TABLE test.t1 (id INT)") == 0,
|
||||
test.expect(query("CREATE TABLE test.t1 (id INT)") == 0,
|
||||
"CREATE TABLE should work.");
|
||||
test.assert(query("INSERT INTO test.t1 VALUES (1)") == 0,
|
||||
test.expect(query("INSERT INTO test.t1 VALUES (1)") == 0,
|
||||
"Write should work at the start of the test.");
|
||||
|
||||
block_master();
|
||||
test.assert(query("INSERT INTO test.t1 VALUES (1)") != 0,
|
||||
test.expect(query("INSERT INTO test.t1 VALUES (1)") != 0,
|
||||
"Write should fail after master is blocked.");
|
||||
|
||||
test.assert(error_matches("read-only"),
|
||||
test.expect(error_matches("read-only"),
|
||||
"Error should mention read-only mode");
|
||||
|
||||
unblock_master();
|
||||
test.assert(query("INSERT INTO test.t1 VALUES (1)") == 0,
|
||||
test.expect(query("INSERT INTO test.t1 VALUES (1)") == 0,
|
||||
"Write should work after unblocking master");
|
||||
|
||||
query("DROP TABLE test.t1");
|
||||
|
@ -27,14 +27,14 @@ int main(int argc, char** argv)
|
||||
};
|
||||
|
||||
test.maxscales->connect();
|
||||
test.assert(query("DROP TABLE IF EXISTS test.t1;") == 0, "DROP TABLE should work.");
|
||||
test.assert(query("CREATE TABLE test.t1 (id INT);") == 0, "CREATE TABLE should work.");
|
||||
test.expect(query("DROP TABLE IF EXISTS test.t1;") == 0, "DROP TABLE should work.");
|
||||
test.expect(query("CREATE TABLE test.t1 (id INT);") == 0, "CREATE TABLE should work.");
|
||||
|
||||
// Execute session commands so that the history is not empty
|
||||
cout << "Setting user variables" << endl;
|
||||
test.assert(query("SET @a = 1") == 0, "First session command should work.");
|
||||
test.assert(query("USE test") == 0, "Second session command should work.");
|
||||
test.assert(query("SET @b = 2") == 0, "Third session command should work.");
|
||||
test.expect(query("SET @a = 1") == 0, "First session command should work.");
|
||||
test.expect(query("USE test") == 0, "Second session command should work.");
|
||||
test.expect(query("SET @b = 2") == 0, "Third session command should work.");
|
||||
|
||||
// Block the master to trigger reconnection
|
||||
cout << "Blocking master" << endl;
|
||||
@ -47,9 +47,9 @@ int main(int argc, char** argv)
|
||||
// Check that inserts work
|
||||
cout << "Selecting user variables" << endl;
|
||||
test.set_timeout(15);
|
||||
test.assert(query("INSERT INTO test.t1 VALUES (1)") == 0, "Write should work after unblocking master");
|
||||
test.assert(check_result("@a", "1"), "@a should be 1");
|
||||
test.assert(check_result("@b", "2"), "@b should be 2");
|
||||
test.expect(query("INSERT INTO test.t1 VALUES (1)") == 0, "Write should work after unblocking master");
|
||||
test.expect(check_result("@a", "1"), "@a should be 1");
|
||||
test.expect(check_result("@b", "2"), "@b should be 2");
|
||||
query("DROP TABLE test.t1");
|
||||
|
||||
return test.global_result;
|
||||
|
@ -31,7 +31,7 @@ int main(int argc, char** argv)
|
||||
|
||||
auto compare = [&test](string q, string res) {
|
||||
auto rc = execute_query_check_one(test.maxscales->conn_rwsplit[0], q.c_str(), res.c_str()) == 0;
|
||||
test.assert(rc, "Query '%s' did not produce result of '%s'", q.c_str(), res.c_str());
|
||||
test.expect(rc, "Query '%s' did not produce result of '%s'", q.c_str(), res.c_str());
|
||||
};
|
||||
|
||||
auto check = [&test, &compare](string q, string res) {
|
||||
@ -42,14 +42,14 @@ int main(int argc, char** argv)
|
||||
};
|
||||
|
||||
auto ok = [&test, &query](string q, int t = 0) {
|
||||
test.assert(query(q, t),
|
||||
test.expect(query(q, t),
|
||||
"Query '%' should work: %s",
|
||||
q.c_str(),
|
||||
mysql_error(test.maxscales->conn_rwsplit[0]));
|
||||
};
|
||||
|
||||
auto err = [&test, &query](string q, int t = 0) {
|
||||
test.assert(!query(q, t), "Query should fail: %s", q.c_str());
|
||||
test.expect(!query(q, t), "Query should fail: %s", q.c_str());
|
||||
};
|
||||
|
||||
auto block = [&test](int pre = 0, int node = 0) {
|
||||
|
@ -44,17 +44,17 @@ int main(int argc, char** argv)
|
||||
|
||||
cout << "Blocking the master and executing a SELECT" << endl;
|
||||
thr = thread(block, std::ref(test), vector<int>({0}));
|
||||
test.assert(query(test), "Select without master should work");
|
||||
test.expect(query(test), "Select without master should work");
|
||||
thr.join();
|
||||
|
||||
cout << "Blocking the slave and executing a SELECT" << endl;
|
||||
thr = thread(block, std::ref(test), vector<int>({1}));
|
||||
test.assert(query(test), "Select without slave should work");
|
||||
test.expect(query(test), "Select without slave should work");
|
||||
thr.join();
|
||||
|
||||
cout << "Blocking both servers and executing a SELECT" << endl;
|
||||
thr = thread(block, std::ref(test), vector<int>({0, 1}));
|
||||
test.assert(query(test), "Select with no servers should work");
|
||||
test.expect(query(test), "Select with no servers should work");
|
||||
thr.join();
|
||||
|
||||
return test.global_result;
|
||||
|
@ -19,14 +19,14 @@ int main(int argc, char** argv)
|
||||
};
|
||||
|
||||
auto ok = [&](string q) {
|
||||
test.assert(query(q),
|
||||
test.expect(query(q),
|
||||
"Query '%s' should work: %s",
|
||||
q.c_str(),
|
||||
mysql_error(test.maxscales->conn_rwsplit[0]));
|
||||
};
|
||||
|
||||
auto err = [&](string q) {
|
||||
test.assert(!query(q), "Query should not work: %s", q.c_str());
|
||||
test.expect(!query(q), "Query should not work: %s", q.c_str());
|
||||
};
|
||||
|
||||
// Create a table and insert one value
|
||||
|
@ -24,7 +24,7 @@ int main(int argc, char** argv)
|
||||
"maxctrl call command mariadbmon switchover MySQL-Monitor %s %s",
|
||||
slave.c_str(),
|
||||
master.c_str());
|
||||
test.assert(rc == 0, "Switchover should work");
|
||||
test.expect(rc == 0, "Switchover should work");
|
||||
master.swap(slave);
|
||||
test.maxscales->wait_for_monitor();
|
||||
};
|
||||
@ -34,7 +34,7 @@ int main(int argc, char** argv)
|
||||
};
|
||||
|
||||
auto ok = [&](string q) {
|
||||
test.assert(query(q),
|
||||
test.expect(query(q),
|
||||
"Query '%s' should work: %s",
|
||||
q.c_str(),
|
||||
mysql_error(test.maxscales->conn_rwsplit[0]));
|
||||
@ -44,7 +44,7 @@ int main(int argc, char** argv)
|
||||
ok("START TRANSACTION");
|
||||
Row row = get_row(test.maxscales->conn_rwsplit[0], q.c_str());
|
||||
ok("COMMIT");
|
||||
test.assert(!row.empty() && row[0] == "1", "Query should return 1: %s", q.c_str());
|
||||
test.expect(!row.empty() && row[0] == "1", "Query should return 1: %s", q.c_str());
|
||||
};
|
||||
|
||||
// Create a table, insert a value and make sure it's replicated to all slaves
|
||||
|
@ -19,19 +19,19 @@ int main(int argc, char** argv)
|
||||
};
|
||||
|
||||
auto ok = [&](string q) {
|
||||
test.assert(query(q),
|
||||
test.expect(query(q),
|
||||
"Query '%s' should work: %s",
|
||||
q.c_str(),
|
||||
mysql_error(test.maxscales->conn_rwsplit[0]));
|
||||
};
|
||||
|
||||
auto err = [&](string q) {
|
||||
test.assert(!query(q), "Query should not work: %s", q.c_str());
|
||||
test.expect(!query(q), "Query should not work: %s", q.c_str());
|
||||
};
|
||||
|
||||
auto check = [&](string q, string res) {
|
||||
Row row = get_row(test.maxscales->conn_rwsplit[0], q.c_str());
|
||||
test.assert(!row.empty() && row[0] == res,
|
||||
test.expect(!row.empty() && row[0] == res,
|
||||
"Query '%s' should return 1: %s (%s)",
|
||||
q.c_str(),
|
||||
row.empty() ? "<empty>" : row[0].c_str(),
|
||||
|
@ -16,7 +16,7 @@ int main(int argc, char** argv)
|
||||
Connection conn {test.maxscales->rwsplit()};
|
||||
|
||||
auto query = [&](bool should_work, string q) {
|
||||
test.assert(conn.query(q) == should_work,
|
||||
test.expect(conn.query(q) == should_work,
|
||||
"Query '%s' should %s: %s",
|
||||
q.c_str(),
|
||||
should_work ? "work" : "fail",
|
||||
@ -25,7 +25,7 @@ int main(int argc, char** argv)
|
||||
|
||||
auto compare = [&](bool equal, string q, string res) {
|
||||
Row row = conn.row(q);
|
||||
test.assert(!row.empty() && (row[0] == res) == equal,
|
||||
test.expect(!row.empty() && (row[0] == res) == equal,
|
||||
"Values are %s: `%s` `%s`",
|
||||
equal ? "not equal" : "equal",
|
||||
row.empty() ? "<empty>" : row[0].c_str(),
|
||||
|
@ -53,7 +53,7 @@ int main(int argc, char** argv)
|
||||
|
||||
std::string errstr;
|
||||
std::accumulate(errors.begin(), errors.end(), errstr, combiner);
|
||||
test.assert(errors.empty(), "None of the queries should fail: %s", errstr.c_str());
|
||||
test.expect(errors.empty(), "None of the queries should fail: %s", errstr.c_str());
|
||||
|
||||
test.tprintf("Dropping databases...");
|
||||
for (auto db : db_list)
|
||||
|
@ -33,7 +33,7 @@ void run(TestConnections& test)
|
||||
init(test);
|
||||
|
||||
MYSQL* pMysql = mysql_init(NULL);
|
||||
test.assert(pMysql, "Could not create MYSQL handle.");
|
||||
test.expect(pMysql, "Could not create MYSQL handle.");
|
||||
|
||||
const char* zUser = test.maxscales->user_name;
|
||||
const char* zPassword = test.maxscales->password;
|
||||
@ -51,7 +51,7 @@ void run(TestConnections& test)
|
||||
const char* q = "UPDATE MXS_1719 SET a=1; UPDATE MXS_1719 SET a=1;";
|
||||
// One multi-statement with two UPDATEs. Note: This query should fail
|
||||
// with 2.3 now that function blocking has been added
|
||||
test.assert(execute_query_silent(pMysql, q) != 0, "Query '%s' should not succeed", q);
|
||||
test.expect(execute_query_silent(pMysql, q) != 0, "Query '%s' should not succeed", q);
|
||||
|
||||
// Sleep a while, so that the log is flushed.
|
||||
sleep(5);
|
||||
@ -66,7 +66,7 @@ void run(TestConnections& test)
|
||||
}
|
||||
else
|
||||
{
|
||||
test.assert(false, "Could not connect to MaxScale.");
|
||||
test.expect(false, "Could not connect to MaxScale.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -92,17 +92,17 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
test.assert(false, "Could not connect to RWS.");
|
||||
test.expect(false, "Could not connect to RWS.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
test.assert(false, "Could not start MaxScale.");
|
||||
test.expect(false, "Could not start MaxScale.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
test.assert(false, "Could not copy masking file to MaxScale node.");
|
||||
test.expect(false, "Could not copy masking file to MaxScale node.");
|
||||
}
|
||||
|
||||
test.maxscales->connect();
|
||||
|
@ -37,7 +37,7 @@ int main(int argc, char** argv)
|
||||
int rc = test.maxscales->ssh_node_f(0,
|
||||
true,
|
||||
"grep 'version_string' /var/lib/maxscale/maxscale.cnf.d/RW-Split-Router.cnf");
|
||||
test.assert(rc == 0,
|
||||
test.expect(rc == 0,
|
||||
"Generated configuration should have version_string defined and MaxScale should ignore it.");
|
||||
|
||||
test.maxscales->ssh_node_f(0, true, "maxadmin alter service RW-Split-Router enable_root_user=false");
|
||||
@ -48,7 +48,7 @@ int main(int argc, char** argv)
|
||||
rc = test.maxscales->ssh_node_f(0,
|
||||
true,
|
||||
"grep 'version_string' /var/lib/maxscale/maxscale.cnf.d/RW-Split-Router.cnf");
|
||||
test.assert(rc != 0, "Generated configuration should not have version_string defined.");
|
||||
test.expect(rc != 0, "Generated configuration should not have version_string defined.");
|
||||
|
||||
return test.global_result;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ int main(int argc, char** argv)
|
||||
find_field(test.repl->nodes[0], query.c_str(), "connections", master_connections);
|
||||
find_field(test.repl->nodes[1], query.c_str(), "connections", slave_connections);
|
||||
|
||||
test.assert(strcmp(master_connections, slave_connections) == 0,
|
||||
test.expect(strcmp(master_connections, slave_connections) == 0,
|
||||
"Master and slave shoud have the same amount of connections: %s != %s",
|
||||
master_connections,
|
||||
slave_connections);
|
||||
|
@ -23,7 +23,7 @@ int main(int argc, char** argv)
|
||||
cout << "Setting variable @a to 123" << endl;
|
||||
mysql_query(test.maxscales->conn_rwsplit[0], "SET @a = 123");
|
||||
int rc = execute_query_check_one(test.maxscales->conn_rwsplit[0], "SELECT @a", "123");
|
||||
test.assert(rc == 0, "Text protocol should return 123 as the value of @a");
|
||||
test.expect(rc == 0, "Text protocol should return 123 as the value of @a");
|
||||
|
||||
cout << "Preparing and executing " << NUM_STMT << " prepared statements" << endl;
|
||||
for (int i = 0; i < NUM_STMT && test.global_result == 0; i++)
|
||||
|
@ -45,17 +45,17 @@ void run_test(TestConnections& test, TestCase test_case)
|
||||
|
||||
if (mysql_stmt_prepare(stmt, query.c_str(), query.size()))
|
||||
{
|
||||
test.assert(false, "Prepared statement failure: %s", mysql_stmt_error(stmt));
|
||||
test.expect(false, "Prepared statement failure: %s", mysql_stmt_error(stmt));
|
||||
}
|
||||
|
||||
cout << test_case.name << endl;
|
||||
test.assert(test_case.func(test.maxscales->conn_rwsplit[0], stmt, bind),
|
||||
test.expect(test_case.func(test.maxscales->conn_rwsplit[0], stmt, bind),
|
||||
"Test '%s' failed",
|
||||
test_case.name.c_str());
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
test.assert(mysql_query(test.maxscales->conn_rwsplit[0], "SELECT 1") == 0, "Normal queries should work");
|
||||
test.expect(mysql_query(test.maxscales->conn_rwsplit[0], "SELECT 1") == 0, "Normal queries should work");
|
||||
|
||||
test.maxscales->disconnect();
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ int main(int argc, char** argv)
|
||||
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "%s", insert.c_str());
|
||||
Row row = get_row(test.maxscales->conn_rwsplit[0], select);
|
||||
test.assert(!row.empty() && row [0] != master && row[1] == "1",
|
||||
test.expect(!row.empty() && row [0] != master && row[1] == "1",
|
||||
"At %d: Row is %s",
|
||||
i,
|
||||
row.empty() ? "empty" : (row[0] + " " + row[1]).c_str());
|
||||
|
@ -49,19 +49,19 @@ int main(int argc, char* argv[])
|
||||
|
||||
test.set_timeout(30);
|
||||
|
||||
test.assert(mysql_stmt_prepare(stmt, query.c_str(), query.size()) == 0,
|
||||
test.expect(mysql_stmt_prepare(stmt, query.c_str(), query.size()) == 0,
|
||||
"Prepared statement failure: %s",
|
||||
mysql_stmt_error(stmt));
|
||||
test.assert(mysql_stmt_bind_param(stmt, &bind.bind) == 0,
|
||||
test.expect(mysql_stmt_bind_param(stmt, &bind.bind) == 0,
|
||||
"Bind failure: %s",
|
||||
mysql_stmt_error(stmt));
|
||||
test.assert(mysql_stmt_execute(stmt) == 0,
|
||||
test.expect(mysql_stmt_execute(stmt) == 0,
|
||||
"Execute failure: %s",
|
||||
mysql_stmt_error(stmt));
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
test.assert(mysql_query(test.maxscales->conn_rwsplit[0], "SELECT 1") == 0, "Normal queries should work");
|
||||
test.expect(mysql_query(test.maxscales->conn_rwsplit[0], "SELECT 1") == 0, "Normal queries should work");
|
||||
test.maxscales->disconnect();
|
||||
|
||||
return test.global_result;
|
||||
|
@ -64,19 +64,19 @@ int main(int argc, char* argv[])
|
||||
|
||||
test.set_timeout(30);
|
||||
|
||||
test.assert(mysql_stmt_prepare(stmt, query.c_str(), query.size()) == 0,
|
||||
test.expect(mysql_stmt_prepare(stmt, query.c_str(), query.size()) == 0,
|
||||
"Prepared statement failure: %s",
|
||||
mysql_stmt_error(stmt));
|
||||
test.assert(mysql_stmt_bind_param(stmt, &bind.bind) == 0,
|
||||
test.expect(mysql_stmt_bind_param(stmt, &bind.bind) == 0,
|
||||
"Bind failure: %s",
|
||||
mysql_stmt_error(stmt));
|
||||
test.assert(mysql_stmt_execute(stmt) == 0,
|
||||
test.expect(mysql_stmt_execute(stmt) == 0,
|
||||
"Execute failure: %s",
|
||||
mysql_stmt_error(stmt));
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
test.assert(mysql_query(test.maxscales->conn_rwsplit[0], "SELECT 1") == 0,
|
||||
test.expect(mysql_query(test.maxscales->conn_rwsplit[0], "SELECT 1") == 0,
|
||||
"Normal queries should work");
|
||||
test.maxscales->disconnect();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ int main(int argc, char** argv)
|
||||
test.maxscales->connect();
|
||||
|
||||
MYSQL_STMT* stmt = mysql_stmt_init(test.maxscales->conn_rwsplit[0]);
|
||||
test.assert(mysql_stmt_prepare(stmt, sqlstr, strlen(sqlstr)) == 0,
|
||||
test.expect(mysql_stmt_prepare(stmt, sqlstr, strlen(sqlstr)) == 0,
|
||||
"Prepare should not fail",
|
||||
mysql_stmt_error(stmt));
|
||||
mysql_stmt_close(stmt);
|
||||
|
@ -79,7 +79,7 @@ int main(int argc, char** argv)
|
||||
TestConnections test(argc, argv);
|
||||
|
||||
test.maxscales->connect();
|
||||
test.assert(test_long_data(test.maxscales->conn_rwsplit[0], 123456), "Test should work");
|
||||
test.expect(test_long_data(test.maxscales->conn_rwsplit[0], 123456), "Test should work");
|
||||
test.maxscales->disconnect();
|
||||
|
||||
return test.global_result;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* MXS-1824: Debug assertion with two open cursors
|
||||
* MXS-1824: Debug expection with two open cursors
|
||||
*
|
||||
* https://jira.mariadb.org/browse/MXS-1824
|
||||
*/
|
||||
@ -18,9 +18,9 @@ void double_cursor(TestConnections& test, MYSQL* conn)
|
||||
MYSQL_STMT* stmt1 = mysql_stmt_init(conn);
|
||||
const char* query = "SELECT id FROM test.t1";
|
||||
int rc = mysql_stmt_prepare(stmt1, query, strlen(query));
|
||||
test.assert(rc == 0, "First prepare should work: %s %s", mysql_stmt_error(stmt1), mysql_error(conn));
|
||||
test.expect(rc == 0, "First prepare should work: %s %s", mysql_stmt_error(stmt1), mysql_error(conn));
|
||||
unsigned long type = CURSOR_TYPE_READ_ONLY;
|
||||
test.assert(mysql_stmt_attr_set(stmt1, STMT_ATTR_CURSOR_TYPE, &type) == 0,
|
||||
test.expect(mysql_stmt_attr_set(stmt1, STMT_ATTR_CURSOR_TYPE, &type) == 0,
|
||||
"Set of first attribute should work: %s %s",
|
||||
mysql_stmt_error(stmt1),
|
||||
mysql_error(conn));
|
||||
@ -31,35 +31,35 @@ void double_cursor(TestConnections& test, MYSQL* conn)
|
||||
bind[0].buffer = &id;
|
||||
mysql_stmt_bind_result(stmt1, bind);
|
||||
|
||||
test.assert(mysql_stmt_execute(stmt1) == 0,
|
||||
test.expect(mysql_stmt_execute(stmt1) == 0,
|
||||
"Execute of first statement should work: %s %s",
|
||||
mysql_stmt_error(stmt1),
|
||||
mysql_error(conn));
|
||||
test.assert(mysql_stmt_fetch(stmt1) == 0,
|
||||
test.expect(mysql_stmt_fetch(stmt1) == 0,
|
||||
"First fetch should work: %s %s",
|
||||
mysql_stmt_error(stmt1),
|
||||
mysql_error(conn));
|
||||
|
||||
MYSQL_STMT* stmt2 = mysql_stmt_init(conn);
|
||||
rc = mysql_stmt_prepare(stmt2, query, strlen(query));
|
||||
test.assert(rc == 0, "Second prepare should work: %s %s", mysql_stmt_error(stmt2), mysql_error(conn));
|
||||
test.assert(mysql_stmt_attr_set(stmt2, STMT_ATTR_CURSOR_TYPE, &type) == 0,
|
||||
test.expect(rc == 0, "Second prepare should work: %s %s", mysql_stmt_error(stmt2), mysql_error(conn));
|
||||
test.expect(mysql_stmt_attr_set(stmt2, STMT_ATTR_CURSOR_TYPE, &type) == 0,
|
||||
"Set of second attribute should work: %s %s",
|
||||
mysql_stmt_error(stmt2),
|
||||
mysql_error(conn));
|
||||
mysql_stmt_bind_result(stmt2, bind);
|
||||
|
||||
test.assert(mysql_stmt_execute(stmt2) == 0,
|
||||
test.expect(mysql_stmt_execute(stmt2) == 0,
|
||||
"Execute of second statement should work: %s %s",
|
||||
mysql_stmt_error(stmt2),
|
||||
mysql_error(conn));
|
||||
test.assert(mysql_stmt_fetch(stmt2) == 0,
|
||||
test.expect(mysql_stmt_fetch(stmt2) == 0,
|
||||
"Second fetch should work: %s %s",
|
||||
mysql_stmt_error(stmt2),
|
||||
mysql_error(conn));
|
||||
mysql_stmt_reset(stmt2);
|
||||
|
||||
test.assert(mysql_stmt_fetch(stmt1) == 0,
|
||||
test.expect(mysql_stmt_fetch(stmt1) == 0,
|
||||
"Third fetch should work: %s %s",
|
||||
mysql_stmt_error(stmt1),
|
||||
mysql_error(conn));
|
||||
|
@ -30,7 +30,7 @@ int main(int argc, char** argv)
|
||||
Row row = get_row(test.maxscales->conn_rwsplit[0], "SELECT COUNT(*) FROM test.t1");
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "COMMIT");
|
||||
|
||||
test.assert(!row.empty() && row[0] == "6",
|
||||
test.expect(!row.empty() && row[0] == "6",
|
||||
"Table should have 6 rows but has %s rows",
|
||||
row.empty() ? "no" : row[0].c_str());
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "DROP TABLE test.t1");
|
||||
|
@ -13,11 +13,11 @@ int main(int argc, char** argv)
|
||||
int rc = test.maxscales->ssh_node_f(0,
|
||||
true,
|
||||
"maxctrl alter monitor MySQL-Monitor not_a_parameter not_a_value|grep Error");
|
||||
test.assert(rc == 0, "Altering unknown parameter should cause an error");
|
||||
test.expect(rc == 0, "Altering unknown parameter should cause an error");
|
||||
rc = test.maxscales->ssh_node_f(0,
|
||||
true,
|
||||
"maxctrl alter monitor MySQL-Monitor ignore_external_masters on_sunday_afternoons|grep Error");
|
||||
test.assert(rc == 0, "Invalid parameter value should cause an error");
|
||||
test.expect(rc == 0, "Invalid parameter value should cause an error");
|
||||
|
||||
return test.global_result;
|
||||
}
|
||||
|
@ -29,12 +29,12 @@ void run(TestConnections& test, MYSQL* pMysql)
|
||||
if (mysql_query(pMysql, "show eventTimes") == 0)
|
||||
{
|
||||
MYSQL_RES* pResult = mysql_store_result(pMysql);
|
||||
test.assert(pResult, "Executing 'show eventTimes' returned no result.");
|
||||
test.expect(pResult, "Executing 'show eventTimes' returned no result.");
|
||||
|
||||
if (pResult)
|
||||
{
|
||||
int nFields = mysql_field_count(pMysql);
|
||||
test.assert(nFields == 3, "Expected 3 fields, got %d.", nFields);
|
||||
test.expect(nFields == 3, "Expected 3 fields, got %d.", nFields);
|
||||
|
||||
MYSQL_ROW row;
|
||||
while ((row = mysql_fetch_row(pResult)) != NULL)
|
||||
@ -47,9 +47,9 @@ void run(TestConnections& test, MYSQL* pMysql)
|
||||
int64_t nEvents_queued = strtoll(row[1], NULL, 0);
|
||||
int64_t nEvents_executed = strtoll(row[2], NULL, 0);
|
||||
|
||||
test.assert(nEvents_queued >= 0 && nEvents_queued < 100,
|
||||
test.expect(nEvents_queued >= 0 && nEvents_queued < 100,
|
||||
"Suspiciously large number of 'No. Events Queued'.");
|
||||
test.assert(nEvents_executed >= 0 && nEvents_executed < 100,
|
||||
test.expect(nEvents_executed >= 0 && nEvents_executed < 100,
|
||||
"Suspiciously large number of 'No. Events Executed'.");
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ void run(TestConnections& test, MYSQL* pMysql)
|
||||
}
|
||||
else
|
||||
{
|
||||
test.assert(false, "Executing 'show eventTimes' failed: %s", mysql_error(pMysql));
|
||||
test.expect(false, "Executing 'show eventTimes' failed: %s", mysql_error(pMysql));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -70,7 +70,7 @@ int main(int argc, char* argv[])
|
||||
const char* zMaxScale_host = test.maxscales->ip(0);
|
||||
|
||||
MYSQL* pMysql = open_conn_no_db(PORT, zMaxScale_host, USER, PASSWD);
|
||||
test.assert(pMysql, "Could not connect to maxinfo on MaxScale.");
|
||||
test.expect(pMysql, "Could not connect to maxinfo on MaxScale.");
|
||||
|
||||
if (pMysql)
|
||||
{
|
||||
|
@ -23,15 +23,15 @@ string get_server_id(TestConnections& test, MYSQL* pMysql)
|
||||
if (rv == 0)
|
||||
{
|
||||
MYSQL_RES* pResult = mysql_store_result(pMysql);
|
||||
test.assert(pResult, "Could not store result.");
|
||||
test.expect(pResult, "Could not store result.");
|
||||
|
||||
if (pResult)
|
||||
{
|
||||
unsigned int n = mysql_field_count(pMysql);
|
||||
test.assert(n == 1, "Unexpected number of fields.");
|
||||
test.expect(n == 1, "Unexpected number of fields.");
|
||||
|
||||
MYSQL_ROW pzRow = mysql_fetch_row(pResult);
|
||||
test.assert(pzRow, "Returned row was NULL.");
|
||||
test.expect(pzRow, "Returned row was NULL.");
|
||||
|
||||
if (pzRow)
|
||||
{
|
||||
@ -78,7 +78,7 @@ int main(int argc, char** argv)
|
||||
|
||||
string slave_id = get_server_id(test, test.maxscales->conn_slave[0]);
|
||||
test.tprintf("Server id: %s", slave_id.c_str());
|
||||
test.assert(slave_id != master_id, "Expected something else but %s", master_id.c_str());
|
||||
test.expect(slave_id != master_id, "Expected something else but %s", master_id.c_str());
|
||||
|
||||
return test.global_result;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ int main(int argc, char** argv)
|
||||
TestConnections test(argc, argv);
|
||||
|
||||
test.maxscales->ssh_node_f(0, true, "maxctrl alter maxscale auth_connect_timeout 10");
|
||||
test.assert(test.maxscales->restart() == 0,
|
||||
test.expect(test.maxscales->restart() == 0,
|
||||
"Restarting MaxScale after modification "
|
||||
"of global parameters should work");
|
||||
|
||||
|
@ -46,21 +46,21 @@ void basic(TestConnections& test)
|
||||
|
||||
Connection c = test.maxscales->rwsplit();
|
||||
c.connect();
|
||||
test.assert(c.check("SELECT 1", "2"), "The regex filter did not replace the query");
|
||||
test.expect(c.check("SELECT 1", "2"), "The regex filter did not replace the query");
|
||||
|
||||
|
||||
auto res = test.maxctrl("destroy filter test1");
|
||||
test.assert(res.first != 0, "Destruction should fail when filter is in use");
|
||||
test.expect(res.first != 0, "Destruction should fail when filter is in use");
|
||||
|
||||
test.check_maxctrl("alter service-filters svc1");
|
||||
test.check_maxctrl("destroy filter test1");
|
||||
|
||||
test.assert(c.check("SELECT 1", "2"), "The filter should not yet be destroyed");
|
||||
test.expect(c.check("SELECT 1", "2"), "The filter should not yet be destroyed");
|
||||
|
||||
c.disconnect();
|
||||
c.connect();
|
||||
|
||||
test.assert(c.check("SELECT 1", "1"), "The filter should be destroyed");
|
||||
test.expect(c.check("SELECT 1", "1"), "The filter should be destroyed");
|
||||
}
|
||||
|
||||
void visibility(TestConnections& test)
|
||||
@ -71,23 +71,23 @@ void visibility(TestConnections& test)
|
||||
};
|
||||
|
||||
test.check_maxctrl("create filter test1 hintfilter");
|
||||
test.assert(in_list_filters("test1"), "The filter should be visible after creation");
|
||||
test.expect(in_list_filters("test1"), "The filter should be visible after creation");
|
||||
|
||||
test.check_maxctrl("destroy filter test1");
|
||||
test.assert(!in_list_filters("test1"), "The filter should not be visible after destruction");
|
||||
test.expect(!in_list_filters("test1"), "The filter should not be visible after destruction");
|
||||
|
||||
test.check_maxctrl("create filter test1 hintfilter");
|
||||
test.assert(in_list_filters("test1"), "The filter should again be visible after recreation");
|
||||
test.assert(!in_list_filters("svc1"), "Filter should not be in use");
|
||||
test.expect(in_list_filters("test1"), "The filter should again be visible after recreation");
|
||||
test.expect(!in_list_filters("svc1"), "Filter should not be in use");
|
||||
|
||||
test.check_maxctrl("alter service-filters svc1 test1");
|
||||
test.assert(in_list_filters("svc1"), "Service should use the filter");
|
||||
test.expect(in_list_filters("svc1"), "Service should use the filter");
|
||||
|
||||
test.check_maxctrl("alter service-filters svc1");
|
||||
test.assert(!in_list_filters("svc1"), "Service should not use the filter");
|
||||
test.expect(!in_list_filters("svc1"), "Service should not use the filter");
|
||||
|
||||
test.check_maxctrl("destroy filter test1");
|
||||
test.assert(!in_list_filters("test1"), "The filter should not be visible after destruction");
|
||||
test.expect(!in_list_filters("test1"), "The filter should not be visible after destruction");
|
||||
}
|
||||
|
||||
void do_load_test(TestConnections& test,
|
||||
@ -133,7 +133,7 @@ void load(TestConnections& test)
|
||||
|
||||
while (running)
|
||||
{
|
||||
test.assert(c.query("select 1"), "Query should succeed: %s", c.error());
|
||||
test.expect(c.query("select 1"), "Query should succeed: %s", c.error());
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -159,7 +159,7 @@ void filter_swap(TestConnections& test)
|
||||
|
||||
while (running)
|
||||
{
|
||||
test.assert(c.check("select 1", "1"), "Query should not return 1 as a result");
|
||||
test.expect(c.check("select 1", "1"), "Query should not return 1 as a result");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -49,20 +49,20 @@ int main(int argc, char** argv)
|
||||
maxctrl("create server server3 " + host3 + " " + port3 + " --services svc1 --monitors mon1");
|
||||
|
||||
c1.connect();
|
||||
test.assert(c1.query("SELECT 1"), "Query to simple service should work: %s", c1.error());
|
||||
test.expect(c1.query("SELECT 1"), "Query to simple service should work: %s", c1.error());
|
||||
c1.disconnect();
|
||||
|
||||
cout << "Destroy the service and check that it is removed" << endl;
|
||||
|
||||
test.assert(!maxctrl("destroy service svc1", false), "Destroying linked service should fail");
|
||||
test.expect(!maxctrl("destroy service svc1", false), "Destroying linked service should fail");
|
||||
maxctrl("unlink service svc1 server1 server2 server3");
|
||||
test.assert(!maxctrl("destroy service svc1", false),
|
||||
test.expect(!maxctrl("destroy service svc1", false),
|
||||
"Destroying service with active listeners should fail");
|
||||
maxctrl("destroy listener svc1 listener1");
|
||||
test.assert(maxctrl("destroy service svc1"), "Destroying valid service should work");
|
||||
test.expect(maxctrl("destroy service svc1"), "Destroying valid service should work");
|
||||
|
||||
test.set_timeout(60);
|
||||
test.assert(!c1.connect(), "Connection should be rejected");
|
||||
test.expect(!c1.connect(), "Connection should be rejected");
|
||||
test.stop_timeout();
|
||||
|
||||
cout << "Create the same service again and check that it still works" << endl;
|
||||
@ -72,7 +72,7 @@ int main(int argc, char** argv)
|
||||
maxctrl("link service svc1 server1 server2 server3");
|
||||
|
||||
c1.connect();
|
||||
test.assert(c1.query("SELECT 1"), "Query to recreated service should work: %s", c1.error());
|
||||
test.expect(c1.query("SELECT 1"), "Query to recreated service should work: %s", c1.error());
|
||||
c1.disconnect();
|
||||
|
||||
cout << "Check that active connections aren't closed when service is destroyed" << endl;
|
||||
@ -82,7 +82,7 @@ int main(int argc, char** argv)
|
||||
maxctrl("destroy listener svc1 listener1");
|
||||
maxctrl("destroy service svc1");
|
||||
|
||||
test.assert(c1.query("SELECT 1"), "Query to destroyed service should still work");
|
||||
test.expect(c1.query("SELECT 1"), "Query to destroyed service should still work");
|
||||
|
||||
// Start a thread to attempt a connection before the last connection
|
||||
// is closed. The connection attempt should be rejected when the
|
||||
@ -91,7 +91,7 @@ int main(int argc, char** argv)
|
||||
condition_variable cv;
|
||||
thread t([&]() {
|
||||
cv.notify_one();
|
||||
test.assert(!test.maxscales->rwsplit().connect(),
|
||||
test.expect(!test.maxscales->rwsplit().connect(),
|
||||
"New connections to created service "
|
||||
"should fail with a timeout while the original connection is open");
|
||||
});
|
||||
@ -109,7 +109,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// Disconnect the original connection and try to reconnect
|
||||
c1.disconnect();
|
||||
test.assert(!c1.connect(), "New connections should be rejected after original connection is closed");
|
||||
test.expect(!c1.connect(), "New connections should be rejected after original connection is closed");
|
||||
|
||||
// The connection should be rejected once the last connection is closed. If
|
||||
// it doesn't, we hit the test timeout before the connection timeout.
|
||||
|
@ -36,7 +36,7 @@ int main(int argc, char** argv)
|
||||
test.maxscales->access_homedir[0]);
|
||||
|
||||
// Make sure the hidden configuration is not read and that MaxScale starts up
|
||||
test.assert(test.maxscales->restart_maxscale() == 0, "Starting MaxScale should succeed");
|
||||
test.expect(test.maxscales->restart_maxscale() == 0, "Starting MaxScale should succeed");
|
||||
|
||||
test.maxscales->ssh_node_f(0, true, "rm -r /etc/maxscale.cnf.d/");
|
||||
remove("hidden.cnf");
|
||||
|
@ -16,7 +16,7 @@ int main(int argc, char** argv)
|
||||
"insert_only",
|
||||
"insert_only",
|
||||
false);
|
||||
test.assert(mysql_errno(conn) == 0, "User without SELECT privileges should be allowed to connect");
|
||||
test.expect(mysql_errno(conn) == 0, "User without SELECT privileges should be allowed to connect");
|
||||
mysql_close(conn);
|
||||
|
||||
execute_query(test.repl->nodes[0], "DROP USER 'insert_only'@'%%'");
|
||||
|
@ -45,17 +45,17 @@ int main(int argc, char* argv[])
|
||||
|
||||
auto slave = [&](const char* name) {
|
||||
static StringSet slave {"Slave", "Running"};
|
||||
test.assert(status(name) == slave, "'%s' should be a slave", name);
|
||||
test.expect(status(name) == slave, "'%s' should be a slave", name);
|
||||
};
|
||||
|
||||
auto master = [&](const char* name) {
|
||||
static StringSet master {"Master", "Running"};
|
||||
test.assert(status(name) == master, "'%s' should be the master", name);
|
||||
test.expect(status(name) == master, "'%s' should be the master", name);
|
||||
};
|
||||
|
||||
auto down = [&](const char* name) {
|
||||
static StringSet down {"Down"};
|
||||
test.assert(status(name) == down, "'%s' should be down", name);
|
||||
test.expect(status(name) == down, "'%s' should be down", name);
|
||||
};
|
||||
|
||||
auto block = [&](int node) {
|
||||
|
@ -118,7 +118,7 @@ int main(int argc, char** argv)
|
||||
for (auto q : t.queries)
|
||||
{
|
||||
int rc = execute_query_silent(test.maxscales->conn_rwsplit[0], q.query);
|
||||
test.assert(q.should_work == (rc == 0),
|
||||
test.expect(q.should_work == (rc == 0),
|
||||
"Step '%s': Query '%s' should %s: %s",
|
||||
i.description,
|
||||
q.query,
|
||||
|
@ -38,7 +38,7 @@ void do_test(Test pre, Test post)
|
||||
if (pre.query)
|
||||
{
|
||||
rc = execute_query_silent(test.maxscales->conn_rwsplit[0], pre.query);
|
||||
test.assert((rc == 0) == pre.should_work,
|
||||
test.expect((rc == 0) == pre.should_work,
|
||||
"Expected query '%s' to %s: %s",
|
||||
pre.query,
|
||||
pre.should_work ? "succeed" : "fail",
|
||||
@ -49,7 +49,7 @@ void do_test(Test pre, Test post)
|
||||
sleep(5);
|
||||
|
||||
rc = execute_query_silent(test.maxscales->conn_rwsplit[0], post.query);
|
||||
test.assert((rc == 0) == post.should_work,
|
||||
test.expect((rc == 0) == post.should_work,
|
||||
"Expected query '%s' to %s: %s",
|
||||
post.query,
|
||||
post.should_work ? "succeed" : "fail",
|
||||
|
@ -91,7 +91,7 @@ void test_master_failure(TestConnections& test, std::ostream& out)
|
||||
|
||||
out << "Writes should fail" << endl;
|
||||
int rc = execute_query_silent(test.maxscales->conn_rwsplit[0], "INSERT INTO test.t1 VALUES (1)");
|
||||
test.assert(rc != 0, "Write after master failure should fail");
|
||||
test.expect(rc != 0, "Write after master failure should fail");
|
||||
|
||||
test.repl->unblock_node(0);
|
||||
test.maxscales->disconnect();
|
||||
|
@ -40,7 +40,7 @@ string get_unique_user()
|
||||
void connect_as_user(TestConnections& test, const string& user)
|
||||
{
|
||||
MYSQL* pMysql = mysql_init(NULL);
|
||||
test.assert(pMysql, "mysql_init() failed.");
|
||||
test.expect(pMysql, "mysql_init() failed.");
|
||||
|
||||
if (pMysql)
|
||||
{
|
||||
@ -92,7 +92,7 @@ int main(int argc, char* argv[])
|
||||
// There should be an error in maxscale.log
|
||||
test.log_includes(0, user.c_str());
|
||||
// But not in /var/log/auth.log
|
||||
test.assert(!found_in_file(test, "/var/log/auth.log", user),
|
||||
test.expect(!found_in_file(test, "/var/log/auth.log", user),
|
||||
"Unexpectedly found %s in /var/log/auth.log",
|
||||
user.c_str());
|
||||
|
||||
@ -110,7 +110,7 @@ int main(int argc, char* argv[])
|
||||
// There should be an error in maxscale.log, as maxlog is not affected by the syslog setting.
|
||||
test.log_includes(0, user.c_str());
|
||||
// And in /var/log/auth.log as that's where authentication errors now should go.
|
||||
test.assert(found_in_file(test, "/var/log/auth.log", user),
|
||||
test.expect(found_in_file(test, "/var/log/auth.log", user),
|
||||
"Unexpectedly NOT found %s in /var/log/auth.log",
|
||||
user.c_str());
|
||||
|
||||
|
@ -37,15 +37,15 @@ int main(int argc, char** argv)
|
||||
test.tprintf("Connect with a user that has a default role");
|
||||
MYSQL* conn
|
||||
= open_conn_db(test.maxscales->rwsplit_port[0], test.maxscales->IP[0], "my_db", "test", "test");
|
||||
test.assert(mysql_errno(conn) == 0, "Connection failed: %s", mysql_error(conn));
|
||||
test.expect(mysql_errno(conn) == 0, "Connection failed: %s", mysql_error(conn));
|
||||
char value[100] {};
|
||||
find_field(conn, "SELECT CURRENT_ROLE() AS role", "role", value);
|
||||
test.assert(strcmp(value, "dba") == 0, "Current role should be 'dba' but is: %s", value);
|
||||
test.expect(strcmp(value, "dba") == 0, "Current role should be 'dba' but is: %s", value);
|
||||
mysql_close(conn);
|
||||
|
||||
test.tprintf("Connect with a user that doesn't have a default role, expect failure");
|
||||
conn = open_conn_db(test.maxscales->rwsplit_port[0], test.maxscales->IP[0], "my_db", "test2", "test2");
|
||||
test.assert(mysql_errno(conn) != 0, "Connection should fail");
|
||||
test.expect(mysql_errno(conn) != 0, "Connection should fail");
|
||||
mysql_close(conn);
|
||||
|
||||
// Cleanup
|
||||
|
@ -70,7 +70,7 @@ void restore_servers(TestConnections& test, bool events_added)
|
||||
&dummy);
|
||||
test.maxscales->wait_for_monitor();
|
||||
int master_id = get_master_server_id(test);
|
||||
test.assert(master_id == 1, "Switchover failed to set server1 as master.");
|
||||
test.expect(master_id == 1, "Switchover failed to set server1 as master.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -114,7 +114,7 @@ int main(int argc, char* argv[])
|
||||
get_output(test);
|
||||
|
||||
int master_id = get_master_server_id(test);
|
||||
test.assert(master_id == 4, "Server 4 should be master, but master is server %d.", master_id);
|
||||
test.expect(master_id == 4, "Server 4 should be master, but master is server %d.", master_id);
|
||||
|
||||
if (test.global_result != 0)
|
||||
{
|
||||
@ -152,7 +152,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
test.repl->connect();
|
||||
int real_id = test.repl->get_server_id(3);
|
||||
test.assert(master_id == real_id, "@@server_id is different: %d != %d", master_id, real_id);
|
||||
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);
|
||||
|
||||
|
@ -18,7 +18,7 @@ const StringSet down = {DOWN};
|
||||
void check_status(TestConnections& test, const char* server, const StringSet& expected, const char* message)
|
||||
{
|
||||
StringSet state = test.get_server_status(server);
|
||||
test.assert(state == expected, "%s: %s", message, dump_status(state, expected).c_str());
|
||||
test.expect(state == expected, "%s: %s", message, dump_status(state, expected).c_str());
|
||||
}
|
||||
|
||||
static bool is_running = true;
|
||||
|
@ -53,7 +53,7 @@ int main(int argc, char** argv)
|
||||
test.maxscales->wait_for_monitor();
|
||||
get_output(test);
|
||||
int master_id = get_master_server_id(test);
|
||||
test.assert(master_id == -1, "Master was promoted even when no slave was eligible.");
|
||||
test.expect(master_id == -1, "Master was promoted even when no slave was eligible.");
|
||||
|
||||
test.repl->unblock_node(0);
|
||||
|
||||
|
@ -462,17 +462,17 @@ bool check_server_status(TestConnections& test, int id)
|
||||
else
|
||||
{
|
||||
cout << result;
|
||||
test.assert(false, "Merely 'Running' node did not error in expected way.");
|
||||
test.expect(false, "Merely 'Running' node did not error in expected way.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
test.assert(false, "Could not execute \"SHOW SLAVE STATUS\"");
|
||||
test.expect(false, "Could not execute \"SHOW SLAVE STATUS\"");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
test.assert(false, "Unexpected server state for %s.", server.c_str());
|
||||
test.expect(false, "Unexpected server state for %s.", server.c_str());
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
@ -497,7 +497,7 @@ void check_server_statuses(TestConnections& test)
|
||||
}
|
||||
else if (masters != 1)
|
||||
{
|
||||
test.assert(!true, "Unexpected number of masters: %d", masters);
|
||||
test.expect(!true, "Unexpected number of masters: %d", masters);
|
||||
}
|
||||
}
|
||||
|
||||
@ -555,7 +555,7 @@ void run(TestConnections& test)
|
||||
}
|
||||
else
|
||||
{
|
||||
test.assert(false, "Unexpected master id: %d");
|
||||
test.expect(false, "Unexpected master id: %d");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ void check_group(TestConnections& test, const char* server, int expected_group)
|
||||
}
|
||||
}
|
||||
|
||||
test.assert(found_group == expected_group,
|
||||
test.expect(found_group == expected_group,
|
||||
"Server '%s', expected group '%d', not '%d'",
|
||||
server,
|
||||
expected_group,
|
||||
|
@ -47,7 +47,7 @@ int main(int argc, char** argv)
|
||||
// Mess with the slaves to fix situation such that only one slave can be rejoined. Stop maxscale.
|
||||
if (test.stop_maxscale(0))
|
||||
{
|
||||
test.assert(false, "Could not stop MaxScale.");
|
||||
test.expect(false, "Could not stop MaxScale.");
|
||||
return test.global_result;
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ int main(int argc, char** argv)
|
||||
|| mysql_query(nodes[i], RESET_SLAVE) != 0
|
||||
|| mysql_query(nodes[i], READ_ONLY_OFF) != 0)
|
||||
{
|
||||
test.assert(false, "Could not stop slave connections and/or disable read_only for node %d.", i);
|
||||
test.expect(false, "Could not stop slave connections and/or disable read_only for node %d.", i);
|
||||
return test.global_result;
|
||||
}
|
||||
}
|
||||
@ -86,7 +86,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
print_gtids(test);
|
||||
bool gtids_ok = (gtid_begin == gtid_node2 && gtid_node2 < gtid_node3);
|
||||
test.assert(gtids_ok, "Gtid:s have not advanced correctly.");
|
||||
test.expect(gtids_ok, "Gtid:s have not advanced correctly.");
|
||||
if (!gtids_ok)
|
||||
{
|
||||
return test.global_result;
|
||||
@ -95,7 +95,7 @@ int main(int argc, char** argv)
|
||||
test.tprintf(LINE);
|
||||
if (test.start_maxscale(0))
|
||||
{
|
||||
test.assert(false, "Could not start MaxScale.");
|
||||
test.expect(false, "Could not start MaxScale.");
|
||||
return test.global_result;
|
||||
}
|
||||
test.maxscales->wait_for_monitor();
|
||||
@ -105,8 +105,8 @@ int main(int argc, char** argv)
|
||||
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.assert(states_n2_ok, "Node 2 has not rejoined when it should have.");
|
||||
test.assert(states_n3_ok, "Node 3 rejoined when it shouldn't have.");
|
||||
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 (!states_n2_ok || !states_n3_ok)
|
||||
{
|
||||
return test.global_result;
|
||||
@ -122,11 +122,11 @@ int main(int argc, char** argv)
|
||||
test.maxscales->wait_for_monitor();
|
||||
get_output(test);
|
||||
int master_id = get_master_server_id(test);
|
||||
test.assert(master_id == 4, "Server 4 should be the cluster master.");
|
||||
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.assert(states_n0_ok, "Server 1 is not a slave when it should be.");
|
||||
test.expect(states_n0_ok, "Server 1 is not a slave when it should be.");
|
||||
if (states_n0_ok)
|
||||
{
|
||||
int ec;
|
||||
@ -136,7 +136,7 @@ int main(int argc, char** argv)
|
||||
&ec);
|
||||
test.maxscales->wait_for_monitor();
|
||||
master_id = get_master_server_id(test);
|
||||
test.assert(master_id == 1, "Server 1 should be the cluster master.");
|
||||
test.expect(master_id == 1, "Server 1 should be the cluster master.");
|
||||
get_output(test);
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ int main(int argc, char** argv)
|
||||
get_output(test);
|
||||
int master_id_new = get_master_server_id(test);
|
||||
cout << "Master server id is " << master_id_new << endl;
|
||||
test.assert(master_id_new > 0 && master_id_new != master_id_old,
|
||||
test.expect(master_id_new > 0 && master_id_new != master_id_old,
|
||||
"Failover did not promote a new master.");
|
||||
if (test.global_result != 0)
|
||||
{
|
||||
@ -102,7 +102,7 @@ int main(int argc, char** argv)
|
||||
// Stop maxscale to prevent an unintended rejoin.
|
||||
if (test.stop_maxscale(0))
|
||||
{
|
||||
test.assert(false, "Could not stop MaxScale.");
|
||||
test.expect(false, "Could not stop MaxScale.");
|
||||
return test.global_result;
|
||||
}
|
||||
// Restart old master. Then add some events to it.
|
||||
@ -115,7 +115,7 @@ int main(int argc, char** argv)
|
||||
// Restart maxscale. Should not rejoin old master.
|
||||
if (test.start_maxscale(0))
|
||||
{
|
||||
test.assert(false, "Could not start MaxScale.");
|
||||
test.expect(false, "Could not start MaxScale.");
|
||||
return test.global_result;
|
||||
}
|
||||
test.maxscales->wait_for_monitor();
|
||||
|
@ -47,7 +47,7 @@ int main(int argc, char** argv)
|
||||
test.tprintf(LINE);
|
||||
test.tprintf(PRINT_ID, master_id);
|
||||
const bool failover_ok = (master_id > 0 && master_id != old_master_id);
|
||||
test.assert(failover_ok, "Master did not change or no master detected.");
|
||||
test.expect(failover_ok, "Master did not change or no master detected.");
|
||||
string gtid_final;
|
||||
if (failover_ok)
|
||||
{
|
||||
@ -76,7 +76,7 @@ int main(int argc, char** argv)
|
||||
test.tprintf(LINE);
|
||||
print_gtids(test);
|
||||
test.tprintf(LINE);
|
||||
test.assert(gtid_final == gtid_old_master, "Old master did not successfully rejoin the cluster.");
|
||||
test.expect(gtid_final == gtid_old_master, "Old master did not successfully rejoin the cluster.");
|
||||
// Switch master back to server1 so last check is faster
|
||||
int ec;
|
||||
test.maxscales->ssh_node_output(0,
|
||||
@ -87,7 +87,7 @@ int main(int argc, char** argv)
|
||||
test.maxscales->wait_for_monitor(); // Wait for monitor to update status
|
||||
get_output(test);
|
||||
master_id = get_master_server_id(test);
|
||||
test.assert(master_id == old_master_id, "Switchover back to server1 failed.");
|
||||
test.expect(master_id == old_master_id, "Switchover back to server1 failed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ int main(int argc, char** argv)
|
||||
int master_id = get_master_server_id(test);
|
||||
cout << "Master server id is " << master_id << endl;
|
||||
const bool failover_ok = (master_id > 0 && master_id != old_master_id);
|
||||
test.assert(failover_ok, "Master did not change or no master detected.");
|
||||
test.expect(failover_ok, "Master did not change or no master detected.");
|
||||
string gtid_final;
|
||||
if (failover_ok)
|
||||
{
|
||||
@ -82,7 +82,7 @@ int main(int argc, char** argv)
|
||||
cout << LINE << "\n";
|
||||
print_gtids(test);
|
||||
cout << LINE << "\n";
|
||||
test.assert(gtid_final == gtid_old_master,
|
||||
test.expect(gtid_final == gtid_old_master,
|
||||
"Old master did not successfully rejoin the cluster (%s != %s).",
|
||||
gtid_final.c_str(),
|
||||
gtid_old_master.c_str());
|
||||
@ -96,7 +96,7 @@ int main(int argc, char** argv)
|
||||
test.maxscales->wait_for_monitor(); // Wait for monitor to update status
|
||||
get_output(test);
|
||||
master_id = get_master_server_id(test);
|
||||
test.assert(master_id == old_master_id, "Switchover back to server1 failed.");
|
||||
test.expect(master_id == old_master_id, "Switchover back to server1 failed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ int main(int argc, char** argv)
|
||||
|| mysql_query(nodes[i], RESET_SLAVE) != 0
|
||||
|| mysql_query(nodes[i], READ_ONLY_OFF) != 0)
|
||||
{
|
||||
test.assert(false, "Could not stop slave connections and/or disable read_only for node %d.", i);
|
||||
test.expect(false, "Could not stop slave connections and/or disable read_only for node %d.", i);
|
||||
return test.global_result;
|
||||
}
|
||||
}
|
||||
@ -82,7 +82,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
print_gtids(test);
|
||||
bool gtids_ok = (gtid_begin == gtid_node2 && gtid_node2 < gtid_node3);
|
||||
test.assert(gtids_ok, "Gtid:s have not advanced correctly.");
|
||||
test.expect(gtids_ok, "Gtid:s have not advanced correctly.");
|
||||
if (!gtids_ok)
|
||||
{
|
||||
return test.global_result;
|
||||
@ -101,8 +101,8 @@ int main(int argc, char** argv)
|
||||
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.assert(states_n2_ok, "Node 2 has not rejoined when it should have.");
|
||||
test.assert(states_n3_ok, "Node 3 rejoined when it shouldn't have.");
|
||||
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 (!states_n2_ok || !states_n3_ok)
|
||||
{
|
||||
return test.global_result;
|
||||
@ -122,11 +122,11 @@ int main(int argc, char** argv)
|
||||
test.maxscales->wait_for_monitor();
|
||||
get_output(test);
|
||||
int master_id = get_master_server_id(test);
|
||||
test.assert(master_id == 4, "Server 4 should be the cluster master.");
|
||||
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.assert(states_n0_ok, "Server 1 is not a slave when it should be.");
|
||||
test.expect(states_n0_ok, "Server 1 is not a slave when it should be.");
|
||||
if (states_n0_ok)
|
||||
{
|
||||
int ec;
|
||||
@ -136,7 +136,7 @@ int main(int argc, char** argv)
|
||||
&ec);
|
||||
test.maxscales->wait_for_monitor();
|
||||
master_id = get_master_server_id(test);
|
||||
test.assert(master_id == 1, "Server 1 should be the cluster master.");
|
||||
test.expect(master_id == 1, "Server 1 should be the cluster master.");
|
||||
get_output(test);
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ void expect(TestConnections& test, const char* zServer, const StringSet& expecte
|
||||
|
||||
if (found != expected)
|
||||
{
|
||||
test.assert(false, "Found states are not the same as the expected ones.");
|
||||
test.expect(false, "Found states are not the same as the expected ones.");
|
||||
++test.global_result;
|
||||
}
|
||||
|
||||
|
@ -450,18 +450,18 @@ bool check_server_status(TestConnections& test, int id)
|
||||
if (find_field(pConn, "SHOW SLAVE STATUS", "Last_IO_Error", result) == 0)
|
||||
{
|
||||
cout << result << endl;
|
||||
test.assert(false, "Server is neither slave, nor master.");
|
||||
test.expect(false, "Server is neither slave, nor master.");
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "?" << endl;
|
||||
test.assert(false, "Could not execute \"SHOW SLAVE STATUS\"");
|
||||
test.expect(false, "Could not execute \"SHOW SLAVE STATUS\"");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "?" << endl;
|
||||
test.assert(false, "Unexpected server state for %s.", server.c_str());
|
||||
test.expect(false, "Unexpected server state for %s.", server.c_str());
|
||||
}
|
||||
|
||||
return is_master;
|
||||
@ -476,7 +476,7 @@ void check_server_statuses(TestConnections& test)
|
||||
masters += check_server_status(test, 3);
|
||||
masters += check_server_status(test, 4);
|
||||
|
||||
test.assert(masters == 1, "Unpexpected number of masters: %d", masters);
|
||||
test.expect(masters == 1, "Unpexpected number of masters: %d", masters);
|
||||
}
|
||||
|
||||
int get_next_master_id(TestConnections& test, int current_id)
|
||||
@ -600,11 +600,11 @@ void run(TestConnections& test)
|
||||
|
||||
if (master_id < 0)
|
||||
{
|
||||
test.assert(false, "No master available after switchover.");
|
||||
test.expect(false, "No master available after switchover.");
|
||||
}
|
||||
else if (master_id != current_master_id)
|
||||
{
|
||||
test.assert(false,
|
||||
test.expect(false,
|
||||
"Master should have been server%d, but it was server%d.",
|
||||
current_master_id,
|
||||
master_id);
|
||||
@ -612,7 +612,7 @@ void run(TestConnections& test)
|
||||
}
|
||||
else
|
||||
{
|
||||
test.assert(false,
|
||||
test.expect(false,
|
||||
"Could not find any slave to switch to.");
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ int main(int argc, char** argv)
|
||||
|
||||
for (auto a : statements)
|
||||
{
|
||||
test.assert(execute_query_check_one(test.maxscales->conn_rwsplit[0], a.first, a.second) == 0,
|
||||
test.expect(execute_query_check_one(test.maxscales->conn_rwsplit[0], a.first, a.second) == 0,
|
||||
"Expected '%s' for query: %s",
|
||||
a.second,
|
||||
a.first);
|
||||
@ -41,7 +41,7 @@ int main(int argc, char** argv)
|
||||
|
||||
for (auto a : oracle_statements)
|
||||
{
|
||||
test.assert(execute_query_check_one(test.maxscales->conn_rwsplit[0], a.first, a.second) == 0,
|
||||
test.expect(execute_query_check_one(test.maxscales->conn_rwsplit[0], a.first, a.second) == 0,
|
||||
"Expected '%s' for query: %s",
|
||||
a.second,
|
||||
a.first);
|
||||
|
@ -27,9 +27,9 @@ int main(int argc, char** argv)
|
||||
|
||||
auto get_id = [&]() {
|
||||
Connection c = test.maxscales->readconn_slave();
|
||||
test.assert(c.connect(), "Connection should be OK: %s", c.error());
|
||||
test.expect(c.connect(), "Connection should be OK: %s", c.error());
|
||||
string res = c.field("SELECT @@server_id");
|
||||
test.assert(!res.empty(), "Field should not be empty: %s", c.error());
|
||||
test.expect(!res.empty(), "Field should not be empty: %s", c.error());
|
||||
return res;
|
||||
};
|
||||
|
||||
@ -51,28 +51,28 @@ int main(int argc, char** argv)
|
||||
|
||||
string first = get_id();
|
||||
auto it = find(begin(ids), end(ids), first);
|
||||
test.assert(it != end(ids), "ID should be found");
|
||||
test.expect(it != end(ids), "ID should be found");
|
||||
int node = distance(begin(ids), it);
|
||||
|
||||
test.tprintf("Blocking the slave that replied to us");
|
||||
test.repl->block_node(node);
|
||||
test.maxscales->wait_for_monitor();
|
||||
test.assert(!in_use(first), "The first slave should not be in use");
|
||||
test.expect(!in_use(first), "The first slave should not be in use");
|
||||
|
||||
test.tprintf("Unblocking all nodes");
|
||||
test.repl->unblock_all_nodes();
|
||||
test.maxscales->wait_for_monitor();
|
||||
test.assert(in_use(first), "The first slave should be in use");
|
||||
test.expect(in_use(first), "The first slave should be in use");
|
||||
|
||||
test.tprintf("Stopping replication on first slave");
|
||||
execute_query(test.repl->nodes[node], "STOP SLAVE");
|
||||
test.maxscales->wait_for_monitor();
|
||||
test.assert(!in_use(first), "The first slave should not be in use");
|
||||
test.expect(!in_use(first), "The first slave should not be in use");
|
||||
|
||||
test.tprintf("Starting replication on first slave");
|
||||
execute_query(test.repl->nodes[node], "START SLAVE");
|
||||
test.maxscales->wait_for_monitor();
|
||||
test.assert(in_use(first), "The first slave should be in use");
|
||||
test.expect(in_use(first), "The first slave should be in use");
|
||||
test.repl->disconnect();
|
||||
|
||||
return test.global_result;
|
||||
|
@ -404,7 +404,7 @@ void TestConnections::add_result(bool result, const char* format, ...)
|
||||
}
|
||||
}
|
||||
|
||||
void TestConnections::assert(bool result, const char* format, ...)
|
||||
void TestConnections::expect(bool result, const char* format, ...)
|
||||
{
|
||||
if (!result)
|
||||
{
|
||||
@ -847,7 +847,7 @@ int TestConnections::copy_maxscale_logs(double timestamp)
|
||||
|
||||
const char* command = "ls /tmp/core* && exit 42";
|
||||
int rc = maxscales->ssh_node_f(i, true, "%s", command);
|
||||
assert(rc != 42, "Test should not generate core files");
|
||||
expect(rc != 42, "Test should not generate core files");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ public:
|
||||
void add_result(bool result, const char* format, ...);
|
||||
|
||||
/** Same as add_result() but inverted */
|
||||
void assert(bool result, const char* format, ...);
|
||||
void expect(bool result, const char *format, ...);
|
||||
|
||||
/**
|
||||
* @brief ReadEnv Reads all Maxscale and Master/Slave and Galera setups info from environmental variables
|
||||
@ -560,7 +560,7 @@ public:
|
||||
void check_maxctrl(std::string cmd, int m = 0, bool sudo = true)
|
||||
{
|
||||
auto result = maxctrl(cmd, m, sudo);
|
||||
assert(result.first == 0, "Command '%s' should work: %s", cmd.c_str(), result.second.c_str());
|
||||
expect(result.first == 0, "Command '%s' should work: %s", cmd.c_str(), result.second.c_str());
|
||||
}
|
||||
|
||||
void check_current_operations(int m, int value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user