| 1 |
# WL#9345 - GCS IP Allowlisting option |
| 2 |
|
| 3 |
#### |
| 4 |
#### This test case checks ip allowlisting options for group |
| 5 |
#### replication. |
| 6 |
#### |
| 7 |
#### First it does negative testing by providing faulty input |
| 8 |
#### to the plugin: |
| 9 |
#### - incorrectly formatted values: -2, NULL |
| 10 |
#### - incorrect IPs: 192.256.1.20, 300.168.1.20 |
| 11 |
#### - incorrect hostname: random_hostname/16 |
| 12 |
#### - incorrect subnetmasks: 192.168.1.0/33, 192.168.266.0/24 |
| 13 |
#### - incorrect lists: 8.9.10.0/20,192.168.1.1,192.168.2.0/44 |
| 14 |
#### - try to change while the plugin is running |
| 15 |
#### |
| 16 |
#### Then it does positive testing: |
| 17 |
#### - correct IPs: 192.168.1.1, 8.9.10.0/20 |
| 18 |
#### - correct subnetmasks: 192.168.1.0/24 |
| 19 |
#### - correct hostname: @@hostname/16 |
| 20 |
#### - correct lists: 8.9.10.0/20,192.168.1.1,192.168.2.0/24 |
| 21 |
#### - empty values, DEFAULT |
| 22 |
#### - assert that the values were logged in the error log |
| 23 |
#### for successful settings |
| 24 |
#### |
| 25 |
#### Check that access from localhost is always allowed, even |
| 26 |
#### if setting the list to "" . |
| 27 |
#### |
| 28 |
#### Additional testing is done on the unit tests for the |
| 29 |
#### Gcs_ip_allowlist object, together with the |
| 30 |
#### Gcs_xcom_interface testing. |
| 31 |
#### |
| 32 |
|
| 33 |
--source include/big_test.inc |
| 34 |
--let $group_replication_group_name= 00000000-1111-2222-3333-444444444444 |
| 35 |
--source include/have_group_replication_plugin.inc |
| 36 |
--let $rpl_skip_group_replication_start= 1 |
| 37 |
--source include/group_replication.inc |
| 38 |
|
| 39 |
--let $incorrect_input1= NULL |
| 40 |
--let $incorrect_ip1= 192.256.1.20 |
| 41 |
--let $incorrect_ip2= 300.168.1.20 |
| 42 |
--let $incorrect_list1= 8.9.10.0/20,192.168.1.1,192.168.2.0/44 |
| 43 |
--let $incorrect_list2= 8.9.10.0/20,192.168.1.1,AUTOMATIC |
| 44 |
--let $incorrect_subnetmask1= 192.168.1.0/33 |
| 45 |
--let $incorrect_subnetmask2= 192.168.266.0/24 |
| 46 |
--let $correct_ip1= 192.168.1.1 |
| 47 |
--let $correct_ip2= 192.168.1.0/24 |
| 48 |
--let $correct_ip3= 8.9.10.0/20 |
| 49 |
--let $correct_hostname= `SELECT CONCAT((SELECT @@hostname), '/16')` |
| 50 |
--let $correct_list1= fe80::f6dd:5a39:661b:b00b/64,8.9.10.0/20,192.168.1.1,192.168.2.0/24 |
| 51 |
|
| 52 |
--let $rpl_connection_name= server1 |
| 53 |
--source include/rpl_connection.inc |
| 54 |
--eval SET GLOBAL group_replication_group_name="$group_replication_group_name" |
| 55 |
|
| 56 |
#### |
| 57 |
#### Negative testing |
| 58 |
#### |
| 59 |
|
| 60 |
# |
| 61 |
# Assert that the wrong inputs will result in errors when |
| 62 |
# trying to start the plugin |
| 63 |
# |
| 64 |
|
| 65 |
--error ER_WRONG_VALUE_FOR_VAR |
| 66 |
--eval SET GLOBAL group_replication_ip_allowlist=$incorrect_input1 |
| 67 |
|
| 68 |
#START GROUP_REPLICATION; |
| 69 |
|
| 70 |
--eval SET GLOBAL group_replication_ip_allowlist="$incorrect_ip1" |
| 71 |
--error ER_GROUP_REPLICATION_COMMUNICATION_LAYER_SESSION_ERROR |
| 72 |
START GROUP_REPLICATION; |
| 73 |
|
| 74 |
--eval SET GLOBAL group_replication_ip_allowlist="$incorrect_ip2" |
| 75 |
--error ER_GROUP_REPLICATION_COMMUNICATION_LAYER_SESSION_ERROR |
| 76 |
START GROUP_REPLICATION; |
| 77 |
|
| 78 |
--eval SET GLOBAL group_replication_ip_allowlist="$incorrect_subnetmask1" |
| 79 |
--error ER_GROUP_REPLICATION_COMMUNICATION_LAYER_SESSION_ERROR |
| 80 |
START GROUP_REPLICATION; |
| 81 |
|
| 82 |
--eval SET GLOBAL group_replication_ip_allowlist="$incorrect_subnetmask2" |
| 83 |
--error ER_GROUP_REPLICATION_COMMUNICATION_LAYER_SESSION_ERROR |
| 84 |
START GROUP_REPLICATION; |
| 85 |
|
| 86 |
--eval SET GLOBAL group_replication_ip_allowlist="$incorrect_list1" |
| 87 |
--error ER_GROUP_REPLICATION_COMMUNICATION_LAYER_SESSION_ERROR |
| 88 |
START GROUP_REPLICATION; |
| 89 |
|
| 90 |
--error ER_GROUP_REPLICATION_CONFIGURATION |
| 91 |
--eval SET GLOBAL group_replication_ip_allowlist="$incorrect_list2" |
| 92 |
|
| 93 |
#### |
| 94 |
#### Positive testing |
| 95 |
#### |
| 96 |
|
| 97 |
# |
| 98 |
# Assert that the server successfully starts GR with correct_ip1 |
| 99 |
# in the allowlist |
| 100 |
# |
| 101 |
--eval SET GLOBAL group_replication_ip_allowlist="$correct_ip1" |
| 102 |
--source include/start_and_bootstrap_group_replication.inc |
| 103 |
|
| 104 |
--let $current= `SELECT @@group_replication_ip_allowlist` |
| 105 |
--let $assert_cond= "$current" = "$correct_ip1" |
| 106 |
--let $assert_text= Assert value changed to $correct_ip1 |
| 107 |
--source include/assert.inc |
| 108 |
|
| 109 |
--source include/stop_group_replication.inc |
| 110 |
|
| 111 |
# |
| 112 |
# Assert that the server logs the correct value |
| 113 |
# |
| 114 |
--let $assert_file=$MYSQLTEST_VARDIR/tmp/group_replication_ip_allowlist_options_mysqld.1.err |
| 115 |
--let $assert_text= ip_allowlist was successfully logged to the error log |
| 116 |
--let $assert_select=.*group_replication_ip_allowlist: '$correct_ip1'.* |
| 117 |
--let $assert_count= 1 |
| 118 |
--source include/assert_grep.inc |
| 119 |
|
| 120 |
# |
| 121 |
# Assert that the server successfully starts GR with correct_ip2 |
| 122 |
# in the allowlist |
| 123 |
# |
| 124 |
|
| 125 |
--eval SET GLOBAL group_replication_ip_allowlist="$correct_ip2" |
| 126 |
--source include/start_and_bootstrap_group_replication.inc |
| 127 |
|
| 128 |
--let $current= `SELECT @@group_replication_ip_allowlist` |
| 129 |
--let $assert_cond= "$current" = "$correct_ip2" |
| 130 |
--let $assert_text= Assert value changed to $correct_ip2 |
| 131 |
--source include/assert.inc |
| 132 |
|
| 133 |
--source include/stop_group_replication.inc |
| 134 |
|
| 135 |
# |
| 136 |
# Assert that the server logs the correct value |
| 137 |
# |
| 138 |
--let $assert_file=$MYSQLTEST_VARDIR/tmp/group_replication_ip_allowlist_options_mysqld.1.err |
| 139 |
--let $assert_text= ip_allowlist was successfully logged to the error log |
| 140 |
--let $assert_select=.*group_replication_ip_allowlist: '$correct_ip2'.* |
| 141 |
--let $assert_count= 1 |
| 142 |
--source include/assert_grep.inc |
| 143 |
|
| 144 |
# |
| 145 |
# Assert that the server successfully starts GR with correct_ip3 |
| 146 |
# in the allowlist |
| 147 |
# |
| 148 |
|
| 149 |
--eval SET GLOBAL group_replication_ip_allowlist="$correct_ip3" |
| 150 |
--source include/start_and_bootstrap_group_replication.inc |
| 151 |
|
| 152 |
--let $current= `SELECT @@group_replication_ip_allowlist` |
| 153 |
--let $assert_cond= "$current" = "$correct_ip3" |
| 154 |
--let $assert_text= Assert value changed to $correct_ip3 |
| 155 |
--source include/assert.inc |
| 156 |
|
| 157 |
--source include/stop_group_replication.inc |
| 158 |
|
| 159 |
# |
| 160 |
# Assert that the server logs the correct value |
| 161 |
# |
| 162 |
--let $assert_file=$MYSQLTEST_VARDIR/tmp/group_replication_ip_allowlist_options_mysqld.1.err |
| 163 |
--let $assert_text= ip_allowlist was successfully logged to the error log |
| 164 |
--let $assert_select=.*group_replication_ip_allowlist: '$correct_ip3'.* |
| 165 |
--let $assert_count= 1 |
| 166 |
--source include/assert_grep.inc |
| 167 |
|
| 168 |
# |
| 169 |
# Assert that the server successfully starts GR with correct_ip3 |
| 170 |
# in the allowlist |
| 171 |
# |
| 172 |
|
| 173 |
--eval SET GLOBAL group_replication_ip_allowlist="$correct_list1" |
| 174 |
--source include/start_and_bootstrap_group_replication.inc |
| 175 |
|
| 176 |
--let $current= `SELECT @@group_replication_ip_allowlist` |
| 177 |
--let $assert_cond= "$current" = "$correct_list1" |
| 178 |
--let $assert_text= Assert value changed to $correct_list1 |
| 179 |
--source include/assert.inc |
| 180 |
|
| 181 |
--source include/stop_group_replication.inc |
| 182 |
|
| 183 |
# |
| 184 |
# Assert that the server logs the correct value |
| 185 |
# |
| 186 |
--let $assert_file=$MYSQLTEST_VARDIR/tmp/group_replication_ip_allowlist_options_mysqld.1.err |
| 187 |
--let $assert_text= ip_allowlist was successfully logged to the error log |
| 188 |
--let $assert_select=.*group_replication_ip_allowlist: '$correct_list1'.* |
| 189 |
--let $assert_count= 1 |
| 190 |
--source include/assert_grep.inc |
| 191 |
|
| 192 |
# |
| 193 |
# Assert that the server successfully starts GR with correct_hostname |
| 194 |
# in the allowlist |
| 195 |
# Since MTR does not have name resolution, we are going in a best effort |
| 196 |
# aproach in which we test that the server started and stopped without errors |
| 197 |
# |
| 198 |
|
| 199 |
--replace_result $correct_hostname CORRECT_HOSTNAME |
| 200 |
--eval SET GLOBAL group_replication_ip_allowlist="$correct_hostname" |
| 201 |
--source include/start_and_bootstrap_group_replication.inc |
| 202 |
|
| 203 |
--let $current= `SELECT @@group_replication_ip_allowlist` |
| 204 |
--let $assert_cond= [SELECT @@group_replication_ip_allowlist = ""] = 0 |
| 205 |
--let $assert_text= Assert value with hostname is not empty |
| 206 |
--source include/assert.inc |
| 207 |
|
| 208 |
--source include/stop_group_replication.inc |
| 209 |
|
| 210 |
# |
| 211 |
# Assert that the server successfully starts GR with "" |
| 212 |
# set to the allowlist |
| 213 |
# |
| 214 |
--eval SET GLOBAL group_replication_ip_allowlist="" |
| 215 |
--source include/start_and_bootstrap_group_replication.inc |
| 216 |
|
| 217 |
--let $current= `SELECT @@group_replication_ip_allowlist` |
| 218 |
--let $assert_cond= [SELECT @@group_replication_ip_allowlist = ""] = 1 |
| 219 |
--let $assert_text= Assert value changed to "" |
| 220 |
--source include/assert.inc |
| 221 |
|
| 222 |
--source include/stop_group_replication.inc |
| 223 |
|
| 224 |
# |
| 225 |
# Assert that the server logs the correct value |
| 226 |
# |
| 227 |
--let $assert_file=$MYSQLTEST_VARDIR/tmp/group_replication_ip_allowlist_options_mysqld.1.err |
| 228 |
--let $assert_text= ip_allowlist was successfully logged to the error log |
| 229 |
--let $assert_select=.*group_replication_ip_allowlist: '';.* |
| 230 |
--let $assert_count= 1 |
| 231 |
--source include/assert_grep.inc |
| 232 |
|
| 233 |
# |
| 234 |
# Assert that the server successfully starts GR with DEFAULT |
| 235 |
# set to the allowlist |
| 236 |
# |
| 237 |
--error ER_WRONG_VALUE_FOR_VAR |
| 238 |
--eval SET GLOBAL group_replication_ip_allowlist=DEFAULT |
| 239 |
|
| 240 |
--eval SET GLOBAL group_replication_ip_allowlist=AUTOMATIC |
| 241 |
--source include/start_and_bootstrap_group_replication.inc |
| 242 |
|
| 243 |
--let $current= `SELECT @@group_replication_ip_allowlist` |
| 244 |
--let $assert_cond= [SELECT "$current" = "AUTOMATIC"] = 1 |
| 245 |
--let $assert_text= Assert value changed to "AUTOMATIC" |
| 246 |
--source include/assert.inc |
| 247 |
|
| 248 |
# assert that we can set the ip_allowlist while GR is running |
| 249 |
--eval SET GLOBAL group_replication_ip_allowlist="$correct_ip1" |
| 250 |
--let $current= `SELECT @@group_replication_ip_allowlist` |
| 251 |
--let $assert_cond= "$current" = "$correct_ip1" |
| 252 |
--let $assert_text= Assert value changed to "$correct_ip1" |
| 253 |
--source include/assert.inc |
| 254 |
|
| 255 |
# Validate the invalid values are detected, |
| 256 |
--error ER_GROUP_REPLICATION_CONFIGURATION |
| 257 |
--eval SET GLOBAL group_replication_ip_allowlist="$incorrect_ip1" |
| 258 |
--let $assert_cond= "$current" = "$correct_ip1" |
| 259 |
--let $assert_text= Assert value has not changed to "$incorrect_ip1" |
| 260 |
--source include/assert.inc |
| 261 |
|
| 262 |
--source include/stop_group_replication.inc |
| 263 |
|
| 264 |
# |
| 265 |
# Assert that the server successfully starts GR with "" |
| 266 |
# and that the other server in localhost can connect. |
| 267 |
# |
| 268 |
# Access from localhost is always allowlisted |
| 269 |
# |
| 270 |
--let $rpl_connection_name= server1 |
| 271 |
--source include/rpl_connection.inc |
| 272 |
|
| 273 |
--eval SET GLOBAL group_replication_ip_allowlist="" |
| 274 |
--source include/start_and_bootstrap_group_replication.inc |
| 275 |
|
| 276 |
--let $rpl_connection_name= server2 |
| 277 |
--source include/rpl_connection.inc |
| 278 |
|
| 279 |
# if localhost was blocked this would not succeed |
| 280 |
--source include/start_group_replication.inc |
| 281 |
|
| 282 |
# execute some load |
| 283 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 284 |
INSERT INTO t1 VALUES (1); |
| 285 |
|
| 286 |
--let $rpl_connection_name= server1 |
| 287 |
--source include/rpl_connection.inc |
| 288 |
--source include/rpl_sync.inc |
| 289 |
|
| 290 |
# Assert that the data made it through |
| 291 |
--let $diff_tables= server1:test.t1,server2:test.t1 |
| 292 |
--source include/diff_tables.inc |
| 293 |
|
| 294 |
## |
| 295 |
## Clean up |
| 296 |
## |
| 297 |
|
| 298 |
DROP TABLE t1; |
| 299 |
--source include/rpl_sync.inc |
| 300 |
|
| 301 |
--let $rpl_connection_name= server1 |
| 302 |
--source include/rpl_connection.inc |
| 303 |
|
| 304 |
--source include/stop_group_replication.inc |
| 305 |
--eval SET GLOBAL group_replication_ip_allowlist= AUTOMATIC |
| 306 |
--source include/start_group_replication.inc |
| 307 |
|
| 308 |
--let $rpl_connection_name= server2 |
| 309 |
--source include/rpl_connection.inc |
| 310 |
|
| 311 |
--source include/stop_group_replication.inc |
| 312 |
--eval SET GLOBAL group_replication_ip_allowlist= AUTOMATIC |
| 313 |
--source include/start_group_replication.inc |
| 314 |
|
| 315 |
## This is the end... My only friend the end! |
| 316 |
--source include/group_replication_end.inc |