Amaury Denoyelle | 79c52ec | 2021-07-15 11:23:17 +0200 | [diff] [blame^] | 1 | varnishtest "Add/Delete server via cli with track support" |
| 2 | |
| 3 | feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev0)'" |
| 4 | feature cmd "$HAPROXY_PROGRAM -cc 'feature(OPENSSL)'" |
| 5 | feature ignore_unknown_macro |
| 6 | |
| 7 | |
| 8 | # just use to provide s1_{addr,port} macros |
| 9 | server s1 { |
| 10 | } |
| 11 | |
| 12 | |
| 13 | # scenario 1 |
| 14 | # -> 3 dynamic servers, delete the first one |
| 15 | syslog S1 { |
| 16 | recv notice |
| 17 | expect ~ "Server be1/s1 is UP/READY" |
| 18 | recv notice |
| 19 | expect ~ "Server be1/s2 is UP/READY" |
| 20 | recv notice |
| 21 | expect ~ "Server be1/s3 is UP/READY" |
| 22 | |
| 23 | recv alert |
| 24 | expect ~ "Server be1/srv is going DOWN for maintenance." |
| 25 | recv alert |
| 26 | expect ~ "Server be1/s3 is going DOWN for maintenance." |
| 27 | recv alert |
| 28 | expect ~ "Server be1/s2 is going DOWN for maintenance." |
| 29 | recv alert |
| 30 | expect ~ "Server be1/s1 is going DOWN for maintenance." |
| 31 | |
| 32 | recv notice |
| 33 | expect ~ "Server be1/srv is UP/READY" |
| 34 | recv notice |
| 35 | expect ~ "Server be1/s3 is UP/READY" |
| 36 | recv notice |
| 37 | expect ~ "Server be1/s2 is UP/READY" |
| 38 | } -start |
| 39 | |
| 40 | # scenario 2 |
| 41 | # -> 3 dynamic servers, delete the middle one |
| 42 | syslog S2 { |
| 43 | recv notice |
| 44 | expect ~ "Server be2/s1 is UP/READY" |
| 45 | recv notice |
| 46 | expect ~ "Server be2/s2 is UP/READY" |
| 47 | recv notice |
| 48 | expect ~ "Server be2/s3 is UP/READY" |
| 49 | |
| 50 | recv alert |
| 51 | expect ~ "Server be2/srv is going DOWN for maintenance." |
| 52 | recv alert |
| 53 | expect ~ "Server be2/s3 is going DOWN for maintenance." |
| 54 | recv alert |
| 55 | expect ~ "Server be2/s2 is going DOWN for maintenance." |
| 56 | recv alert |
| 57 | expect ~ "Server be2/s1 is going DOWN for maintenance." |
| 58 | |
| 59 | recv notice |
| 60 | expect ~ "Server be2/srv is UP/READY" |
| 61 | recv notice |
| 62 | expect ~ "Server be2/s3 is UP/READY" |
| 63 | recv notice |
| 64 | expect ~ "Server be2/s1 is UP/READY" |
| 65 | } -start |
| 66 | |
| 67 | # scenario 3 |
| 68 | # -> 3 dynamic servers, delete all of them |
| 69 | syslog S3 { |
| 70 | recv notice |
| 71 | expect ~ "Server be3/s1 is UP/READY" |
| 72 | recv notice |
| 73 | expect ~ "Server be3/s2 is UP/READY" |
| 74 | recv notice |
| 75 | expect ~ "Server be3/s3 is UP/READY" |
| 76 | |
| 77 | recv alert |
| 78 | expect ~ "Server be3/s1 is going DOWN for maintenance." |
| 79 | recv alert |
| 80 | expect ~ "Server be3/s3 is going DOWN for maintenance." |
| 81 | recv alert |
| 82 | expect ~ "Server be3/s2 is going DOWN for maintenance." |
| 83 | |
| 84 | recv alert |
| 85 | expect ~ "Server be3/srv is going DOWN for maintenance." |
| 86 | |
| 87 | recv notice |
| 88 | expect ~ "Server be3/srv is UP/READY" |
| 89 | } -start |
| 90 | |
| 91 | |
| 92 | haproxy h1 -conf { |
| 93 | global |
| 94 | stats socket "${tmpdir}/h1/stats" level admin |
| 95 | |
| 96 | backend be_check |
| 97 | server srv_check ${s1_addr}:${s1_port} check |
| 98 | server srv_no_check ${s1_addr}:${s1_port} |
| 99 | |
| 100 | backend be1 |
| 101 | log ${S1_addr}:${S1_port} daemon |
| 102 | server srv ${s1_addr}:${s1_port} check |
| 103 | |
| 104 | backend be2 |
| 105 | log ${S2_addr}:${S2_port} daemon |
| 106 | server srv ${s1_addr}:${s1_port} check |
| 107 | |
| 108 | backend be3 |
| 109 | log ${S3_addr}:${S3_port} daemon |
| 110 | server srv ${s1_addr}:${s1_port} check |
| 111 | } -start |
| 112 | |
| 113 | |
| 114 | ### |
| 115 | # check the support of the 'track' keyword on 'add server' CLI command. |
| 116 | # rejection must happen if track on a non-checked or a dynamic server |
| 117 | ### |
| 118 | haproxy h1 -cli { |
| 119 | # invalid command: track on a non-checked server |
| 120 | send "experimental-mode on; add server be_check/s1 ${s1_addr}:${s1_port} track be_check/srv_no_check" |
| 121 | expect ~ "unable to use be_check/srv_no_check for tracking as it does not have any check nor agent enabled." |
| 122 | |
| 123 | # valid track usage |
| 124 | send "experimental-mode on; add server be_check/s1 ${s1_addr}:${s1_port} track be_check/srv_check" |
| 125 | expect ~ "New server registered." |
| 126 | |
| 127 | # invalid command: track on a dynamic server |
| 128 | send "experimental-mode on; add server be_check/s3 ${s1_addr}:${s1_port} track be_check/s1" |
| 129 | expect ~ "unable to use be_check/s1 for tracking as it is a dynamic server." |
| 130 | } |
| 131 | |
| 132 | ### |
| 133 | # scenario 1 |
| 134 | # |
| 135 | # Add 3 dynamic servers with tracking on be1/srv |
| 136 | # Disable be1/srv, S1 should report all servers DOWN |
| 137 | # Delete the first dynamic server, enable be1/srv, S1 should report s1 and s3 UP |
| 138 | #### |
| 139 | haproxy h1 -cli { |
| 140 | send "experimental-mode on; add server be1/s1 ${s1_addr}:${s1_port} track be1/srv" |
| 141 | expect ~ "New server registered." |
| 142 | send "enable server be1/s1" |
| 143 | expect ~ ".*" |
| 144 | |
| 145 | send "experimental-mode on; add server be1/s2 ${s1_addr}:${s1_port} track be1/srv" |
| 146 | expect ~ "New server registered." |
| 147 | send "enable server be1/s2" |
| 148 | expect ~ ".*" |
| 149 | |
| 150 | send "experimental-mode on; add server be1/s3 ${s1_addr}:${s1_port} track be1/srv" |
| 151 | expect ~ "New server registered." |
| 152 | send "enable server be1/s3" |
| 153 | expect ~ ".*" |
| 154 | |
| 155 | send "disable server be1/srv" |
| 156 | expect ~ ".*" |
| 157 | |
| 158 | send "experimental-mode on; del server be1/s1" |
| 159 | expect ~ "Server deleted." |
| 160 | |
| 161 | send "enable server be1/srv" |
| 162 | expect ~ ".*" |
| 163 | } |
| 164 | |
| 165 | ### |
| 166 | # scenario 2 |
| 167 | # |
| 168 | # Add 3 dynamic servers with tracking on be2/srv |
| 169 | # Disable be2/srv, S3 should report all servers DOWN |
| 170 | # Delete the second dynamic server, enable be2/srv, S2 should report s2 and s3 UP |
| 171 | #### |
| 172 | haproxy h1 -cli { |
| 173 | send "experimental-mode on; add server be2/s1 ${s1_addr}:${s1_port} track be2/srv" |
| 174 | expect ~ "New server registered." |
| 175 | send "enable server be2/s1" |
| 176 | expect ~ ".*" |
| 177 | |
| 178 | send "experimental-mode on; add server be2/s2 ${s1_addr}:${s1_port} track be2/srv" |
| 179 | expect ~ "New server registered." |
| 180 | send "enable server be2/s2" |
| 181 | expect ~ ".*" |
| 182 | |
| 183 | send "experimental-mode on; add server be2/s3 ${s1_addr}:${s1_port} track be2/srv" |
| 184 | expect ~ "New server registered." |
| 185 | send "enable server be2/s3" |
| 186 | expect ~ ".*" |
| 187 | |
| 188 | send "disable server be2/srv" |
| 189 | expect ~ ".*" |
| 190 | |
| 191 | send "experimental-mode on; del server be2/s2" |
| 192 | expect ~ "Server deleted." |
| 193 | |
| 194 | send "enable server be2/srv" |
| 195 | expect ~ ".*" |
| 196 | } |
| 197 | |
| 198 | ### |
| 199 | # scenario 3 |
| 200 | # |
| 201 | # Add 3 dynamic servers with tracking on be3/srv |
| 202 | # Delete all of them, disable/enable be3/srv, only be3/srv should be reported |
| 203 | # as DOWN/UP. |
| 204 | #### |
| 205 | haproxy h1 -cli { |
| 206 | # create server 1, track on be3/srv |
| 207 | send "experimental-mode on; add server be3/s1 ${s1_addr}:${s1_port} track be3/srv" |
| 208 | expect ~ "New server registered." |
| 209 | send "enable server be3/s1" |
| 210 | expect ~ ".*" |
| 211 | |
| 212 | # create server 2, track on be3/srv |
| 213 | send "experimental-mode on; add server be3/s2 ${s1_addr}:${s1_port} track be3/srv" |
| 214 | expect ~ "New server registered." |
| 215 | send "enable server be3/s2" |
| 216 | expect ~ ".*" |
| 217 | |
| 218 | # create server 3, track on be3/srv |
| 219 | send "experimental-mode on; add server be3/s3 ${s1_addr}:${s1_port} track be3/srv" |
| 220 | expect ~ "New server registered." |
| 221 | send "enable server be3/s3" |
| 222 | expect ~ ".*" |
| 223 | |
| 224 | # delete all dynamic servers |
| 225 | send "experimental-mode on; disable server be3/s1; del server be3/s1" |
| 226 | expect ~ "Server deleted." |
| 227 | send "experimental-mode on; disable server be3/s3; del server be3/s3" |
| 228 | expect ~ "Server deleted." |
| 229 | send "experimental-mode on; disable server be3/s2; del server be3/s2" |
| 230 | expect ~ "Server deleted." |
| 231 | |
| 232 | # disable / enable the static server |
| 233 | send "disable server be3/srv" |
| 234 | expect ~ ".*" |
| 235 | send "enable server be3/srv" |
| 236 | expect ~ ".*" |
| 237 | } |
| 238 | |
| 239 | |
| 240 | syslog S1 -wait |
| 241 | syslog S2 -wait |
| 242 | syslog S3 -wait |