MXS-2295: Session command loop test case
Test executes various session commands in a loop and makes sure a COM_CHANGE_USER resets the history.
This commit is contained in:
@ -915,6 +915,9 @@ add_test_executable(mxs2111_auth_string.cpp mxs2111_auth_string replication LABE
|
||||
# MXS-2115: Automatic version_string detection
|
||||
add_test_executable(mxs2115_version_string.cpp mxs2115_version_string replication LABELS REPL_BACKEND)
|
||||
|
||||
# MXS-2295: COM_CHANGE_USER does not clear out session command history
|
||||
add_test_executable(mxs2295_change_user_loop.cpp mxs2295_change_user_loop mxs2295_change_user_loop LABELS REPL_BACKEND)
|
||||
|
||||
############################################
|
||||
# BEGIN: binlogrouter and avrorouter tests #
|
||||
############################################
|
||||
|
||||
50
maxscale-system-test/cnf/maxscale.cnf.template.mxs2295_change_user_loop
Executable file
50
maxscale-system-test/cnf/maxscale.cnf.template.mxs2295_change_user_loop
Executable file
@ -0,0 +1,50 @@
|
||||
[maxscale]
|
||||
threads=###threads###
|
||||
log_info=1
|
||||
|
||||
[server1]
|
||||
type=server
|
||||
address=###node_server_IP_1###
|
||||
port=###node_server_port_1###
|
||||
protocol=MySQLBackend
|
||||
|
||||
[server2]
|
||||
type=server
|
||||
address=###node_server_IP_2###
|
||||
port=###node_server_port_2###
|
||||
protocol=MySQLBackend
|
||||
|
||||
[server3]
|
||||
type=server
|
||||
address=###node_server_IP_3###
|
||||
port=###node_server_port_3###
|
||||
protocol=MySQLBackend
|
||||
|
||||
[server4]
|
||||
type=server
|
||||
address=###node_server_IP_4###
|
||||
port=###node_server_port_4###
|
||||
protocol=MySQLBackend
|
||||
|
||||
[MySQL Monitor]
|
||||
type=monitor
|
||||
module=mysqlmon
|
||||
servers=server1,server2,server3,server4
|
||||
user=maxskysql
|
||||
password=skysql
|
||||
monitor_interval=1000
|
||||
|
||||
[RW Split Router]
|
||||
type=service
|
||||
router=readwritesplit
|
||||
servers=server1,server2,server3,server4
|
||||
user=maxskysql
|
||||
password=skysql
|
||||
max_sescmd_history=20
|
||||
disable_sescmd_history=false
|
||||
|
||||
[RW Split Listener]
|
||||
type=listener
|
||||
service=RW Split Router
|
||||
protocol=MySQLClient
|
||||
port=4006
|
||||
@ -334,6 +334,16 @@ public:
|
||||
return mysql_error(m_conn);
|
||||
}
|
||||
|
||||
bool change_user(std::string user, std::string pw, std::string db = "test")
|
||||
{
|
||||
return mysql_change_user(m_conn, user.c_str(), pw.c_str(), db.c_str()) == 0;
|
||||
}
|
||||
|
||||
bool reset_connection()
|
||||
{
|
||||
return change_user(m_user, m_pw, m_db);
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_host;
|
||||
int m_port;
|
||||
|
||||
66
maxscale-system-test/mxs2295_change_user_loop.cpp
Normal file
66
maxscale-system-test/mxs2295_change_user_loop.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
/**
|
||||
* MXS-2295: COM_CHANGE_USER does not clear out session command history
|
||||
* https://jira.mariadb.org/browse/MXS-2295
|
||||
*/
|
||||
|
||||
#include "testconnections.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
TestConnections test(argc, argv);
|
||||
|
||||
|
||||
Connection conn = test.maxscales->rwsplit();
|
||||
test.expect(conn.connect(), "Connection failed: %s", conn.error());
|
||||
|
||||
for (int i = 0; i <= 300 && test.global_result == 0; i++)
|
||||
{
|
||||
if (i % 50 == 0)
|
||||
{
|
||||
test.tprintf("Iteration: %d", i);
|
||||
}
|
||||
|
||||
test.set_timeout(60);
|
||||
|
||||
// Interleaved session commands, reads and "writes" (`SELECT @@last_insert_id` is treated as a master-only read)
|
||||
test.expect(conn.query("SET @a = 1"), "Query failed: %s", conn.error());
|
||||
test.expect(conn.query("USE test"), "Query failed: %s", conn.error());
|
||||
test.expect(conn.query("SET SQL_MODE=''"), "Query failed: %s", conn.error());
|
||||
test.expect(conn.query("USE test"), "Query failed: %s", conn.error());
|
||||
test.expect(conn.query("SELECT @@last_insert_id"), "Query failed: %s", conn.error());
|
||||
test.expect(conn.query("SELECT 1"), "Query failed: %s", conn.error());
|
||||
test.expect(conn.query("USE test"), "Query failed: %s", conn.error());
|
||||
test.expect(conn.query("SELECT 1"), "Query failed: %s", conn.error());
|
||||
|
||||
// User variable inside transaction
|
||||
test.expect(conn.query("SET @a = 123"), "Query failed: %s", conn.error());
|
||||
test.expect(conn.query("BEGIN"), "Query failed: %s", conn.error());
|
||||
Row row = conn.row("SELECT @a");
|
||||
test.expect(!row.empty() && row[0] == "123", "Invalid contents in user variable inside RW trx");
|
||||
test.expect(conn.query("COMMIT"), "Query failed: %s", conn.error());
|
||||
|
||||
// User variable outside transaction
|
||||
test.expect(conn.query("SET @a = 321"), "Query failed: %s", conn.error());
|
||||
row = conn.row("SELECT @a");
|
||||
test.expect(!row.empty() && row[0] == "321", "Invalid contents in user variable outside trx");
|
||||
|
||||
// User variable inside read-only transaction
|
||||
test.expect(conn.query("SET @a = 456"), "Query failed: %s", conn.error());
|
||||
test.expect(conn.query("START TRANSACTION READ ONLY"), "Query failed: %s", conn.error());
|
||||
row = conn.row("SELECT @a");
|
||||
test.expect(!row.empty() && row[0] == "456", "Invalid contents in user variable inside RO trx");
|
||||
test.expect(conn.query("COMMIT"), "Query failed: %s", conn.error());
|
||||
|
||||
test.expect(conn.query("PREPARE ps FROM 'SELECT 1'"), "PREPARE failed: %s", conn.error());
|
||||
row = conn.row("EXECUTE ps");
|
||||
test.expect(!row.empty() && row[0] == "1", "Invalid contents in PS result");
|
||||
test.expect(conn.query("DEALLOCATE PREPARE ps"), "DEALLOCATE failed: %s", conn.error());
|
||||
|
||||
test.expect(conn.reset_connection(), "Connection reset failed: %s", conn.error());
|
||||
}
|
||||
|
||||
test.log_excludes(0, "Router session exceeded session command history limit");
|
||||
test.log_includes(0, "Resetting session command history");
|
||||
|
||||
return test.global_result;
|
||||
}
|
||||
Reference in New Issue
Block a user