polardbxengine/mysql-test/suite/ndb/t/ndb_76_inplace_upgrade.test

178 lines
6.2 KiB
Plaintext

--source include/have_multi_ndb.inc
--source suite/ndb/include/backup_restore_setup.inc
# Test to check inplace upgrade from 7.6. The initial server upgrade
# phase i.e. the phase during which InnoDB and other SE tables are
# upgraded should not upgrade NDB tables. NDB tables are instead
# upgraded during the schema synchronization phase.
#
# For inplace upgrade with NDB tables, another requirement is to
# ensure that the tables are present in NDB Dictionary. This is
# done through restoring a 7.6 based backup created using the
# following SQL statements:
#
# CREATE DATABASE test;
# USE test;
# CREATE LOGFILE GROUP lg1
# ADD UNDOFILE 'lg1_undofile.dat'
# INITIAL_SIZE 1M
# UNDO_BUFFER_SIZE = 1M
# ENGINE NDB;
# CREATE TABLESPACE ts1
# ADD DATAFILE 'ts1_datafile.dat'
# USE LOGFILE GROUP lg1
# INITIAL_SIZE 2M
# ENGINE NDB;
# CREATE TABLE t1 (
# a int PRIMARY KEY,
# b varchar(255)
# ) ENGINE = NDB
# TABLESPACE ts1
# STORAGE DISK;
# INSERT INTO t1 VALUES (1, "Solskjaer has won it");
# CREATE DATABASE db1;
# USE db1;
# CREATE TABLE t1 (
# a int PRIMARY KEY,
# b varchar(255)
# ) ENGINE NDB;
# INSERT INTO t1 VALUES (1, "Manchester United have");
# INSERT INTO t1 VALUES (2, "Reached the promised land");
#
# This test does the following:
# 1. Stops both MySQL servers
# 2. Restores the NDB backup
# 3. Unzips the 7.6 data directories
# 4. Restarts both MySQL servers (step where the upgrade takes place)
# 5. Runs test DDL statements and queries
# 6. Clean up which includes restarting both MySQL servers
--let $MYSQLD_DATADIR = `select @@datadir`
--echo # Stop MySQL server 1
--let $restart_file1 = $MYSQLTEST_VARDIR/tmp/mysqld.1.1.expect
--exec echo "wait" > $restart_file1
--shutdown_server 30
--source include/wait_until_disconnected.inc
--connection server2
--echo # Stop MySQL server 2
--let $restart_file2 = $MYSQLTEST_VARDIR/tmp/mysqld.2.1.expect
--exec echo "wait" > $restart_file2
--shutdown_server 30
--source include/wait_until_disconnected.inc
--connection server1
--echo # Restore 7.6 backup into NDB
--exec $NDB_RESTORE -b 1 -n 1 -m -r --disable-indexes --include-databases=mysql,test,db1 $NDB_SAVED_BACKUPS/76_inplace_upgrade_backup >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE -b 1 -n 2 -r --include-databases=mysql,test,db1 $NDB_SAVED_BACKUPS/76_inplace_upgrade_backup >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE -b 1 -n 1 --rebuild-indexes --include-databases=mysql,test,db1 $NDB_SAVED_BACKUPS/76_inplace_upgrade_backup >> $NDB_TOOLS_OUTPUT
--echo # Setup the 7.6 data directory
--echo # Copy zip files to tmp
--copy_file $MYSQLTEST_VARDIR/std_data/data76.zip $MYSQL_TMP_DIR/data76.zip
--echo # Check that the file exists in the working folder
--file_exists $MYSQL_TMP_DIR/data76.zip
--echo # Unzip the contents
--exec unzip -qo $MYSQL_TMP_DIR/data76.zip -d $MYSQL_TMP_DIR
--echo # Rename the extracted root directory for server2
--move_file $MYSQL_TMP_DIR/data76_server1 $MYSQL_TMP_DIR/data76_server2
--echo # Unzip again for server1
--exec unzip -qo $MYSQL_TMP_DIR/data76.zip -d $MYSQL_TMP_DIR
--echo # Test upgrade on 7.6 data directory on MySQL server 1
--let $MYSQLD_DATADIR1 = $MYSQL_TMP_DIR/data76_server1
--let $MYSQLD_LOG1 = $MYSQLTEST_VARDIR/log/76_upgrade_server1.log
--replace_result $MYSQLD MYSQLD $MYSQLD_DATADIR1 MYSQLD_DATADIR1 $MYSQLD_LOG1 MYSQLD_LOG1
--exec echo "restart: --datadir=$MYSQLD_DATADIR1 --log-error=$MYSQLD_LOG1" > $restart_file1
--let $wait_counter= 10000
--enable_reconnect
--source include/wait_until_connected_again.inc
--let SEARCH_FILE= $MYSQLD_LOG1
# Server shutdown error can show up during high IO loads
--let IGNORE_PATTERN= \[ERROR\] \[[^]]*\] \[[^]]*\] Event Scheduler\: \[root@localhost\]\[events\.myevent\] (Unknown column \'c1\' in \'field list\'|Server shutdown in progress)
--let SEARCH_PATTERN= \[ERROR\]
--source include/search_pattern.inc
--connection server2
--echo # Test upgrade on 7.6 data directory on MySQL server 2
--let $MYSQLD_DATADIR2 = $MYSQL_TMP_DIR/data76_server2
--let $MYSQLD_LOG2 = $MYSQLTEST_VARDIR/log/76_upgrade_server2.log
--replace_result $MYSQLD MYSQLD $MYSQLD_DATADIR2 MYSQLD_DATADIR2 $MYSQLD_LOG2 MYSQLD_LOG2
--exec echo "restart: --datadir=$MYSQLD_DATADIR2 --log-error=$MYSQLD_LOG2" > $restart_file2
--let $wait_counter= 10000
--enable_reconnect
--source include/wait_until_connected_again.inc
--let SEARCH_FILE= $MYSQLD_LOG2
# Server shutdown error can show up during high IO loads
--let IGNORE_PATTERN= \[ERROR\] \[[^]]*\] \[[^]]*\] Event Scheduler\: \[root@localhost\]\[events\.myevent\] (Unknown column \'c1\' in \'field list\'|Server shutdown in progress)
--let SEARCH_PATTERN= \[ERROR\]
--source include/search_pattern.inc
--connection server1
# Check if the tables have been upgraded properly in server1
SHOW TABLES;
SELECT engine from information_schema.tables
WHERE table_schema='mysql' and table_name='user';
SHOW TABLES IN db1;
SHOW CREATE TABLE t1;
SHOW CREATE TABLE db1.t1;
--sorted_result
SELECT * FROM t1;
--sorted_result
SELECT * FROM db1.t1;
ALTER TABLE t1 DROP COLUMN b;
--connection server2
# Check if the tables have been upgraded properly in server2
SHOW TABLES;
SELECT engine from information_schema.tables
WHERE table_schema='mysql' and table_name='user';
SHOW TABLES IN db1;
SHOW CREATE TABLE t1;
SHOW CREATE TABLE db1.t1;
--sorted_result
SELECT * FROM t1;
--sorted_result
SELECT * FROM db1.t1;
# Clean up
--connection server1
DROP TABLE t1;
DROP TABLE db1.t1;
ALTER TABLESPACE ts1
DROP DATAFILE 'ts1_datafile.dat';
DROP TABLESPACE ts1;
DROP LOGFILE GROUP lg1
ENGINE NDB;
--exec echo "wait" > $restart_file1
--shutdown_server 30
--source include/wait_until_disconnected.inc
--exec echo "restart" > $restart_file1
--let $wait_counter= 10000
--enable_reconnect
--source include/wait_until_connected_again.inc
--connection server2
--exec echo "wait" > $restart_file2
--shutdown_server 30
--source include/wait_until_disconnected.inc
--exec echo "restart" > $restart_file2
--let $wait_counter= 10000
--enable_reconnect
--source include/wait_until_connected_again.inc
--force-rmdir $MYSQLD_DATADIR1
--force-rmdir $MYSQLD_DATADIR2
--remove_file $MYSQL_TMP_DIR/data76.zip
--exec $NDB_DROP_TABLE -d mysql db user tables_priv columns_priv procs_priv proxies_priv >> $NDB_TOOLS_OUTPUT
let NDB_RESTORE=;
--remove_file $NDB_TOOLS_OUTPUT