MXS-2515: Add KILL QUERY test case
The test checks that queries are killed properly.
This commit is contained in:
@ -204,6 +204,9 @@ add_test_executable(maxctrl_basic.cpp maxctrl_basic maxctrl_basic LABELS maxctrl
|
|||||||
# MXS-2167: Monitors should be able to use extra_port
|
# MXS-2167: Monitors should be able to use extra_port
|
||||||
add_test_executable(mxs2167_extra_port.cpp mxs2167_extra_port mxs2167_extra_port LABELS REPL_BACKEND)
|
add_test_executable(mxs2167_extra_port.cpp mxs2167_extra_port mxs2167_extra_port LABELS REPL_BACKEND)
|
||||||
|
|
||||||
|
# Test KILL QUERY functionality
|
||||||
|
add_test_executable(kill_query.cpp kill_query replication LABELS REPL_BACKEND)
|
||||||
|
|
||||||
############################################
|
############################################
|
||||||
# BEGIN: Tests that require GTID #
|
# BEGIN: Tests that require GTID #
|
||||||
############################################
|
############################################
|
||||||
|
|||||||
50
maxscale-system-test/kill_query.cpp
Normal file
50
maxscale-system-test/kill_query.cpp
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/**
|
||||||
|
* Test KILL QUERY functionality
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "testconnections.h"
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
TestConnections test(argc, argv);
|
||||||
|
|
||||||
|
auto conn = test.maxscales->rwsplit();
|
||||||
|
conn.connect();
|
||||||
|
conn.query("CREATE OR REPLACE TABLE test.t1 (id LONGTEXT)");
|
||||||
|
|
||||||
|
for (int x = 0; x < 10; x++)
|
||||||
|
{
|
||||||
|
conn.query("INSERT INTO test.t1 VALUES (REPEAT('a', 5000000))");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
auto a = test.maxscales->rwsplit();
|
||||||
|
auto b = test.maxscales->rwsplit();
|
||||||
|
test.expect(a.connect() && b.connect(), "Connections should work");
|
||||||
|
|
||||||
|
auto id = a.thread_id();
|
||||||
|
|
||||||
|
test.set_timeout(15);
|
||||||
|
std::thread thr(
|
||||||
|
[&]() {
|
||||||
|
// The ALTER should take longer than 15 seconds to complete so that a KILL is required to
|
||||||
|
// interrupt it.
|
||||||
|
test.expect(!a.query("ALTER TABLE test.t1 FORCE"), "ALTER should fail");
|
||||||
|
|
||||||
|
const char* expected = "Query execution was interrupted";
|
||||||
|
test.expect(strstr(a.error(), expected),
|
||||||
|
"Alter should fail with '%s' but it failed with '%s'",
|
||||||
|
expected, a.error());
|
||||||
|
});
|
||||||
|
|
||||||
|
test.expect(b.query("KILL QUERY " + std::to_string(id)), "KILL QUERY failed: %s", b.error());
|
||||||
|
thr.join();
|
||||||
|
|
||||||
|
test.stop_timeout();
|
||||||
|
}
|
||||||
|
|
||||||
|
conn.query("DROP TABLE test.t1");
|
||||||
|
|
||||||
|
return test.global_result;
|
||||||
|
}
|
||||||
@ -342,6 +342,11 @@ public:
|
|||||||
return change_user(m_user, m_pw, m_db);
|
return change_user(m_user, m_pw, m_db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t thread_id() const
|
||||||
|
{
|
||||||
|
return mysql_thread_id(m_conn);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_host;
|
std::string m_host;
|
||||||
int m_port;
|
int m_port;
|
||||||
|
|||||||
Reference in New Issue
Block a user