Debian Codegraph @

mysql-test/suite/ndb/t/ndb_metadata_upgrade_large.test

raw
1 --source include/have_ndb.inc
2 --source suite/ndb/include/backup_restore_setup.inc
3
4 # This test upgrades metadata of a large number of tables which have the following
5 # structure:
6 #
7 # CREATE TABLE t1 (
8 # col1 int(20) unsigned NOT NULL AUTO_INCREMENT,
9 # col2 varchar(255) DEFAULT NULL,
10 # col3 varchar(255) DEFAULT NULL,
11 # col4 bigint(20) unsigned NOT NULL,
12 # col5 varchar(20) DEFAULT NULL,
13 # col6 tinyint(1) unsigned NOT NULL,
14 # col7 tinyint(1) unsigned DEFAULT NULL,
15 # col8 varchar(255) DEFAULT NULL,
16 # col9 int(11) unsigned DEFAULT NULL,
17 # col10 varchar(255) DEFAULT NULL,
18 # col11 varchar(255) DEFAULT NULL,
19 # col12 varchar(255) DEFAULT NULL,
20 # col13 bigint(20) unsigned DEFAULT NULL,
21 # col14 varchar(255) DEFAULT NULL,
22 # col15 varchar(20) DEFAULT NULL,
23 # col16 bigint(20) unsigned DEFAULT NULL,
24 # col17 decimal(10,5) NOT NULL,
25 # col18 decimal(10,5) NOT NULL,
26 # col19 decimal(10,5) NOT NULL,
27 # col20 float(7,2) NOT NULL,
28 # PRIMARY KEY (col1)
29 # ) CHARACTER SET=latin1 ENGINE=ndbcluster;
30 #
31 # The number of tables being restored (and upgraded) are configurable and controlled by the db_number variable.
32 # By default, db_number=1 which results in 100 tables i.e. `t1` to `t100` created in the `db1` database which
33 # are restored and upgraded. The number of tables being upgraded can be increased by multiples of 100 by adjusting
34 # the db_number variable. For example, setting db_number to 10 creates databases `db1` to `db10` and a total of
35 # 1000 (db_number*100) tables are upgraded. This somewhat convoluted test design is to ensure that this test can
36 # be run without issues in PB2 while also providing coverage of a larger upgrade scenario when run manually with a
37 # few tweaks in the test and its corresponding .cnf file.
38
39 --disable_query_log
40 # Set number of databases
41 --let $db_number=1
42
43 # Restore checked in backup
44 CREATE DATABASE db1;
45
46 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR -b 1 -n 1 -m $NDB_SAVED_BACKUPS/metadata_upgrade_large_backup >> $NDB_TOOLS_OUTPUT
47
48 # Create more tables if requested. Number of tables created = db_number*100
49 --let $i=1
50 while($i < $db_number)
51 {
52 --inc $i
53 --let $db_name=db$i
54 --eval CREATE DATABASE $db_name
55 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR -b 1 -n 1 -m --disable-indexes --rewrite-database=db1,$db_name $NDB_SAVED_BACKUPS/metadata_upgrade_large_backup >> $NDB_TOOLS_OUTPUT
56 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR -b 1 -n 1 --rebuild-indexes --rewrite-database=db1,$db_name $NDB_SAVED_BACKUPS/metadata_upgrade_large_backup >> $NDB_TOOLS_OUTPUT
57 }
58 --enable_query_log
59
60 --echo Backup restored
61
62 --echo Restart server 1 to trigger schema synchronization
63 let $mysqld_name=mysqld.1.1;
64 --source include/restart_mysqld.inc
65 --source include/ndb_wait_connected.inc
66
67 --echo Check that tables can be used
68 SELECT COUNT(*) FROM information_schema.tables
69 WHERE table_schema LIKE 'db%';
70
71 SHOW CREATE TABLE db1.t1;
72
73 ALTER TABLE db1.t50 DROP COLUMN col2;
74
75 ALTER TABLE db1.t100 DROP COLUMN col20;
76
77 --disable_query_log
78 --let $i=0
79 while($i < $db_number)
80 {
81 --inc $i
82 --eval DROP DATABASE db$i
83 }
84
85 --remove_file $NDB_TOOLS_OUTPUT
86 --enable_query_log