Debian Codegraph @

mysql-test/suite/group_replication/t/gr_provisioning_mysqldump_backup.test

raw
1 #################################################################################################
2 # Create a backup from a member of GR group , which at later point can be restored successfully.
3 #
4 # 0. Start GR on with 2 servers
5 # 1. Perform some DDL/DML operations on a member
6 # 2. Create a backup from the member using mysqldump
7 # 3. Verify if that backup can be later restored successfully on a 3rd server
8 # 4. See if that 3rd server can then be added to GR group
9 # 5. Perform some DDL/DML operations on the group
10 # 6. Cleanup
11 #################################################################################################
12
13 --source include/big_test.inc
14 --source include/have_group_replication_plugin.inc
15 --let $rpl_skip_group_replication_start= 1
16 --let $rpl_server_count= 3
17 --source include/group_replication.inc
18
19 # Start group replication on thwo servers
20
21 --echo
22 --let $rpl_connection_name= server1
23 --source include/rpl_connection.inc
24 --source include/start_and_bootstrap_group_replication.inc
25
26 --echo
27 --let $rpl_connection_name= server2
28 --source include/rpl_connection.inc
29 --source include/start_group_replication.inc
30
31 # Make sure number of servers in the group is 2
32 --let $group_replication_number_of_members= 2
33 --source include/gr_wait_for_number_of_members.inc
34
35 # Create a table and insert data into it.
36 CREATE DATABASE db;
37 USE db;
38 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
39 INSERT INTO t1 VALUES (0);
40 INSERT INTO t1 VALUES (1);
41 UPDATE t1 SET c1=2 WHERE c1=0;
42
43 # Create a backup using mysqldump
44 --let $server2_datadir= `SELECT @@DATADIR`
45 --let $server2_backup_file= backup_server2.sql
46 # Use mysqldump client to get a dump of server2
47 # --single-transaction uses savepoints
48 --exec $MYSQL_DUMP --user=root --host=127.0.0.1 --single-transaction --port=$SLAVE_MYPORT --databases db > $server2_datadir/$server2_backup_file
49
50 # Restore the backup onto a 3rd server outside the GR group
51 --echo
52 --let $rpl_connection_name= server3
53 --source include/rpl_connection.inc
54 --exec $MYSQL --user=root --host=127.0.0.1 --port=$SERVER_MYPORT_3 < $server2_datadir/$server2_backup_file
55
56 # See if the data has been properly restored on server3
57 --echo
58 --let $assert_text= 'There is a value 1 in table t1'
59 --let $assert_cond= [SELECT COUNT(*) AS count FROM db.t1 WHERE t1.c1 = 1, count, 1] = 1
60 --source include/assert.inc
61 --let $assert_text= 'There is a value 2 in table t1'
62 --let $assert_cond= [SELECT COUNT(*) AS count FROM db.t1 WHERE t1.c1 = 2, count, 1] = 1
63 --source include/assert.inc
64
65 # Add server3 to GR group
66 --echo
67 --source include/start_group_replication.inc
68
69 # Make sure number of servers in the group is now 3
70 --echo
71 --let $wait_timeout= 100
72 let $wait_condition=SELECT COUNT(*)=3 FROM performance_schema.replication_group_members where MEMBER_STATE="ONLINE";
73 --source include/wait_condition.inc
74
75 # Now perform DDL/DML operations
76 --echo
77 # Create a table and insert data into it.
78 USE db;
79 CREATE TABLE t2 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
80 INSERT INTO t2 VALUES (0);
81 INSERT INTO t2 VALUES (1);
82 UPDATE t2 SET c1=2 WHERE c1=0;
83 --source include/rpl_sync.inc
84
85 # See if data has been successfully replicated across the group
86 --echo
87 --let $rpl_connection_name= server1
88 --source include/rpl_connection.inc
89 --let $assert_text= 'Checking the number of records in db.t2'
90 --let $assert_cond= [SELECT COUNT(*) as count FROM db.t2,count, 1] = 2
91 --source include/assert.inc
92
93 --echo
94 --let $rpl_connection_name= server2
95 --source include/rpl_connection.inc
96 --let $assert_text= 'Checking the number of records in db.t2'
97 --let $assert_cond= [SELECT COUNT(*) as count FROM db.t2,count, 1] = 2
98 --source include/assert.inc
99
100 # Drop table
101 --echo
102 DROP DATABASE db;
103
104 --remove_file $server2_datadir/$server2_backup_file
105 --source include/group_replication_end.inc