Extend mxs359_error_on_write

The test now checks that an error is returned even if the master fails
mid-query.
This commit is contained in:
Markus Mäkelä
2019-05-07 12:06:45 +03:00
parent 2b292c1e5c
commit 5960bb5e61

View File

@ -51,14 +51,23 @@ int main(int argc, char** argv)
TestConnections test(argc, argv);
self = &test;
Queries rw_ok({ {"INSERT INTO test.t1 VALUES (1)", true}, {"SELECT * FROM test.t1", true}});
Queries rw_err({ {"INSERT INTO test.t1 VALUES (1)", false}, {"SELECT * FROM test.t1", true}});
Queries rw_ok({{"INSERT INTO test.t1 VALUES (1)", true}, {"SELECT * FROM test.t1", true}});
Queries rw_err({{"INSERT INTO test.t1 VALUES (1)", false}, {"SELECT * FROM test.t1", true}});
Queries delayed_rw_err({{"INSERT INTO test.t1 VALUES (SLEEP(10))", false},
{"SELECT * FROM test.t1", true}});
Func block_master = [&test]() {
test.repl->block_node(0);
sleep(10);
};
Func delayed_block_master = [&test]() {
std::thread([&test]() {
sleep(5);
test.repl->block_node(0);
}).detach();
};
Func unblock_master = [&test]() {
test.repl->unblock_node(0);
sleep(10);
@ -97,6 +106,15 @@ int main(int argc, char** argv)
{"Change master and check that writes work", master_change, rw_ok},
{"Reset cluster", reset, {}}
}
},
{
"Master failure mid-query",
{
{"Check that writes work at startup", noop, rw_ok},
{"Do query and block master at the same time, check that write fails", delayed_block_master, delayed_rw_err},
{"Unblock master and check that writes do not fail", unblock_master, rw_ok},
{"Reset cluster", reset, {}}
}
}
});