From 8b09db8bfb81f1e7695cfcfa6ce2bec45247171f Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Wed, 24 Aug 2016 17:13:20 -0400 Subject: [PATCH] Fixes/improvements in galera test suite --- .../include/auto_increment_offset_restore.inc | 35 ++++++++++++++++++ .../include/auto_increment_offset_save.inc | 37 +++++++++++++++++++ .../galera/t/galera_ist_restart_joiner.test | 16 +++----- .../suite/galera/t/galera_pc_ignore_sb.test | 17 ++++----- .../galera/t/galera_restart_nochanges.test | 17 ++++----- .../suite/galera/t/galera_split_brain.test | 21 +++++------ .../suite/galera/t/galera_suspend_slave.test | 15 +++----- .../galera/t/galera_var_dirty_reads.test | 16 ++------ mysql-test/suite/galera/t/mysql-wsrep#31.test | 14 +++++++ .../t/galera_certification_ccc.test | 21 ++++------- 10 files changed, 131 insertions(+), 78 deletions(-) create mode 100644 mysql-test/suite/galera/include/auto_increment_offset_restore.inc create mode 100644 mysql-test/suite/galera/include/auto_increment_offset_save.inc diff --git a/mysql-test/suite/galera/include/auto_increment_offset_restore.inc b/mysql-test/suite/galera/include/auto_increment_offset_restore.inc new file mode 100644 index 00000000000..6218dfd6f2c --- /dev/null +++ b/mysql-test/suite/galera/include/auto_increment_offset_restore.inc @@ -0,0 +1,35 @@ +# See auto_increment_offset_restore.inc for details. + +if (!$node_1) +{ + --die ERROR IN TEST: $node_1 must be set before sourcing auto_increment_offset_save.inc +} + +if (!$node_2) +{ + --die ERROR IN TEST: $node_2 must be set before sourcing auto_increment_offset_save.inc +} + +if (!$auto_increment_offset_node_1) +{ + --die ERROR IN TEST: $auto_increment_offset_node_1 must be set before sourcing auto_increment_offset_save.inc +} + +if (!$auto_increment_offset_node_2) +{ + --die ERROR IN TEST: $auto_increment_offset_node_2 must be set before sourcing auto_increment_offset_save.inc +} + +# Restore original auto_increment_offset values. +--disable_query_log +--connection $node_1 +--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; +--connection $node_2 +--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; + +if ($node_3) +{ +--connection $node_3 +--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_3; +} +--enable_query_log diff --git a/mysql-test/suite/galera/include/auto_increment_offset_save.inc b/mysql-test/suite/galera/include/auto_increment_offset_save.inc new file mode 100644 index 00000000000..3c4db3f381c --- /dev/null +++ b/mysql-test/suite/galera/include/auto_increment_offset_save.inc @@ -0,0 +1,37 @@ +# This file can be used to save the @@global.auto_increment_offset value at +# the beginning of any test that intends to restart any of the participating +# nodes. This is required as the node may get auto-assigned a different +# auto_increment_offset value on restart, which could cause MTR's internal +# post-check to fail. auto_increment_offset_restore.inc can be used at the +# end of the test to restore these saved values. + +# Parameters +# ---------- +# $node_1 +# Connection handle for 1st node +# $node_2 +# Connection handle for 2nd node +# $node_3 (optional) +# Connection handle for 3rd node + +if (!$node_1) +{ + --die ERROR IN TEST: $node_1 must be set before sourcing auto_increment_offset_save.inc +} + +if (!$node_2) +{ + --die ERROR IN TEST: $node_2 must be set before sourcing auto_increment_offset_save.inc +} + +--connection $node_1 +let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; +--connection $node_2 +let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; + +if ($node_3) +{ + --connection $node_3 + let $auto_increment_offset_node_3 = `SELECT @@global.auto_increment_offset`; +} + diff --git a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test index 11664affe7c..931daaad30d 100644 --- a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test +++ b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test @@ -10,10 +10,9 @@ --source suite/galera/include/galera_have_debug_sync.inc # Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); INSERT INTO t1 VALUES (1, 'a'), (2, 'a'), (3, 'a'), (4, 'a'), (5, 'a'),(6, 'a'); @@ -114,10 +113,7 @@ SELECT COUNT(*) = 0 FROM t3; DROP TABLE t1, t2, t3; # Restore original auto_increment_offset values. ---disable_query_log ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---enable_query_log +--source include/auto_increment_offset_restore.inc + +--source include/galera_end.inc diff --git a/mysql-test/suite/galera/t/galera_pc_ignore_sb.test b/mysql-test/suite/galera/t/galera_pc_ignore_sb.test index f63215ebe4a..84fd3a91857 100644 --- a/mysql-test/suite/galera/t/galera_pc_ignore_sb.test +++ b/mysql-test/suite/galera/t/galera_pc_ignore_sb.test @@ -6,10 +6,9 @@ --source include/have_innodb.inc # Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --connection node_1 --let $wsrep_cluster_address_orig = `SELECT @@wsrep_cluster_address` @@ -40,10 +39,8 @@ SET GLOBAL wsrep_cluster_address = ''; --source include/start_mysqld.inc --source include/wait_until_connected_again.inc ---disable_query_log # Restore original auto_increment_offset values. ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---enable_query_log +--source include/auto_increment_offset_restore.inc + +--source include/galera_end.inc + diff --git a/mysql-test/suite/galera/t/galera_restart_nochanges.test b/mysql-test/suite/galera/t/galera_restart_nochanges.test index ba12c4c409c..0a6a0c5ccbe 100644 --- a/mysql-test/suite/galera/t/galera_restart_nochanges.test +++ b/mysql-test/suite/galera/t/galera_restart_nochanges.test @@ -6,10 +6,9 @@ --source include/have_innodb.inc # Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --connection node_1 CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; @@ -33,11 +32,9 @@ SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_N DROP TABLE t1; ---disable_query_log # Restore original auto_increment_offset values. ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2a ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---enable_query_log +--let $node_2=node_2a +--source include/auto_increment_offset_restore.inc + +--source include/galera_end.inc diff --git a/mysql-test/suite/galera/t/galera_split_brain.test b/mysql-test/suite/galera/t/galera_split_brain.test index e0298e55422..22f6370241c 100644 --- a/mysql-test/suite/galera/t/galera_split_brain.test +++ b/mysql-test/suite/galera/t/galera_split_brain.test @@ -6,17 +6,16 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + call mtr.add_suppression("WSREP: TO isolation failed for: "); --connection node_1 --let $wsrep_cluster_address_orig = `SELECT @@wsrep_cluster_address` -# Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; - --connection node_2 --source include/kill_galera.inc @@ -44,10 +43,8 @@ SET GLOBAL wsrep_cluster_address = ''; --source include/wait_until_connected_again.inc # Restore original auto_increment_offset values. ---disable_query_log ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2a ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---enable_query_log +--let $node_2=node_2a +--source include/auto_increment_offset_restore.inc + +--source include/galera_end.inc diff --git a/mysql-test/suite/galera/t/galera_suspend_slave.test b/mysql-test/suite/galera/t/galera_suspend_slave.test index 236c65b73a7..5c622085804 100644 --- a/mysql-test/suite/galera/t/galera_suspend_slave.test +++ b/mysql-test/suite/galera/t/galera_suspend_slave.test @@ -8,10 +8,9 @@ --source include/have_innodb.inc # Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --connection node_1 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; @@ -56,11 +55,7 @@ SELECT COUNT(*) = 1 FROM t1; DROP TABLE t1; ---disable_query_log # Restore original auto_increment_offset values. ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2a ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---enable_query_log +--let $node_2=node_2a +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_var_dirty_reads.test b/mysql-test/suite/galera/t/galera_var_dirty_reads.test index 9eea8efdaf3..dfd8d5ecf29 100644 --- a/mysql-test/suite/galera/t/galera_var_dirty_reads.test +++ b/mysql-test/suite/galera/t/galera_var_dirty_reads.test @@ -5,13 +5,10 @@ --source include/galera_cluster.inc --source include/have_innodb.inc ---disable_query_log # Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; ---enable_query_log +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --connection node_2 --let $wsrep_cluster_address_saved = `SELECT @@global.wsrep_cluster_address` @@ -49,13 +46,8 @@ SELECT * FROM t1; # Cleanup DROP TABLE t1; ---disable_query_log # Restore original auto_increment_offset values. ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---enable_query_log +--source include/auto_increment_offset_restore.inc --source include/galera_end.inc --echo # End of test diff --git a/mysql-test/suite/galera/t/mysql-wsrep#31.test b/mysql-test/suite/galera/t/mysql-wsrep#31.test index eaace5d50dd..c669d4834ba 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#31.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#31.test @@ -1,6 +1,11 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + --connection node_1 CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; @@ -36,4 +41,13 @@ if ($galera_wsrep_start_position != $expected_position) DROP TABLE t1; DROP DATABASE db; +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--source include/wait_until_connected_again.inc + +# Restore original auto_increment_offset values. +--let $node_2=node_2a +--source include/auto_increment_offset_restore.inc + +--source include/galera_end.inc + diff --git a/mysql-test/suite/galera_3nodes/t/galera_certification_ccc.test b/mysql-test/suite/galera_3nodes/t/galera_certification_ccc.test index e19169a350c..b4fe10bff0d 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_certification_ccc.test +++ b/mysql-test/suite/galera_3nodes/t/galera_certification_ccc.test @@ -10,12 +10,10 @@ --source include/galera_connect.inc # Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; ---connection node_3 -let $auto_increment_offset_node_3 = `SELECT @@global.auto_increment_offset`; +--let $node_1=node_1 +--let $node_2=node_2 +--let $node_3=node_3 +--source ../galera/include/auto_increment_offset_save.inc --connection node_1 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; @@ -49,12 +47,7 @@ SELECT COUNT(*) = 2 FROM t1; DROP TABLE t1; # Restore original auto_increment_offset values. ---disable_query_log ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---connection node_3 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_3; ---enable_query_log +--source ../galera/include/auto_increment_offset_restore.inc + +--source include/galera_end.inc