Commit a1a7414b authored by Philip Stoev's avatar Philip Stoev Committed by Nirbhay Choubey

Galera MTR Tests: An end-to-end test with restoring a node from xtrabackup; a...

Galera MTR Tests: An end-to-end test with restoring a node from xtrabackup; a test for restoring the primary component via pc.bootstrap
parent 1e290689
CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
SELECT COUNT(*) = 1 FROM t1;
COUNT(*) = 1
1
UPDATE t1 SET f1 = 2 WHERE f1 = 1;
SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2;
COUNT(*) = 1
1
DROP TABLE t1;
!include ../galera_2nodes.cnf
[mysqld.1]
log-bin=log1
[mysqld.2]
log-bin=log2
#
# A simple test that confirms that Galera works with log-bin enabled, that is
# when MySQL's binlog is in effect rather than the Galera 'dummy' implementation.
#
--source include/have_binlog_format_row.inc
--source include/galera_cluster.inc
CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
--connection node_2
SELECT COUNT(*) = 1 FROM t1;
--connection node_1
UPDATE t1 SET f1 = 2 WHERE f1 = 1;
--connection node_2
SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2;
DROP TABLE t1;
CREATE TABLE t1 (f1 INTEGER);
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
SELECT COUNT(*) = 10 FROM t1;
COUNT(*) = 10
1
Killing server ...
INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19),(20);
SELECT COUNT(*) = 20 FROM t1;
COUNT(*) = 20
1
DROP TABLE t1;
CREATE TABLE t1 (f1 INTEGER);
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
SET SESSION wsrep_sync_wait = 0;
SHOW STATUS LIKE 'wsrep_cluster_status';
Variable_name Value
wsrep_cluster_status non-Primary
SET GLOBAL wsrep_provider_options = 'pc.bootstrap=1';
SHOW STATUS LIKE 'wsrep_cluster_size';
Variable_name Value
wsrep_cluster_size 1
SHOW STATUS LIKE 'wsrep_cluster_status';
Variable_name Value
wsrep_cluster_status Primary
INSERT INTO t1 VALUES (1);
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
SELECT COUNT(*) FROM t1;
COUNT(*)
1
SELECT COUNT(*) FROM t1;
COUNT(*)
1
SELECT COUNT(*) FROM t1;
COUNT(*)
1
DROP TABLE t1;
#
# This test uses innobackupex to take a backup on node #2 and then restores that node from backup
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
--connection node_1
CREATE TABLE t1 (f1 INTEGER);
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
--connection node_2
SELECT COUNT(*) = 10 FROM t1;
--exec innobackupex $MYSQL_TMP_DIR/innobackupex_backup --galera-info --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 --port=$NODE_MYPORT_2 --host=127.0.0.1 --no-timestamp > $MYSQL_TMP_DIR/innobackupex-backup.log
--exec innobackupex $MYSQL_TMP_DIR/innobackupex_backup --apply-log --galera-info --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 --port=$NODE_MYPORT_2 --host=127.0.0.1 --no-timestamp > $MYSQL_TMP_DIR/innobackupex-apply.log
--source include/kill_galera.inc
--sleep 1
--connection node_1
INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19),(20);
--exec rm -rf $MYSQLTEST_VARDIR/mysqld.2/data/*
--exec innobackupex --copy-back $MYSQL_TMP_DIR/innobackupex_backup --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 --port=$NODE_MYPORT_2 --host=127.0.0.1 > $MYSQL_TMP_DIR/innobackupex-restore.log
#
# Convert the xtrabackup_galera_info into a grastate.dat file
#
--perl
use strict;
my $xtrabackup_galera_info_file = $ENV{'MYSQL_TMP_DIR'}.'/innobackupex_backup/xtrabackup_galera_info';
open(XTRABACKUP_GALERA_INFO, $xtrabackup_galera_info_file) or die "Can not open $xtrabackup_galera_info_file: $!";
my $xtrabackup_galera_info = <XTRABACKUP_GALERA_INFO>;
my ($uuid, $seqno) = split(':', $xtrabackup_galera_info);
my $grastate_dat_file = $ENV{'MYSQLTEST_VARDIR'}.'/mysqld.2/data/grastate.dat';
die "grastate.dat already exists" if -e $grastate_dat_file;
open(GRASTATE_DAT, ">$grastate_dat_file") or die "Can not write to $grastate_dat_file: $!";
print GRASTATE_DAT "version: 2.1\n";
print GRASTATE_DAT "uuid: $uuid\n";
print GRASTATE_DAT "seqno: $seqno\n";
print GRASTATE_DAT "cert_index:\n";
exit(0);
EOF
--source include/start_mysqld.inc
--source include/wait_until_connected_again.inc
SELECT COUNT(*) = 20 FROM t1;
DROP TABLE t1;
--sleep 10
#
# Test the operation of pc.bootstrap
#
--source include/big_test.inc
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE t1 (f1 INTEGER);
# Force all nodes to become non-primary
--connection node_1
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
--connection node_2
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
--connection node_3
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
--sleep 10
# Node #2 should be non-primary
SET SESSION wsrep_sync_wait = 0;
SHOW STATUS LIKE 'wsrep_cluster_status';
# Signal node #2 to bootstrap
--connection node_2
SET GLOBAL wsrep_provider_options = 'pc.bootstrap=1';
# Wait until node becomes available for queries again
--source include/wait_until_connected_again.inc
# Node #2 should now be a primary of a 1-node cluster
SHOW STATUS LIKE 'wsrep_cluster_size';
SHOW STATUS LIKE 'wsrep_cluster_status';
# Perform an insert on node #2
INSERT INTO t1 VALUES (1);
# Reconnect all nodes
--connection node_2
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
--sleep 10
--source include/wait_until_connected_again.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--source include/wait_condition.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
--source include/wait_condition.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc
--connection node_1
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
--source include/wait_until_connected_again.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--source include/wait_condition.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
--source include/wait_condition.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc
--connection node_3
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
--sleep 10
--source include/wait_until_connected_again.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--source include/wait_condition.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
--source include/wait_condition.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc
# Check that all nodes have the same view of the database
--connection node_1
SELECT COUNT(*) FROM t1;
--connection node_2
SELECT COUNT(*) FROM t1;
--connection node_3
SELECT COUNT(*) FROM t1;
# Test cleanup
DROP TABLE t1;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment