Debian Codegraph @

mysql-test/suite/ndb_rpl/t/ndb_rpl_sync.test

raw
1 --source include/have_ndb.inc
2 --source include/have_binlog_format_mixed_or_row.inc
3 --source suite/ndb_rpl/ndb_master-slave.inc
4 --source suite/ndb/include/backup_restore_setup.inc
5
6 #
7 # Currently test only works with ndb since it retrieves "old"
8 # binlog positions with mysql.ndb_binlog_index and ndb_apply_status;
9 #
10
11 # stop the save
12 --connection slave
13 STOP SLAVE;
14 CREATE DATABASE ndbsynctest;
15 USE ndbsynctest;
16
17 # get some data on the master
18 --connection master
19 CREATE DATABASE ndbsynctest;
20 USE ndbsynctest;
21 CREATE TABLE t1 (c1 BIT(1) NOT NULL, c2 BIT(1) NOT NULL, c3 CHAR(15), PRIMARY KEY(c3)) ENGINE = NDB ;
22 INSERT INTO t1 VALUES (1,1,"row1"),(0,1,"row2"),(1,0,"row3"),(0,0,"row4");
23 CREATE TABLE t2 (c1 CHAR(15), c2 BIT(1) NOT NULL, c3 BIT(1) NOT NULL, PRIMARY KEY(c1)) ENGINE = NDB ;
24 INSERT INTO t2 VALUES ("ABC",1,1),("BCDEF",0,1),("CD",1,0),("DEFGHIJKL",0,0);
25 SELECT hex(c1),hex(c2),c3 FROM t1 ORDER BY c3;
26 SELECT hex(c2),hex(c3),c1 FROM t2 ORDER BY c1;
27
28 # take a backup on master
29 --source include/ndb_backup.inc
30
31 # update a row
32 UPDATE t1 SET c2=0 WHERE c3="row2";
33 SELECT hex(c1),hex(c2),c3 FROM t1 ORDER BY c3;
34
35 # restore on slave, first check that nothing is there
36 --connection slave
37
38 # we should have no tables
39 SHOW TABLES;
40
41 --exec $NDB_RESTORE --ndb-connectstring="$NDB_CONNECTSTRING_SLAVE" -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
42 --exec $NDB_RESTORE --ndb-connectstring="$NDB_CONNECTSTRING_SLAVE" -b $the_backup_id -n 2 -r -e --print --print_meta $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
43
44 #
45 # BUG#11960
46 # prior to bugfix "DROP DATABASE" would give a warning since
47 # the events were not created by ndb_restore
48 #
49 DROP DATABASE ndbsynctest;
50 CREATE DATABASE ndbsynctest;
51 USE ndbsynctest;
52 --exec $NDB_RESTORE --ndb-connectstring="$NDB_CONNECTSTRING_SLAVE" -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
53 --exec $NDB_RESTORE --ndb-connectstring="$NDB_CONNECTSTRING_SLAVE" -b $the_backup_id -n 2 -r -e --print --print_meta $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
54
55 SELECT hex(c1),hex(c2),c3 FROM t1 ORDER BY c3;
56 SELECT hex(c2),hex(c3),c1 FROM t2 ORDER BY c1;
57
58 #
59 # now setup replication to continue from last epoch
60 --source suite/ndb_rpl/ndb_setup_slave.inc
61 --connection slave
62 START SLAVE;
63
64 #
65 #
66 #
67 --connection master
68 --sync_slave_with_master
69 --source include/check_slave_is_running.inc
70
71 SELECT hex(c1),hex(c2),c3 FROM t1 ORDER BY c3;
72 SELECT hex(c2),hex(c3),c1 FROM t2 ORDER BY c1;
73
74 #
75 # Cleanup
76 #
77
78 --connection master
79 DROP DATABASE ndbsynctest;
80 --sync_slave_with_master
81 STOP SLAVE;
82
83 #
84 # Test some replication commands
85 #
86 --connection master
87 reset master;
88 # should now contain nothing
89 select * from mysql.ndb_binlog_index;
90
91 --connection slave
92 reset slave;
93 # should now contain nothing
94 select * from mysql.ndb_apply_status;
95
96 # End 5.1 Test
97 --let $rpl_only_running_threads= 1
98 --source include/rpl_end.inc
99 --source suite/ndb/include/backup_restore_cleanup.inc
100 --remove_file $NDB_TOOLS_OUTPUT