| 1 |
################################################################################ |
| 2 |
# This test verifies that events which does not obey GR requirements: |
| 3 |
# - tables having no primary keys |
| 4 |
# - tables using non-innodb storage engine |
| 5 |
# - tables with foreign key with cascade clause |
| 6 |
# are not allowed to be applied on the server. |
| 7 |
# |
| 8 |
# ==== Usage ==== |
| 9 |
# |
| 10 |
# --let $gr_test_name= NAME |
| 11 |
# [--let $rpl_binlog_format= [ROW|STATEMENT]] |
| 12 |
# [--let $rpl_mysqlbinlog= 1] |
| 13 |
# --source ../extra/gr_binlog_events_verifications.test |
| 14 |
# |
| 15 |
# Parameters: |
| 16 |
# |
| 17 |
# $gr_test_name |
| 18 |
# The current test name getting executed |
| 19 |
# |
| 20 |
# $rpl_binlog_format |
| 21 |
# The binlog format either ROW or STATEMENT. |
| 22 |
# If not set, the default value is set to ROW. |
| 23 |
# |
| 24 |
# $rpl_mysqlbinlog |
| 25 |
# If not set the binlog events are applied through asynchronous |
| 26 |
# replication otherwise through mysqlbinlog. |
| 27 |
# |
| 28 |
# Test: |
| 29 |
# 0. The test requires two servers: M1 and M2. |
| 30 |
# 1. Initialization. |
| 31 |
# 2. Bootstrap start group replication on M1. |
| 32 |
# 3. If $rpl_mysqlbinlog is disabled, |
| 33 |
# create new channel: |
| 34 |
# ch2_1: server1(slave), server2(master). |
| 35 |
# 4. Set binlog format from $rpl_binlog_format on server2. |
| 36 |
# 5. Create a table t1 without PK on server2(master) and add data to it. |
| 37 |
# 6. Verify insert doesn't gets executed as table doesn't have a primary key. |
| 38 |
# 7. Create a table t2 with MYISAM storage engine on |
| 39 |
# server2(master) and add data to it. |
| 40 |
# 8. Verify insert doesn't gets executed as table |
| 41 |
# doesn't have the innodb storage engine. |
| 42 |
# 9. Create a table tc3 with foreign key with delete CASCADE clause |
| 43 |
# on server2(master) and add data to it. |
| 44 |
# 10. Verify insert doesn't gets executed as table |
| 45 |
# has a foreign key with CASCADE clause. |
| 46 |
# 11. Clean-up |
| 47 |
################################################################################ |
| 48 |
|
| 49 |
if (!$gr_test_name) |
| 50 |
{ |
| 51 |
--die ERROR IN TEST: You must set $gr_test_name before sourcing gr_binlog_events_verifications.inc |
| 52 |
} |
| 53 |
|
| 54 |
--source include/have_group_replication_plugin.inc |
| 55 |
--let $rpl_skip_group_replication_start= 1 |
| 56 |
--source include/group_replication.inc |
| 57 |
|
| 58 |
--echo |
| 59 |
--echo # Initialization |
| 60 |
|
| 61 |
--let $rpl_start_binlog_pos= 1 |
| 62 |
--let $rpl_gr_grep_primary_error= 0 |
| 63 |
--let $rpl_gr_grep_innodb_error= 0 |
| 64 |
--let $rpl_gr_grep_foreign_cascade_error= 0 |
| 65 |
|
| 66 |
if ($rpl_mysqlbinlog) |
| 67 |
{ |
| 68 |
--let $rpl_out_binlog= $MYSQLTEST_VARDIR/tmp/$gr_test_name.binlog |
| 69 |
} |
| 70 |
|
| 71 |
--echo |
| 72 |
--echo # Bootstrap start Group Replication on server1 |
| 73 |
|
| 74 |
--let $rpl_connection_name= server1 |
| 75 |
--source include/rpl_connection.inc |
| 76 |
--source include/start_and_bootstrap_group_replication.inc |
| 77 |
|
| 78 |
if (!$rpl_mysqlbinlog) |
| 79 |
{ |
| 80 |
--echo |
| 81 |
--echo # Create new channel ch2_1: server1(slave), server2(master). |
| 82 |
--let $rpl_connection_name= server1 |
| 83 |
--source include/rpl_connection.inc |
| 84 |
|
| 85 |
--replace_result $SERVER_MYPORT_2 SERVER_2_PORT |
| 86 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST="127.0.0.1", SOURCE_USER="root", SOURCE_PASSWORD="", SOURCE_PORT=$SERVER_MYPORT_2, SOURCE_AUTO_POSITION=1 for channel 'ch2_1' |
| 87 |
|
| 88 |
--let $rpl_channel_name='ch2_1' |
| 89 |
--source include/start_slave.inc |
| 90 |
} |
| 91 |
|
| 92 |
--echo |
| 93 |
--echo # Set binlog format on server2. |
| 94 |
|
| 95 |
--let $rpl_connection_name= server2 |
| 96 |
--source include/rpl_connection.inc |
| 97 |
|
| 98 |
if (!$rpl_binlog_format) |
| 99 |
{ |
| 100 |
--let $rpl_binlog_format=ROW |
| 101 |
} |
| 102 |
|
| 103 |
--eval SET SESSION BINLOG_FORMAT= "$rpl_binlog_format" |
| 104 |
|
| 105 |
--echo |
| 106 |
--echo # Create a table t1 without PK on server2(master) |
| 107 |
--echo # and add data to it. |
| 108 |
|
| 109 |
CREATE TABLE t1 (c1 INT); |
| 110 |
--source include/rpl_sync.inc |
| 111 |
|
| 112 |
--let $rpl_curr_gtid= 'aaaaaaaa-aaaa-aaaa-aaaa-bbbbbbbbbbbb:1' |
| 113 |
--eval SET GTID_NEXT= $rpl_curr_gtid |
| 114 |
INSERT INTO t1 VALUES (1); |
| 115 |
SET GTID_NEXT= AUTOMATIC; |
| 116 |
|
| 117 |
--echo |
| 118 |
--echo # Verify insert doesn't gets executed as table |
| 119 |
--echo # doesn't have a primary key. |
| 120 |
|
| 121 |
--let $rpl_slave_connection_name= server1 |
| 122 |
--let $rpl_gr_grep_primary_error= 1 |
| 123 |
--let $rpl_gr_grep_primary_error_message= Table t1 does not have any PRIMARY KEY. This is not compatible with Group Replication |
| 124 |
--source ../include/gr_binlog_events_assert_error.inc |
| 125 |
|
| 126 |
|
| 127 |
--echo |
| 128 |
--echo # Create a table t2 with MYISAM storage engine on |
| 129 |
--echo # server2(master) and add data to it. |
| 130 |
|
| 131 |
--let $rpl_connection_name= server2 |
| 132 |
--source include/rpl_connection.inc |
| 133 |
|
| 134 |
CREATE TABLE t2 (c1 INT) engine MyIsam; |
| 135 |
--source include/rpl_sync.inc |
| 136 |
|
| 137 |
--let $rpl_curr_gtid= 'aaaaaaaa-aaaa-aaaa-aaaa-bbbbbbbbbbbb:2' |
| 138 |
--eval SET GTID_NEXT= $rpl_curr_gtid |
| 139 |
INSERT INTO t2 VALUES (1); |
| 140 |
SET GTID_NEXT= AUTOMATIC; |
| 141 |
|
| 142 |
--echo |
| 143 |
--echo # Verify insert doesn't gets executed as table |
| 144 |
--echo # doesn't have the innodb storage engine. |
| 145 |
|
| 146 |
--let $rpl_slave_connection_name= server1 |
| 147 |
--let $rpl_gr_grep_primary_error= 1 |
| 148 |
--let $rpl_gr_grep_primary_error_message= Table t2 does not have any PRIMARY KEY. This is not compatible with Group Replication |
| 149 |
--let $rpl_gr_grep_innodb_error= 1 |
| 150 |
--let $rpl_gr_grep_innodb_error_message= Table t2 does not use the InnoDB storage engine. This is not compatible with Group Replication |
| 151 |
--source ../include/gr_binlog_events_assert_error.inc |
| 152 |
|
| 153 |
|
| 154 |
--echo |
| 155 |
--echo # Create a table tc3 with foreign key with delete CASCADE clause |
| 156 |
--echo # on server2(master) and add data to it. |
| 157 |
|
| 158 |
--let $rpl_connection_name= server2 |
| 159 |
--source include/rpl_connection.inc |
| 160 |
|
| 161 |
CREATE TABLE tp3 (c1 INT PRIMARY KEY); |
| 162 |
CREATE TABLE tc3 (c1 INT PRIMARY KEY, FOREIGN KEY (c1) REFERENCES tp3(c1) ON DELETE CASCADE); |
| 163 |
INSERT INTO tp3 VALUES(1); |
| 164 |
--source include/rpl_sync.inc |
| 165 |
|
| 166 |
--let $rpl_curr_gtid= 'aaaaaaaa-aaaa-aaaa-aaaa-bbbbbbbbbbbb:3' |
| 167 |
--eval SET GTID_NEXT= $rpl_curr_gtid |
| 168 |
INSERT INTO tc3 VALUES (1); |
| 169 |
SET GTID_NEXT= AUTOMATIC; |
| 170 |
|
| 171 |
--echo |
| 172 |
--echo # Verify insert doesn't gets executed as table |
| 173 |
--echo # has a foreign key with CASCADE clause. |
| 174 |
|
| 175 |
--let $rpl_slave_connection_name= server1 |
| 176 |
--let $rpl_gr_grep_foreign_cascade_error= 1 |
| 177 |
--let $rpl_gr_grep_foreign_cascade_error_message= Table tc3 has a foreign key with 'CASCADE', 'SET NULL' or 'SET DEFAULT' clause. This is not compatible with Group Replication |
| 178 |
--source ../include/gr_binlog_events_assert_error.inc |
| 179 |
|
| 180 |
|
| 181 |
--echo |
| 182 |
--echo # Clean-up |
| 183 |
|
| 184 |
--let $rpl_connection_name= server2 |
| 185 |
--source include/rpl_connection.inc |
| 186 |
|
| 187 |
drop table t1; |
| 188 |
drop table t2; |
| 189 |
drop table tc3; |
| 190 |
drop table tp3; |
| 191 |
|
| 192 |
SET SESSION BINLOG_FORMAT= DEFAULT; |
| 193 |
|
| 194 |
# stop slave channel if present |
| 195 |
if (!$rpl_mysqlbinlog) |
| 196 |
{ |
| 197 |
# Sync slave(server1) with master(server2) |
| 198 |
--let $sync_slave_connection=server_1 |
| 199 |
--source include/sync_slave_sql_with_master.inc |
| 200 |
|
| 201 |
--let $rpl_connection_name= server1 |
| 202 |
--source include/rpl_connection.inc |
| 203 |
|
| 204 |
--let $rpl_channel_name='ch2_1' |
| 205 |
--source include/stop_slave.inc |
| 206 |
|
| 207 |
RESET SLAVE ALL FOR CHANNEL 'ch2_1'; |
| 208 |
|
| 209 |
--let $rpl_channel_name= |
| 210 |
} |
| 211 |
|
| 212 |
# remove binlog file and tables |
| 213 |
if ($rpl_mysqlbinlog) |
| 214 |
{ |
| 215 |
--remove_file $rpl_out_binlog |
| 216 |
|
| 217 |
--let $rpl_connection_name= server1 |
| 218 |
--source include/rpl_connection.inc |
| 219 |
|
| 220 |
drop table t1; |
| 221 |
drop table t2; |
| 222 |
drop table tc3; |
| 223 |
drop table tp3; |
| 224 |
} |
| 225 |
|
| 226 |
--source include/group_replication_end.inc |