Files
MaxScale/maxscale-system-test/ccrfilter_global.cpp
Markus Mäkelä 0a897aa839 Fix ccrfilter_global
Made sure that the inserted row is replicated before inserting another
one. Shortened the test so that slower systems finish it within a
reasonable time. Increased the time that the writes are routed to the
master.
2019-11-08 07:39:20 +02:00

49 lines
1.5 KiB
C++

/**
* Test global mode for the CCRFilter
*/
#include "testconnections.h"
int main(int argc, char* argv[])
{
TestConnections test(argc, argv);
auto conn = test.maxscales->rwsplit();
conn.connect();
test.expect(conn.query("CREATE OR REPLACE TABLE test.t1 (a LONGTEXT)"),
"Table creation should work: %s", conn.error());
conn.disconnect();
std::string data(1000000, 'a');
auto secondary = test.maxscales->rwsplit();
secondary.connect();
for (int i = 0; i < 25; i++)
{
conn.connect();
test.expect(conn.query("INSERT INTO test.t1 VALUES ('" + data + "')"),
"INSERT should work: %s", conn.error());
conn.disconnect();
// New connections should see the inserted rows
conn.connect();
auto count = std::stoi(conn.field("SELECT COUNT(*) FROM test.t1"));
test.expect(count == i + 1, "Missing `%d` rows.", (i + 1) - count);
conn.disconnect();
// Existing connections should also see the inserted rows
auto second_count = std::stoi(secondary.field("SELECT COUNT(*) FROM test.t1"));
test.expect(second_count == i + 1, "Missing `%d` rows from open connection.", (i + 1) - count);
// Make sure the row is replicated before inserting another one
test.repl->sync_slaves();
}
conn.connect();
test.expect(conn.query("DROP TABLE test.t1"),
"Table creation should work: %s", conn.error());
conn.disconnect();
return test.global_result;
}