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