| 1 |
################################################################################ |
| 2 |
# The intent of this test is to verify if the validations that were |
| 3 |
# created within the Group Replication plugin in the runtime process |
| 4 |
# are fully functional. |
| 5 |
# |
| 6 |
# It will test the invalid scenarios for table creation. |
| 7 |
# |
| 8 |
# Table with only unique key. |
| 9 |
# Table with NULL key. |
| 10 |
# Table with Unique NULL key. |
| 11 |
# Table with a normal key. (Not unique) |
| 12 |
# |
| 13 |
# It will cycle all cases in which the runtime validation is verified. |
| 14 |
# |
| 15 |
# Afterwards the plugin will be stopped and one of the cases will be tested in |
| 16 |
# order to assess that the verification is no longer accomplished. |
| 17 |
# |
| 18 |
# Test: |
| 19 |
# 0. The test requires two servers: M1 and M2. |
| 20 |
# 1. Setup group of two members. Bring both the members ONLINE. |
| 21 |
# 2. On M1: |
| 22 |
# - Create table t1 with only unique key. |
| 23 |
# - Create table t2 with possible NULL value for the key. |
| 24 |
# - Create table t3 with unique NULL key. |
| 25 |
# - Sync it to the group. |
| 26 |
# 3. Testing all the three tables that will fail with following DML operations: |
| 27 |
# - Test the INSERT instruction. It must fail. |
| 28 |
# - Test the UPDATE instruction. It must fail. |
| 29 |
# - Test the DELETE instruction. It must fail. |
| 30 |
# - Sync data to the group. |
| 31 |
# 4. Stop GR on M1. Stop GR on M2. |
| 32 |
# 5. Testing all the three tables again with following DML operations on M1: |
| 33 |
# - Test the INSERT instruction. It must succeed. |
| 34 |
# - Test the UPDATE instruction. It must succeed. |
| 35 |
# - Test the DELETE instruction. It must succeed. |
| 36 |
# 6. Clean up. |
| 37 |
################################################################################ |
| 38 |
--source include/have_group_replication_plugin.inc |
| 39 |
--source include/group_replication.inc |
| 40 |
|
| 41 |
SET SESSION sql_log_bin=0; |
| 42 |
call mtr.add_suppression("Table.*does not have any PRIMARY KEY. This is not compatible with Group Replication."); |
| 43 |
SET SESSION sql_log_bin=1; |
| 44 |
|
| 45 |
--connection server1 |
| 46 |
#Lets create several tables. They will all breach 1 or more rules |
| 47 |
|
| 48 |
#Wrong table with only unique Key |
| 49 |
CREATE TABLE t1 (c1 INT UNIQUE KEY) ENGINE=InnoDB; |
| 50 |
|
| 51 |
#Wrong table with possible NULL value for the key. |
| 52 |
CREATE TABLE t2 (c1 INT, KEY `c1` (`c1`)) ENGINE=InnoDB; |
| 53 |
|
| 54 |
#Wrong table with unique key with null value. |
| 55 |
CREATE TABLE t3 (c1 INT UNIQUE NULL) ENGINE=InnoDB; |
| 56 |
|
| 57 |
--source include/rpl_sync.inc |
| 58 |
|
| 59 |
# |
| 60 |
# The tests begin here. |
| 61 |
# |
| 62 |
--echo # |
| 63 |
--echo # Testing all tables that will fail. |
| 64 |
--echo # |
| 65 |
|
| 66 |
--let $wrong_tables_count=3 |
| 67 |
while ($wrong_tables_count) |
| 68 |
{ |
| 69 |
#Test the INSERT instruction |
| 70 |
--error ER_BEFORE_DML_VALIDATION_ERROR |
| 71 |
--eval INSERT INTO t$wrong_tables_count VALUES(1) |
| 72 |
|
| 73 |
#Test the UPDATE instruction |
| 74 |
--error ER_BEFORE_DML_VALIDATION_ERROR |
| 75 |
--eval UPDATE t$wrong_tables_count SET c1 = 2 |
| 76 |
|
| 77 |
#Test the DELETE instruction |
| 78 |
--error ER_BEFORE_DML_VALIDATION_ERROR |
| 79 |
--eval DELETE FROM t$wrong_tables_count |
| 80 |
|
| 81 |
--dec $wrong_tables_count |
| 82 |
} |
| 83 |
|
| 84 |
#This will sync data among all group members |
| 85 |
--source include/rpl_sync.inc |
| 86 |
|
| 87 |
--echo # Now, lets repeat all the tests with group replication stopped. |
| 88 |
--source include/stop_group_replication.inc |
| 89 |
--connection server2 |
| 90 |
--source include/stop_group_replication.inc |
| 91 |
|
| 92 |
--connection server1 |
| 93 |
|
| 94 |
--let $wrong_tables_count=3 |
| 95 |
while ($wrong_tables_count) |
| 96 |
{ |
| 97 |
#Test the INSERT instruction |
| 98 |
--eval INSERT INTO t$wrong_tables_count VALUES(1) |
| 99 |
|
| 100 |
#Test the UPDATE instruction |
| 101 |
--eval UPDATE t$wrong_tables_count SET c1 = 2 |
| 102 |
|
| 103 |
#Test the DELETE instruction |
| 104 |
--eval DELETE FROM t$wrong_tables_count |
| 105 |
|
| 106 |
#clean up this table |
| 107 |
--eval DROP TABLE t$wrong_tables_count |
| 108 |
|
| 109 |
--dec $wrong_tables_count |
| 110 |
} |
| 111 |
|
| 112 |
--connection server2 |
| 113 |
--let $table_count= 3 |
| 114 |
while ($table_count) |
| 115 |
{ |
| 116 |
--eval DROP TABLE t$table_count |
| 117 |
--dec $table_count |
| 118 |
} |
| 119 |
--source include/group_replication_end.inc |