MXS-3324 Test switchover with autocommit off
This commit is contained in:
parent
7e6eb55618
commit
36b97ea198
@ -102,6 +102,7 @@ add_test_executable_ex(NAME verify_master_failure SOURCE verify_master_failure.c
|
||||
CONFIG verify_master_failure.cnf VMS repl_backend LABELS mysqlmon)
|
||||
|
||||
# MariaDB-Monitor enforce_simple_topology
|
||||
# Also MXS-3324 switchover when autocommit is off on backends.
|
||||
add_test_executable_ex(NAME mysqlmon_enforce_simple SOURCE mysqlmon_enforce_simple.cpp
|
||||
CONFIG mysqlmon_enforce_simple.cnf VMS repl_backend LABELS mysqlmon)
|
||||
|
||||
|
@ -97,5 +97,53 @@ int main(int argc, char** argv)
|
||||
new_master_id = get_master_server_id(test);
|
||||
test.expect(new_master_id == server_ids[master_ind], "Switchover to original master failed.");
|
||||
}
|
||||
|
||||
if (test.ok())
|
||||
{
|
||||
// Test that switchover works even if autocommit is off on all backends.
|
||||
test.tprintf("Setting autocommit=0 on all backends, then check that switchover works.");
|
||||
test.maxscales->stop();
|
||||
test.repl->connect();
|
||||
const char set_ac[] = "SET GLOBAL autocommit=%i;";
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
test.try_query(test.repl->nodes[i], set_ac, 0);
|
||||
}
|
||||
test.maxscales->start();
|
||||
|
||||
// Check that autocommit is really off.
|
||||
Connection conn = test.repl->get_connection(2);
|
||||
conn.connect();
|
||||
auto row = conn.row("SELECT @@GLOBAL.autocommit;");
|
||||
test.expect(!row.empty() && row[0] == "0", "autocommit is not off");
|
||||
|
||||
new_master_id = get_master_server_id(test);
|
||||
test.expect(new_master_id == server_ids[master_ind], "No valid master");
|
||||
|
||||
if (test.ok())
|
||||
{
|
||||
test.tprintf("Switchover...");
|
||||
string switchover = "call command mariadbmon switchover MariaDB-Monitor";
|
||||
test.maxscales->execute_maxadmin_command(0, switchover.c_str());
|
||||
test.maxscales->wait_for_monitor(2);
|
||||
new_master_id = get_master_server_id(test);
|
||||
test.expect(new_master_id != server_ids[master_ind], "Switchover failed.");
|
||||
if (test.ok())
|
||||
{
|
||||
test.expect(new_master_id == server_ids[1], "Switchover to wrong server.");
|
||||
}
|
||||
|
||||
switchover = "call command mariadbmon switchover MariaDB-Monitor " + master_name;
|
||||
test.maxscales->execute_maxadmin_command(0, switchover.c_str());
|
||||
test.maxscales->wait_for_monitor(2);
|
||||
new_master_id = get_master_server_id(test);
|
||||
test.expect(new_master_id == server_ids[master_ind], "Switchover to original master failed.");
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
test.try_query(test.repl->nodes[i], set_ac, 1);
|
||||
}
|
||||
}
|
||||
return test.global_result;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user