MXS-1503: Add test case
Added test case that checks that session commands are properly executed.
This commit is contained in:
@ -596,6 +596,9 @@ add_test_executable(mxs1476.cpp mxs1476 mxs1476 LABELS GALERA_BACKEND)
|
|||||||
# https://jira.mariadb.org/browse/MXS-1503
|
# https://jira.mariadb.org/browse/MXS-1503
|
||||||
add_test_executable(mxs1503_master_reconnection.cpp mxs1503_master_reconnection mxs1503_master_reconnection LABELS REPL_BACKEND)
|
add_test_executable(mxs1503_master_reconnection.cpp mxs1503_master_reconnection mxs1503_master_reconnection LABELS REPL_BACKEND)
|
||||||
|
|
||||||
|
# Master reconnection with session commands
|
||||||
|
add_test_executable(mxs1503_queued_sescmd.cpp mxs1503_queued_sescmd mxs1503_master_reconnection LABELS REPL_BACKEND)
|
||||||
|
|
||||||
# MXS-1509: Show correct server state for multisource replication
|
# MXS-1509: Show correct server state for multisource replication
|
||||||
# https://jira.mariadb.org/browse/MXS-1509
|
# https://jira.mariadb.org/browse/MXS-1509
|
||||||
add_test_executable(mxs1509.cpp mxs1509 mxs1509 LABELS REPL_BACKEND)
|
add_test_executable(mxs1509.cpp mxs1509 mxs1509 LABELS REPL_BACKEND)
|
||||||
|
58
maxscale-system-test/mxs1503_queued_sescmd.cpp
Normal file
58
maxscale-system-test/mxs1503_queued_sescmd.cpp
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/**
|
||||||
|
* MXS-1503: Test master reconnection with session command history
|
||||||
|
*
|
||||||
|
* https://jira.mariadb.org/browse/MXS-1503
|
||||||
|
*/
|
||||||
|
#include "testconnections.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <iostream>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
TestConnections test(argc, argv);
|
||||||
|
|
||||||
|
auto query = [&test](std::string q)
|
||||||
|
{
|
||||||
|
return execute_query_silent(test.maxscales->conn_rwsplit[0], q.c_str());
|
||||||
|
};
|
||||||
|
|
||||||
|
auto check_result = [&test](std::string name, std::string res)
|
||||||
|
{
|
||||||
|
std::string query = "SELECT " + name;
|
||||||
|
char value[1024];
|
||||||
|
return find_field(test.maxscales->conn_rwsplit[0], query.c_str(), name.c_str(), value) == 0 &&
|
||||||
|
res == value;
|
||||||
|
};
|
||||||
|
|
||||||
|
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.");
|
||||||
|
|
||||||
|
// 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.");
|
||||||
|
|
||||||
|
// Block the master to trigger reconnection
|
||||||
|
cout << "Blocking master" << endl;
|
||||||
|
test.repl->block_node(0);
|
||||||
|
sleep(10);
|
||||||
|
cout << "Unblocking master" << endl;
|
||||||
|
test.repl->unblock_node(0);
|
||||||
|
sleep(10);
|
||||||
|
|
||||||
|
// 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");
|
||||||
|
query("DROP TABLE test.t1");
|
||||||
|
|
||||||
|
return test.global_result;
|
||||||
|
}
|
Reference in New Issue
Block a user