| 1 |
################################################################################ |
| 2 |
# WL#6833: GCS Replication: Read-set free Certification |
| 3 |
# Module (DBSM Snapshot Isolation) |
| 4 |
# |
| 5 |
# Scenario 2: Replicate from a server into a group |
| 6 |
# |
| 7 |
# Verify Group Replication behavior when we establish a |
| 8 |
# asynchronous replication connection from a server to a group. |
| 9 |
# |
| 10 |
# Test: |
| 11 |
# 0. The test requires three servers: M1, M2 and M3. |
| 12 |
# 1. Bootstrap start a group on M1. Start GR on M2. |
| 13 |
# 2. Setup a asynchronous replication connection from M3 into group(M1) |
| 14 |
# i.e. M3 -> M1. |
| 15 |
# 3. Execute some transactions on M3. |
| 16 |
# 4. Wait until transactions executed on M3 are applied on group. |
| 17 |
# 5. Execute a transaction on the group(M1). |
| 18 |
# 6. Validate data on M3. |
| 19 |
# 8. Validate data on M1. GTID_EXECUTED on M1 must have GTID_EXECUTED from M3. |
| 20 |
# 9. Validate data on M2. GTID_EXECUTED on M2 must have GTID_EXECUTED from M3. |
| 21 |
# 10. Clean data. |
| 22 |
# 11. Stop asynchronous replication connection from M3 into group(M1). |
| 23 |
# 12. Stop Group Replication on M1 and M2. |
| 24 |
################################################################################ |
| 25 |
|
| 26 |
--let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9420000 |
| 27 |
--source include/have_group_replication_plugin.inc |
| 28 |
--let $rpl_skip_group_replication_start= 1 |
| 29 |
--let $rpl_server_count= 3 |
| 30 |
--source include/group_replication.inc |
| 31 |
|
| 32 |
|
| 33 |
--echo |
| 34 |
--echo ############################################################ |
| 35 |
--echo # 1. Setup Group Replication on server 1 and 2. |
| 36 |
--connection server1 |
| 37 |
--source include/start_and_bootstrap_group_replication.inc |
| 38 |
|
| 39 |
--connection server2 |
| 40 |
--source include/start_group_replication.inc |
| 41 |
|
| 42 |
--let $group_replication_number_of_members= 2 |
| 43 |
--source include/gr_wait_for_number_of_members.inc |
| 44 |
|
| 45 |
|
| 46 |
--echo |
| 47 |
--echo ############################################################ |
| 48 |
--echo # 2. Setup a asynchronous replication connection from server 3 |
| 49 |
--echo # into group (server 1) |
| 50 |
--connection server1 |
| 51 |
--replace_result $SERVER_MYPORT_3 SERVER_3_PORT |
| 52 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST="127.0.0.1", SOURCE_USER="root", SOURCE_PASSWORD="", SOURCE_PORT=$SERVER_MYPORT_3, SOURCE_AUTO_POSITION=1 |
| 53 |
--source include/start_slave.inc |
| 54 |
|
| 55 |
|
| 56 |
--echo |
| 57 |
--echo ############################################################ |
| 58 |
--echo # 3. Execute some transactions on server 3. |
| 59 |
--connection server3 |
| 60 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 61 |
INSERT INTO t1 VALUES (0); |
| 62 |
INSERT INTO t1 VALUES (1); |
| 63 |
UPDATE t1 SET c1=2 WHERE c1=0; |
| 64 |
|
| 65 |
SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1'; |
| 66 |
BEGIN; |
| 67 |
COMMIT; |
| 68 |
SET GTID_NEXT= 'AUTOMATIC'; |
| 69 |
|
| 70 |
|
| 71 |
--echo |
| 72 |
--echo ############################################################ |
| 73 |
--echo # 4. Wait until transactions executed on server 3 are applied |
| 74 |
--echo # on group. |
| 75 |
--connection server3 |
| 76 |
--let $sync_slave_connection= server1 |
| 77 |
--source include/sync_slave_sql_with_master.inc |
| 78 |
--connection server3 |
| 79 |
--let $sync_slave_connection= server2 |
| 80 |
--source include/sync_slave_sql_with_master.inc |
| 81 |
|
| 82 |
|
| 83 |
--echo |
| 84 |
--echo ############################################################ |
| 85 |
--echo # 5. Execute a transaction on the group. |
| 86 |
--connection server1 |
| 87 |
INSERT INTO t1 VALUES (6); |
| 88 |
--source include/rpl_sync.inc |
| 89 |
|
| 90 |
|
| 91 |
--echo |
| 92 |
--echo ############################################################ |
| 93 |
--echo # 6. Validate data on server 3. |
| 94 |
--connection server3 |
| 95 |
--let $server3_gtid_executed= `SELECT @@GLOBAL.GTID_EXECUTED` |
| 96 |
|
| 97 |
--let $assert_text= 'There is a value 1 in table t1' |
| 98 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1 |
| 99 |
--source include/assert.inc |
| 100 |
--let $assert_text= 'There is a value 2 in table t1' |
| 101 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 1 |
| 102 |
--source include/assert.inc |
| 103 |
--let $assert_text= 'There is no value 6 in table t1' |
| 104 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 6, count, 1] = 0 |
| 105 |
--source include/assert.inc |
| 106 |
|
| 107 |
|
| 108 |
--echo |
| 109 |
--echo ############################################################ |
| 110 |
--echo # 7. GTID_EXECUTED on server 1 must contain GTID_EXECUTED |
| 111 |
--echo # from server 3. |
| 112 |
--echo # Validate data on server 1. |
| 113 |
--connection server1 |
| 114 |
--let $assert_text= GTID_EXECUTED must contain server 3 GTID_EXECUTED |
| 115 |
--let $assert_cond= [SELECT GTID_SUBSET("$server3_gtid_executed", @@GLOBAL.GTID_EXECUTED)] = 1 |
| 116 |
--source include/assert.inc |
| 117 |
|
| 118 |
--let $assert_text= 'There is a value 1 in table t1' |
| 119 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1 |
| 120 |
--source include/assert.inc |
| 121 |
--let $assert_text= 'There is a value 2 in table t1' |
| 122 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 1 |
| 123 |
--source include/assert.inc |
| 124 |
--let $assert_text= 'There is a value 6 in table t1' |
| 125 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 6, count, 1] = 1 |
| 126 |
--source include/assert.inc |
| 127 |
|
| 128 |
|
| 129 |
--echo |
| 130 |
--echo ############################################################ |
| 131 |
--echo # 8. GTID_EXECUTED on server 2 must contain GTID_EXECUTED |
| 132 |
--echo # from server 3. |
| 133 |
--echo # Validate data on server 2. |
| 134 |
--connection server2 |
| 135 |
--let $assert_text= GTID_EXECUTED must contain server 3 GTID_EXECUTED |
| 136 |
--let $assert_cond= [SELECT GTID_SUBSET("$server3_gtid_executed", @@GLOBAL.GTID_EXECUTED)] = 1 |
| 137 |
--source include/assert.inc |
| 138 |
|
| 139 |
--let $assert_text= 'There is a value 1 in table t1' |
| 140 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1 |
| 141 |
--source include/assert.inc |
| 142 |
--let $assert_text= 'There is a value 2 in table t1' |
| 143 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 1 |
| 144 |
--source include/assert.inc |
| 145 |
--let $assert_text= 'There is a value 6 in table t1' |
| 146 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 6, count, 1] = 1 |
| 147 |
--source include/assert.inc |
| 148 |
|
| 149 |
--echo |
| 150 |
--echo ############################################################ |
| 151 |
--echo # 9. Clean data. |
| 152 |
--connection server3 |
| 153 |
DROP TABLE t1; |
| 154 |
|
| 155 |
--let $sync_slave_connection= server1 |
| 156 |
--source include/sync_slave_sql_with_master.inc |
| 157 |
--connection server3 |
| 158 |
--let $sync_slave_connection= server2 |
| 159 |
--source include/sync_slave_sql_with_master.inc |
| 160 |
|
| 161 |
|
| 162 |
--echo |
| 163 |
--echo ############################################################ |
| 164 |
--echo # 10. Stop asynchronous replication connection from server 3 |
| 165 |
--echo # into group (server 1) |
| 166 |
--connection server1 |
| 167 |
--source include/stop_slave.inc |
| 168 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION=0 FOR CHANNEL ""; |
| 169 |
|
| 170 |
--echo |
| 171 |
--echo ############################################################ |
| 172 |
--echo # 11. Stop Group Replication on server 1 and 2. |
| 173 |
--connection server1 |
| 174 |
--source include/stop_group_replication.inc |
| 175 |
|
| 176 |
--connection server2 |
| 177 |
--source include/stop_group_replication.inc |
| 178 |
|
| 179 |
--source include/group_replication_end.inc |