Debian Codegraph @

mysql-test/suite/group_replication/t/gr_provisioning_logical_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. Verify if the available backup (binlog file) can be later restored successfully on a non-member
7 # 3. Verify if that non-member can then be added to the GR group
8 # 4. Perform some DDL/DML operations to the group
9 # 5. Check mysqlbinlog output to test View Change Log events are written properly.
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 two 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 USE test;
37 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
38 INSERT INTO t1 VALUES (0);
39 INSERT INTO t1 VALUES (1);
40 UPDATE t1 SET c1=2 WHERE c1=0;
41
42 # Get the binlog file
43 --let $server2_datadir= `SELECT @@DATADIR`
44 --let $server2_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
45
46 # Restore the backup onto a 3rd server outside the GR group
47 --echo
48 --let $rpl_connection_name= server3
49 --source include/rpl_connection.inc
50 # Setting the arguments to connect to server3#
51 --let $server3_connection_args= --user=root --host=127.0.0.1 --port=$SERVER_MYPORT_3
52 # Restoring the backup file on server3 using mysqlbinlog client and the connection arguments set above
53 --exec $MYSQL_BINLOG $server2_datadir/$server2_binlog_file | $MYSQL $server3_connection_args
54
55 # See if the data has been properly restored on server3
56 --let $assert_text= 'There is a value 1 in table t1'
57 --let $assert_cond= [SELECT COUNT(*) AS count FROM test.t1 WHERE t1.c1 = 1, count, 1] = 1
58 --source include/assert.inc
59 --let $assert_text= 'There is a value 2 in table t1'
60 --let $assert_cond= [SELECT COUNT(*) AS count FROM test.t1 WHERE t1.c1 = 2, count, 1] = 1
61 --source include/assert.inc
62
63 # Add server3 to GR group
64 --source include/start_group_replication.inc
65
66 # Make sure number of servers in the group is 3
67 --let $group_replication_number_of_members= 3
68 --source include/gr_wait_for_number_of_members.inc
69
70 # Create a table and insert data into it.
71 USE test;
72 CREATE TABLE t2 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
73 INSERT INTO t2 VALUES (0);
74 INSERT INTO t2 VALUES (1);
75 UPDATE t2 SET c1=2 WHERE c1=0;
76 --source include/rpl_sync.inc
77
78 # See if data has been successfully replicated across the group
79 --echo
80 --let $rpl_connection_name= server1
81 --source include/rpl_connection.inc
82 --let $assert_text= 'Checking the number of records in test.t2'
83 --let $assert_cond= [SELECT COUNT(*) as count FROM test.t2,count, 1] = 2
84 --source include/assert.inc
85
86 --echo
87 --let $rpl_connection_name= server2
88 --source include/rpl_connection.inc
89 --let $assert_text= 'Checking the number of records in test.t2'
90 --let $assert_cond= [SELECT COUNT(*) as count FROM test.t2,count, 1] = 2
91 --source include/assert.inc
92
93 # Get the binlog file
94 --let $server2_datadir= `SELECT @@DATADIR`
95 --let $server2_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
96 # Record the binlog file
97 --exec $MYSQL_BINLOG $server2_datadir/$server2_binlog_file > $MYSQL_TMP_DIR/binlog_output
98
99 # Verifying the output of mysqlbinlog for VCLE
100 --let $grep_pattern= View_change_log_event
101 --let $grep_file= $MYSQL_TMP_DIR/binlog_output
102 --let $grep_output= print_count
103 --source include/grep_pattern.inc
104
105 # Drop table
106 DROP TABLE test.t1;
107 DROP TABLE test.t2;
108 --remove_file $MYSQL_TMP_DIR/binlog_output
109
110 --source include/group_replication_end.inc