Files
MaxScale/system-test/mxs2350_lazy_connect.cpp
2020-07-28 16:15:50 +03:00

40 lines
1.3 KiB
C++

/**
* MXS-2350: On-demand connection creation
* https://jira.mariadb.org/browse/MXS-2350
*/
#include <maxtest/testconnections.hh>
#include <maxbase/string.hh>
int main(int argc, char* argv[])
{
TestConnections test(argc, argv);
Connection c = test.maxscales->rwsplit();
test.expect(c.connect(), "Connection should work");
auto output = test.maxscales->ssh_output("maxctrl list servers --tsv|cut -f 4|sort|uniq").second;
mxb::trim(output);
test.expect(output == "0", "Servers should have no connections: %s", output.c_str());
c.disconnect();
test.expect(c.connect(), "Connection should work");
test.expect(c.query("SELECT 1"), "Read should work");
c.disconnect();
test.expect(c.connect(), "Connection should work");
test.expect(c.query("SELECT @@last_insert_id"), "Write should work");
c.disconnect();
test.expect(c.connect(), "Connection should work");
test.expect(c.query("SET @a = 1"), "Session command should work");
c.disconnect();
test.expect(c.connect(), "Connection should work");
test.expect(c.query("BEGIN"), "BEGIN should work");
test.expect(c.query("SELECT 1"), "Read should work");
test.expect(c.query("COMMIT"), "COMMIT command should work");
c.disconnect();
return test.global_result;
}