From 4420730f31dd6877f2c73e540ade283fdeed7781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 7 Feb 2018 09:24:08 +0200 Subject: [PATCH] Start all tests with read_only disabled Explicitly checking and setting read_only allows all tests to have a consistent backend state. --- maxscale-system-test/mariadb_nodes.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/maxscale-system-test/mariadb_nodes.cpp b/maxscale-system-test/mariadb_nodes.cpp index 6071f7a63..1d8eff683 100644 --- a/maxscale-system-test/mariadb_nodes.cpp +++ b/maxscale-system-test/mariadb_nodes.cpp @@ -385,6 +385,7 @@ int Mariadb_nodes::start_replication() for (int i = 0; i < N; i++) { + execute_query(nodes[i], "SET GLOBAL read_only=OFF"); execute_query(nodes[i], "STOP SLAVE;"); if (g_require_gtid) @@ -551,6 +552,20 @@ int Mariadb_nodes::unblock_all_nodes() return rval; } +bool is_readonly(MYSQL* conn) +{ + bool rval = false; + char output[512]; + find_field(conn, "SHOW VARIABLES LIKE 'read_only'", "Value", output); + + if (strcasecmp(output, "OFF") != 0) + { + rval = true; + } + + return rval; +} + bool Mariadb_nodes::check_master_node(MYSQL *conn) { bool rval = true; @@ -600,10 +615,7 @@ bool Mariadb_nodes::check_master_node(MYSQL *conn) } } - char output[512]; - find_field(conn, "SHOW VARIABLES LIKE 'read_only'", "Value", output); - - if (strcmp(output, "OFF")) + if (is_readonly(conn)) { printf("The master is in read-only mode\n"); rval = false; @@ -754,7 +766,8 @@ int Mariadb_nodes::check_replication() else if (bad_slave_thread_status(nodes[i], "Slave_IO_Running", i) || bad_slave_thread_status(nodes[i], "Slave_SQL_Running", i) || wrong_replication_type(nodes[i]) || - multi_source_replication(nodes[i], i)) + multi_source_replication(nodes[i], i) || + is_readonly(nodes[i])) { res = 1; if (verbose)