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 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
|
# WL#9345 - GCS IP Allowlisting option
####
#### This test case checks ip allowlisting options for group
#### replication.
####
#### First it does negative testing by providing faulty input
#### to the plugin:
#### - incorrectly formatted values: -2, NULL
#### - incorrect IPs: 192.256.1.20, 300.168.1.20
#### - incorrect hostname: random_hostname/16
#### - incorrect subnetmasks: 192.168.1.0/33, 192.168.266.0/24
#### - incorrect lists: 8.9.10.0/20,192.168.1.1,192.168.2.0/44
#### - try to change while the plugin is running
####
#### Then it does positive testing:
#### - correct IPs: 192.168.1.1, 8.9.10.0/20
#### - correct subnetmasks: 192.168.1.0/24
#### - correct hostname: @@hostname/16
#### - correct lists: 8.9.10.0/20,192.168.1.1,192.168.2.0/24
#### - empty values, DEFAULT
#### - assert that the values were logged in the error log
#### for successful settings
####
#### Check that access from localhost is always allowed, even
#### if setting the list to "" .
####
#### Additional testing is done on the unit tests for the
#### Gcs_ip_allowlist object, together with the
#### Gcs_xcom_interface testing.
####
--source include/big_test.inc
--let $group_replication_group_name= 00000000-1111-2222-3333-444444444444
--source include/have_group_replication_plugin.inc
--let $rpl_skip_group_replication_start= 1
--source include/group_replication.inc
--let $incorrect_input1= NULL
--let $incorrect_ip1= 192.256.1.20
--let $incorrect_ip2= 300.168.1.20
--let $incorrect_list1= 8.9.10.0/20,192.168.1.1,192.168.2.0/44
--let $incorrect_list2= 8.9.10.0/20,192.168.1.1,AUTOMATIC
--let $incorrect_subnetmask1= 192.168.1.0/33
--let $incorrect_subnetmask2= 192.168.266.0/24
--let $correct_ip1= 192.168.1.1
--let $correct_ip2= 192.168.1.0/24
--let $correct_ip3= 8.9.10.0/20
--let $correct_hostname= `SELECT CONCAT((SELECT @@hostname), '/16')`
--let $correct_list1= fe80::f6dd:5a39:661b:b00b/64,8.9.10.0/20,192.168.1.1,192.168.2.0/24
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--eval SET GLOBAL group_replication_group_name="$group_replication_group_name"
####
#### Negative testing
####
#
# Assert that the wrong inputs will result in errors when
# trying to start the plugin
#
--error ER_WRONG_VALUE_FOR_VAR
--eval SET GLOBAL group_replication_ip_allowlist=$incorrect_input1
#START GROUP_REPLICATION;
--eval SET GLOBAL group_replication_ip_allowlist="$incorrect_ip1"
--error ER_GROUP_REPLICATION_COMMUNICATION_LAYER_SESSION_ERROR
START GROUP_REPLICATION;
--eval SET GLOBAL group_replication_ip_allowlist="$incorrect_ip2"
--error ER_GROUP_REPLICATION_COMMUNICATION_LAYER_SESSION_ERROR
START GROUP_REPLICATION;
--eval SET GLOBAL group_replication_ip_allowlist="$incorrect_subnetmask1"
--error ER_GROUP_REPLICATION_COMMUNICATION_LAYER_SESSION_ERROR
START GROUP_REPLICATION;
--eval SET GLOBAL group_replication_ip_allowlist="$incorrect_subnetmask2"
--error ER_GROUP_REPLICATION_COMMUNICATION_LAYER_SESSION_ERROR
START GROUP_REPLICATION;
--eval SET GLOBAL group_replication_ip_allowlist="$incorrect_list1"
--error ER_GROUP_REPLICATION_COMMUNICATION_LAYER_SESSION_ERROR
START GROUP_REPLICATION;
--error ER_GROUP_REPLICATION_CONFIGURATION
--eval SET GLOBAL group_replication_ip_allowlist="$incorrect_list2"
####
#### Positive testing
####
#
# Assert that the server successfully starts GR with correct_ip1
# in the allowlist
#
--eval SET GLOBAL group_replication_ip_allowlist="$correct_ip1"
--source include/start_and_bootstrap_group_replication.inc
--let $current= `SELECT @@group_replication_ip_allowlist`
--let $assert_cond= "$current" = "$correct_ip1"
--let $assert_text= Assert value changed to $correct_ip1
--source include/assert.inc
--source include/stop_group_replication.inc
#
# Assert that the server logs the correct value
#
--let $assert_file=$MYSQLTEST_VARDIR/tmp/group_replication_ip_allowlist_options_mysqld.1.err
--let $assert_text= ip_allowlist was successfully logged to the error log
--let $assert_select=.*group_replication_ip_allowlist: '$correct_ip1'.*
--let $assert_count= 1
--source include/assert_grep.inc
#
# Assert that the server successfully starts GR with correct_ip2
# in the allowlist
#
--eval SET GLOBAL group_replication_ip_allowlist="$correct_ip2"
--source include/start_and_bootstrap_group_replication.inc
--let $current= `SELECT @@group_replication_ip_allowlist`
--let $assert_cond= "$current" = "$correct_ip2"
--let $assert_text= Assert value changed to $correct_ip2
--source include/assert.inc
--source include/stop_group_replication.inc
#
# Assert that the server logs the correct value
#
--let $assert_file=$MYSQLTEST_VARDIR/tmp/group_replication_ip_allowlist_options_mysqld.1.err
--let $assert_text= ip_allowlist was successfully logged to the error log
--let $assert_select=.*group_replication_ip_allowlist: '$correct_ip2'.*
--let $assert_count= 1
--source include/assert_grep.inc
#
# Assert that the server successfully starts GR with correct_ip3
# in the allowlist
#
--eval SET GLOBAL group_replication_ip_allowlist="$correct_ip3"
--source include/start_and_bootstrap_group_replication.inc
--let $current= `SELECT @@group_replication_ip_allowlist`
--let $assert_cond= "$current" = "$correct_ip3"
--let $assert_text= Assert value changed to $correct_ip3
--source include/assert.inc
--source include/stop_group_replication.inc
#
# Assert that the server logs the correct value
#
--let $assert_file=$MYSQLTEST_VARDIR/tmp/group_replication_ip_allowlist_options_mysqld.1.err
--let $assert_text= ip_allowlist was successfully logged to the error log
--let $assert_select=.*group_replication_ip_allowlist: '$correct_ip3'.*
--let $assert_count= 1
--source include/assert_grep.inc
#
# Assert that the server successfully starts GR with correct_ip3
# in the allowlist
#
--eval SET GLOBAL group_replication_ip_allowlist="$correct_list1"
--source include/start_and_bootstrap_group_replication.inc
--let $current= `SELECT @@group_replication_ip_allowlist`
--let $assert_cond= "$current" = "$correct_list1"
--let $assert_text= Assert value changed to $correct_list1
--source include/assert.inc
--source include/stop_group_replication.inc
#
# Assert that the server logs the correct value
#
--let $assert_file=$MYSQLTEST_VARDIR/tmp/group_replication_ip_allowlist_options_mysqld.1.err
--let $assert_text= ip_allowlist was successfully logged to the error log
--let $assert_select=.*group_replication_ip_allowlist: '$correct_list1'.*
--let $assert_count= 1
--source include/assert_grep.inc
#
# Assert that the server successfully starts GR with correct_hostname
# in the allowlist
# Since MTR does not have name resolution, we are going in a best effort
# aproach in which we test that the server started and stopped without errors
#
--replace_result $correct_hostname CORRECT_HOSTNAME
--eval SET GLOBAL group_replication_ip_allowlist="$correct_hostname"
--source include/start_and_bootstrap_group_replication.inc
--let $current= `SELECT @@group_replication_ip_allowlist`
--let $assert_cond= [SELECT @@group_replication_ip_allowlist = ""] = 0
--let $assert_text= Assert value with hostname is not empty
--source include/assert.inc
--source include/stop_group_replication.inc
#
# Assert that the server successfully starts GR with ""
# set to the allowlist
#
--eval SET GLOBAL group_replication_ip_allowlist=""
--source include/start_and_bootstrap_group_replication.inc
--let $current= `SELECT @@group_replication_ip_allowlist`
--let $assert_cond= [SELECT @@group_replication_ip_allowlist = ""] = 1
--let $assert_text= Assert value changed to ""
--source include/assert.inc
--source include/stop_group_replication.inc
#
# Assert that the server logs the correct value
#
--let $assert_file=$MYSQLTEST_VARDIR/tmp/group_replication_ip_allowlist_options_mysqld.1.err
--let $assert_text= ip_allowlist was successfully logged to the error log
--let $assert_select=.*group_replication_ip_allowlist: '';.*
--let $assert_count= 1
--source include/assert_grep.inc
#
# Assert that the server successfully starts GR with DEFAULT
# set to the allowlist
#
--error ER_WRONG_VALUE_FOR_VAR
--eval SET GLOBAL group_replication_ip_allowlist=DEFAULT
--eval SET GLOBAL group_replication_ip_allowlist=AUTOMATIC
--source include/start_and_bootstrap_group_replication.inc
--let $current= `SELECT @@group_replication_ip_allowlist`
--let $assert_cond= [SELECT "$current" = "AUTOMATIC"] = 1
--let $assert_text= Assert value changed to "AUTOMATIC"
--source include/assert.inc
# assert that we can set the ip_allowlist while GR is running
--eval SET GLOBAL group_replication_ip_allowlist="$correct_ip1"
--let $current= `SELECT @@group_replication_ip_allowlist`
--let $assert_cond= "$current" = "$correct_ip1"
--let $assert_text= Assert value changed to "$correct_ip1"
--source include/assert.inc
# Validate the invalid values are detected,
--error ER_GROUP_REPLICATION_CONFIGURATION
--eval SET GLOBAL group_replication_ip_allowlist="$incorrect_ip1"
--let $assert_cond= "$current" = "$correct_ip1"
--let $assert_text= Assert value has not changed to "$incorrect_ip1"
--source include/assert.inc
--source include/stop_group_replication.inc
#
# Assert that the server successfully starts GR with ""
# and that the other server in localhost can connect.
#
# Access from localhost is always allowlisted
#
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--eval SET GLOBAL group_replication_ip_allowlist=""
--source include/start_and_bootstrap_group_replication.inc
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
# if localhost was blocked this would not succeed
--source include/start_group_replication.inc
# execute some load
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source include/rpl_sync.inc
# Assert that the data made it through
--let $diff_tables= server1:test.t1,server2:test.t1
--source include/diff_tables.inc
##
## Clean up
##
DROP TABLE t1;
--source include/rpl_sync.inc
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source include/stop_group_replication.inc
--eval SET GLOBAL group_replication_ip_allowlist= AUTOMATIC
--source include/start_group_replication.inc
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--source include/stop_group_replication.inc
--eval SET GLOBAL group_replication_ip_allowlist= AUTOMATIC
--source include/start_group_replication.inc
## This is the end... My only friend the end!
--source include/group_replication_end.inc
|