| 1 |
################################################################################ |
| 2 |
# WL#9052 - GCS compression options |
| 3 |
# |
| 4 |
# This test case checks compression options for group replication |
| 5 |
# |
| 6 |
# Test: |
| 7 |
# 0. The test requires two servers: M1 and M2. |
| 8 |
# 1. When GROUP is OFFLINE. Set variable group_replication_compression_threshold |
| 9 |
# to 0 i.e. disabled. |
| 10 |
# 2. Check it asserts that: |
| 11 |
# - The variable does not take invalid inputs. |
| 12 |
# - The variable does not take over the max inputs. |
| 13 |
# - The variable does not take negative inputs. |
| 14 |
# - The variable can be set to valid value. |
| 15 |
# - The default value is 0. |
| 16 |
# 3. Set variable to valid value. Bootstrap M1 and start M2 to make them ONLINE. |
| 17 |
# 4. Assert that on running member variable cannot be changed. |
| 18 |
# 5. Then the test checks if two servers with and without compression enabled |
| 19 |
# are able to exchange messages and still comunicate with each other. |
| 20 |
################################################################################ |
| 21 |
|
| 22 |
--source include/have_group_replication_plugin.inc |
| 23 |
--let $rpl_skip_group_replication_start= 1 |
| 24 |
--source include/group_replication.inc |
| 25 |
|
| 26 |
--let $saved_threshold= `SELECT @@group_replication_compression_threshold` |
| 27 |
--let $sound_threshold= 512 |
| 28 |
--let $double_sound_threshold= `SELECT $sound_threshold * 2` |
| 29 |
--let $half_sound_threshold= `SELECT $sound_threshold / 2` |
| 30 |
--let $default_threshold= 1000000 |
| 31 |
--let $incorrect_threshold= "AAAA" |
| 32 |
--let $overflow_threshold= 4294967297 |
| 33 |
--let $negative_threshold= -1 |
| 34 |
|
| 35 |
## |
| 36 |
## Set group_replication_compression_threshold to 0 initially on both |
| 37 |
## servers |
| 38 |
## |
| 39 |
# make sure that compression is disabled |
| 40 |
--let $rpl_connection_name= server2 |
| 41 |
--source include/rpl_connection.inc |
| 42 |
|
| 43 |
SET GLOBAL group_replication_compression_threshold= 0; |
| 44 |
|
| 45 |
--let $rpl_connection_name= server1 |
| 46 |
--source include/rpl_connection.inc |
| 47 |
|
| 48 |
SET GLOBAL group_replication_compression_threshold= 0; |
| 49 |
|
| 50 |
## |
| 51 |
## Perform tests |
| 52 |
## |
| 53 |
|
| 54 |
--let $rpl_connection_name= server1 |
| 55 |
--source include/rpl_connection.inc |
| 56 |
|
| 57 |
# |
| 58 |
# Assert that the wrong input results in an error |
| 59 |
# |
| 60 |
--error ER_WRONG_TYPE_FOR_VAR |
| 61 |
--eval SET GLOBAL group_replication_compression_threshold=$incorrect_threshold |
| 62 |
|
| 63 |
# |
| 64 |
# Assert that a wrong value - over the max - for the variable results in an error |
| 65 |
# |
| 66 |
--error ER_WRONG_VALUE_FOR_VAR |
| 67 |
--eval SET GLOBAL group_replication_compression_threshold=$overflow_threshold |
| 68 |
|
| 69 |
# |
| 70 |
# Assert that a wrong value - lower than the minimum results in an error |
| 71 |
# |
| 72 |
--error ER_WRONG_VALUE_FOR_VAR |
| 73 |
--eval SET GLOBAL group_replication_compression_threshold=$negative_threshold |
| 74 |
|
| 75 |
# |
| 76 |
# Assert that we can set compression to a sound value |
| 77 |
# |
| 78 |
--eval SET GLOBAL group_replication_compression_threshold=$sound_threshold |
| 79 |
|
| 80 |
# |
| 81 |
# Assert that the threshold was actually changed |
| 82 |
# |
| 83 |
--let $threshold= `SELECT @@group_replication_compression_threshold` |
| 84 |
--let $assert_cond= $threshold = $sound_threshold |
| 85 |
--let $assert_text= Assert that the compression_threshold is set to the default |
| 86 |
--source include/assert.inc |
| 87 |
|
| 88 |
# |
| 89 |
# We are not allowed to use DEFAULT as a value. |
| 90 |
# |
| 91 |
--error ER_WRONG_VALUE_FOR_VAR |
| 92 |
SET GLOBAL group_replication_compression_threshold=DEFAULT; |
| 93 |
|
| 94 |
## |
| 95 |
## Now lets test with the system running |
| 96 |
## |
| 97 |
--eval SET GLOBAL group_replication_compression_threshold=$sound_threshold |
| 98 |
|
| 99 |
## Start GR on server1 |
| 100 |
--source include/start_and_bootstrap_group_replication.inc |
| 101 |
|
| 102 |
## Start GR on server2 |
| 103 |
--let $rpl_connection_name= server2 |
| 104 |
--source include/rpl_connection.inc |
| 105 |
--source include/start_group_replication.inc |
| 106 |
|
| 107 |
## Go back to server1 |
| 108 |
--let $rpl_connection_name= server1 |
| 109 |
--source include/rpl_connection.inc |
| 110 |
|
| 111 |
# |
| 112 |
# Assert that we cannot change the variable while group replication |
| 113 |
# is running |
| 114 |
# |
| 115 |
--error ER_GROUP_REPLICATION_RUNNING |
| 116 |
--eval SET GLOBAL group_replication_compression_threshold=$double_sound_threshold |
| 117 |
|
| 118 |
# |
| 119 |
# Assert that despite the error the value remains unchanged |
| 120 |
# |
| 121 |
--let $threshold= `SELECT @@group_replication_compression_threshold` |
| 122 |
--let $assert_cond= $threshold = $sound_threshold |
| 123 |
--let $assert_text= Assert that the compression_threshold remains unchanged |
| 124 |
--source include/assert.inc |
| 125 |
|
| 126 |
## |
| 127 |
## Now lets verify that the data goes across, both when it |
| 128 |
## is compressed and not compressed |
| 129 |
## |
| 130 |
|
| 131 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY, c2 LONGBLOB) ENGINE=InnoDB; |
| 132 |
|
| 133 |
## This will trigger on the wire compression since we are generating |
| 134 |
## a row insert larger than the compression threshold |
| 135 |
--eval INSERT INTO t1 VALUES(1, REPEAT('A', $double_sound_threshold)) |
| 136 |
|
| 137 |
## This will not be compressed on the wire |
| 138 |
--eval INSERT INTO t1 VALUES(2, REPEAT('B', $half_sound_threshold)) |
| 139 |
|
| 140 |
--let $rpl_connection_name= server2 |
| 141 |
--source include/rpl_connection.inc |
| 142 |
|
| 143 |
--source include/rpl_sync.inc |
| 144 |
|
| 145 |
# |
| 146 |
# Assert that compression is disabled on server2 |
| 147 |
# given that we had set threshold to 0 earlier in the test |
| 148 |
# |
| 149 |
--let $threshold= `SELECT @@group_replication_compression_threshold` |
| 150 |
--let $assert_cond= $threshold = 0 |
| 151 |
--let $assert_text= Assert that the compression_threshold is disabled |
| 152 |
--source include/assert.inc |
| 153 |
|
| 154 |
# Server2 has no compression enabled, so lets see if it |
| 155 |
# is able to speak with server1 which has compression on |
| 156 |
--eval INSERT INTO t1 VALUES(3, REPEAT('C', $double_sound_threshold)) |
| 157 |
|
| 158 |
--source include/rpl_sync.inc |
| 159 |
|
| 160 |
# |
| 161 |
# Assert that the data made it through |
| 162 |
# |
| 163 |
--let $diff_tables= server1:test.t1,server2:test.t1 |
| 164 |
--source include/diff_tables.inc |
| 165 |
|
| 166 |
# |
| 167 |
# One last assert - entries in the error log are correct |
| 168 |
# |
| 169 |
|
| 170 |
# |
| 171 |
# Assert that GR on server1 was started with compression enabled |
| 172 |
# It was only started once |
| 173 |
# |
| 174 |
--let $assert_file=$MYSQLTEST_VARDIR/tmp/group_replication_compression_options_mysqld.1.err |
| 175 |
--let $assert_text= LZ4 compression was active and logged to the error log |
| 176 |
--let $assert_select=.*group_replication_compression_threshold: 512.* |
| 177 |
--let $assert_count= 1 |
| 178 |
--source include/assert_grep.inc |
| 179 |
|
| 180 |
# |
| 181 |
# Assert that GR on server1 was never started with compression disabled |
| 182 |
# |
| 183 |
--let $assert_file=$MYSQLTEST_VARDIR/tmp/group_replication_compression_options_mysqld.1.err |
| 184 |
--let $assert_text= LZ4 compression was disabled and logged to the error log |
| 185 |
--let $assert_select=.*group_replication_compression_threshold: 0.* |
| 186 |
--let $assert_count= 0 |
| 187 |
--source include/assert_grep.inc |
| 188 |
|
| 189 |
# |
| 190 |
# Assert that GR on server2 was never started with compression enabled |
| 191 |
# It was started twice, btw |
| 192 |
# |
| 193 |
--let $assert_file=$MYSQLTEST_VARDIR/tmp/group_replication_compression_options_mysqld.2.err |
| 194 |
--let $assert_text= LZ4 compression was disabled always |
| 195 |
--let $assert_select=.*group_replication_compression_threshold: 0.* |
| 196 |
--let $assert_count= 1 |
| 197 |
--source include/assert_grep.inc |
| 198 |
|
| 199 |
## |
| 200 |
## Clean up |
| 201 |
## |
| 202 |
|
| 203 |
DROP TABLE t1; |
| 204 |
|
| 205 |
--source include/rpl_sync.inc |
| 206 |
|
| 207 |
--let $rpl_connection_name= server1 |
| 208 |
--source include/rpl_connection.inc |
| 209 |
|
| 210 |
--source include/stop_group_replication.inc |
| 211 |
--replace_result $saved_threshold SAVED_THRESHOLD |
| 212 |
--eval SET GLOBAL group_replication_compression_threshold= $saved_threshold |
| 213 |
--source include/start_group_replication.inc |
| 214 |
|
| 215 |
--let $rpl_connection_name= server2 |
| 216 |
--source include/rpl_connection.inc |
| 217 |
|
| 218 |
--source include/stop_group_replication.inc |
| 219 |
--replace_result $saved_threshold SAVED_THRESHOLD |
| 220 |
--eval SET GLOBAL group_replication_compression_threshold= $saved_threshold |
| 221 |
--source include/start_group_replication.inc |
| 222 |
|
| 223 |
## This is the end... My only friend the end! |
| 224 |
--source include/group_replication_end.inc |