Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 1 | varnishtest "Health-check test" |
| 2 | feature ignore_unknown_macro |
| 3 | |
| 4 | #REQUIRE_VERSION=1.8 |
Frédéric Lécaille | 15685c7 | 2018-12-20 09:55:45 +0100 | [diff] [blame] | 5 | #EXCLUDE_TARGETS=freebsd |
Frédéric Lécaille | dc1a3bd | 2019-03-29 15:07:24 +0100 | [diff] [blame] | 6 | #REGTEST_TYPE=slow |
Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 7 | |
| 8 | # This script test health-checks for four backends with one server by backend. |
| 9 | # A syslog server is attached to each backend to check the syslog messages |
| 10 | # in the righ order. |
| 11 | |
| 12 | # First, we check a health-check has passed for all the servers thanks to the syslog |
| 13 | # messages. Then each server is disabled. The health-check status are checked. |
| 14 | # Then each server is re-enabled. Finally health-check status |
| 15 | # verifications for each server terminate the execution of this script. |
| 16 | |
| 17 | # Note that the CLI is synchronized with the syslog servers so that |
| 18 | # to be sure to receive the passed health-checks status messages before |
| 19 | # disabling the servers. Same thing, when we check that the servers are down |
| 20 | # before enabling the servers. |
| 21 | |
| 22 | # Cyclic barrier to synchonize the CLI with the syslog servers |
Frédéric Lécaille | 3b3a883 | 2018-12-20 09:55:42 +0100 | [diff] [blame] | 23 | barrier b1 cond 5 -cyclic |
Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 24 | |
| 25 | # These servers are there only for the health-check test. |
| 26 | server s1 { |
| 27 | } -start |
| 28 | |
| 29 | server s2 { |
| 30 | } -start |
| 31 | |
| 32 | server s3 { |
| 33 | } -start |
| 34 | |
| 35 | server s4 { |
| 36 | } -start |
| 37 | |
| 38 | syslog S1 -level notice { |
| 39 | recv |
| 40 | expect ~ "Proxy be1 started" |
| 41 | recv |
| 42 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv1 succeeded, reason: Layer4 check passed, check duration: [[:digit:]]+ms, status: 1/1 UP" |
| 43 | barrier b1 sync |
| 44 | recv alert |
| 45 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Server be1/srv1 is going DOWN for maintenance. 0 active and 0 backup servers left. [01] sessions active, 0 requeued, 0 remaining in queue." |
| 46 | recv emerg |
| 47 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: backend be1 has no server available!" |
| 48 | barrier b1 sync |
| 49 | recv |
| 50 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: (Server be1/srv1 is UP/READY \\(leaving forced maintenance\\).|Health check for server be1/srv1 succeeded, reason: Layer4 check passed, check duration: [[:digit:]]+ms, status: 1/1 UP)" |
| 51 | barrier b1 sync |
| 52 | } -start |
| 53 | |
| 54 | syslog S2 -level notice { |
| 55 | recv |
| 56 | expect ~ "Proxy be2 started" |
| 57 | recv |
| 58 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be2/srv2 succeeded, reason: Layer4 check passed, check duration: [[:digit:]]+ms, status: 1/1 UP" |
| 59 | barrier b1 sync |
| 60 | recv alert |
| 61 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Server be2/srv2 is going DOWN for maintenance. 0 active and 0 backup servers left. [01] sessions active, 0 requeued, 0 remaining in queue." |
| 62 | recv emerg |
| 63 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: backend be2 has no server available!" |
| 64 | barrier b1 sync |
| 65 | recv |
| 66 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: (Server be2/srv2 is UP/READY \\(leaving forced maintenance\\).|Health check for server be2/srv2 succeeded, reason: Layer4 check passed, check duration: [[:digit:]]+ms, status: 1/1 UP)" |
| 67 | barrier b1 sync |
| 68 | } -start |
| 69 | |
| 70 | syslog S3 -level notice { |
| 71 | recv |
| 72 | expect ~ "Proxy be3 started" |
| 73 | recv |
| 74 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be3/srv3 succeeded, reason: Layer4 check passed, check duration: [[:digit:]]+ms, status: 1/1 UP" |
| 75 | barrier b1 sync |
| 76 | recv alert |
| 77 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Server be3/srv3 is going DOWN for maintenance. 0 active and 0 backup servers left. [01] sessions active, 0 requeued, 0 remaining in queue." |
| 78 | recv emerg |
| 79 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: backend be3 has no server available!" |
| 80 | barrier b1 sync |
| 81 | recv |
| 82 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: (Server be3/srv3 is UP/READY \\(leaving forced maintenance\\).|Health check for server be3/srv3 succeeded, reason: Layer4 check passed, check duration: [[:digit:]]+ms, status: 1/1 UP)" |
| 83 | barrier b1 sync |
| 84 | } -start |
| 85 | |
| 86 | syslog S4 -level notice { |
| 87 | recv |
| 88 | expect ~ "Proxy be4 started" |
| 89 | recv |
| 90 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be4/srv4 succeeded, reason: Layer4 check passed, check duration: [[:digit:]]+ms, status: 1/1 UP" |
| 91 | barrier b1 sync |
| 92 | recv alert |
| 93 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Server be4/srv4 is going DOWN for maintenance. 0 active and 0 backup servers left. [01] sessions active, 0 requeued, 0 remaining in queue." |
| 94 | recv emerg |
| 95 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: backend be4 has no server available!" |
| 96 | barrier b1 sync |
| 97 | recv |
| 98 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: (Server be4/srv4 is UP/READY \\(leaving forced maintenance\\).|Health check for server be4/srv4 succeeded, reason: Layer4 check passed, check duration: [[:digit:]]+ms, status: 1/1 UP)" |
| 99 | barrier b1 sync |
| 100 | } -start |
| 101 | |
| 102 | |
| 103 | haproxy h1 -conf { |
| 104 | defaults |
| 105 | timeout client 1s |
| 106 | timeout server 1s |
| 107 | timeout connect 1s |
| 108 | default-server check downinter 1s rise 1 fall 1 |
| 109 | |
| 110 | frontend fe1 |
| 111 | bind "fd@${fe1}" |
| 112 | use_backend be1 |
| 113 | |
| 114 | frontend fe2 |
| 115 | bind "fd@${fe2}" |
| 116 | use_backend be2 |
| 117 | |
| 118 | frontend fe3 |
| 119 | bind "fd@${fe3}" |
| 120 | use_backend be3 |
| 121 | |
| 122 | frontend fe4 |
| 123 | bind "fd@${fe4}" |
| 124 | use_backend be4 |
| 125 | |
| 126 | backend be1 |
| 127 | option log-health-checks |
| 128 | log ${S1_addr}:${S1_port} daemon |
| 129 | server srv1 ${s1_addr}:${s1_port} |
| 130 | |
| 131 | backend be2 |
| 132 | option log-health-checks |
| 133 | log ${S2_addr}:${S2_port} daemon |
| 134 | server srv2 ${s2_addr}:${s2_port} |
| 135 | |
| 136 | backend be3 |
| 137 | option log-health-checks |
| 138 | log ${S3_addr}:${S3_port} daemon |
| 139 | server srv3 ${s3_addr}:${s3_port} |
| 140 | |
| 141 | backend be4 |
| 142 | option log-health-checks |
| 143 | log ${S4_addr}:${S4_port} daemon |
| 144 | server srv4 ${s4_addr}:${s4_port} |
| 145 | } -start |
| 146 | |
| 147 | haproxy h1 -cli { |
| 148 | barrier b1 sync |
| 149 | send "show servers state" |
Willy Tarreau | f42fa7b | 2019-08-01 09:51:29 +0200 | [diff] [blame] | 150 | expect ~ "# be_id be_name srv_id srv_name srv_addr srv_op_state srv_admin_state srv_uweight srv_iweight srv_time_since_last_change srv_check_status srv_check_result srv_check_health srv_check_state srv_agent_state bk_f_forced_id srv_f_forced_id srv_fqdn srv_port srvrecord\n6 be1 1 srv1 ${s1_addr} 2 0 1 1 [[:digit:]]+ 6 3 1 [67] 0 0 0 - ${s1_port} -\n7 be2 1 srv2 ${s2_addr} 2 0 1 1 [[:digit:]]+ 6 3 1 [67] 0 0 0 - ${s2_port} -\n8 be3 1 srv3 ${s3_addr} 2 0 1 1 [[:digit:]]+ 6 3 1 [67] 0 0 0 - ${s3_port} -\n9 be4 1 srv4 ${s4_addr} 2 0 1 1 [[:digit:]]+ 6 3 1 [67] 0 0 0 - ${s4_port} -" |
Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | haproxy h1 -cli { |
| 154 | send "disable server be1/srv1" |
| 155 | expect ~ .* |
| 156 | } |
| 157 | |
| 158 | haproxy h1 -cli { |
| 159 | send "disable server be2/srv2" |
| 160 | expect ~ .* |
| 161 | } |
| 162 | |
| 163 | haproxy h1 -cli { |
| 164 | send "disable server be3/srv3" |
| 165 | expect ~ .* |
| 166 | } |
| 167 | |
| 168 | haproxy h1 -cli { |
| 169 | send "disable server be4/srv4" |
| 170 | expect ~ .* |
| 171 | } |
| 172 | |
| 173 | haproxy h1 -cli { |
| 174 | barrier b1 sync |
| 175 | send "show servers state" |
Willy Tarreau | f42fa7b | 2019-08-01 09:51:29 +0200 | [diff] [blame] | 176 | expect ~ "# be_id be_name srv_id srv_name srv_addr srv_op_state srv_admin_state srv_uweight srv_iweight srv_time_since_last_change srv_check_status srv_check_result srv_check_health srv_check_state srv_agent_state bk_f_forced_id srv_f_forced_id srv_fqdn srv_port srvrecord\n6 be1 1 srv1 ${s1_addr} 0 1 1 1 [[:digit:]]+ 6 3 [01] 1[45] 0 0 0 - ${s1_port} -\n7 be2 1 srv2 ${s2_addr} 0 1 1 1 [[:digit:]]+ 6 3 [01] 1[45] 0 0 0 - ${s2_port} -\n8 be3 1 srv3 ${s3_addr} 0 1 1 1 [[:digit:]]+ 6 3 [01] 1[45] 0 0 0 - ${s3_port} -\n9 be4 1 srv4 ${s4_addr} 0 1 1 1 [[:digit:]]+ 6 3 [01] 1[45] 0 0 0 - ${s4_port} -" |
Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | haproxy h1 -cli { |
| 180 | send "enable server be1/srv1" |
| 181 | expect ~ .* |
| 182 | } |
| 183 | |
| 184 | haproxy h1 -cli { |
| 185 | send "enable server be2/srv2" |
| 186 | expect ~ .* |
| 187 | } |
| 188 | |
| 189 | haproxy h1 -cli { |
| 190 | send "enable server be3/srv3" |
| 191 | expect ~ .* |
| 192 | } |
| 193 | |
| 194 | haproxy h1 -cli { |
| 195 | send "enable server be4/srv4" |
| 196 | expect ~ .* |
| 197 | } |
| 198 | |
| 199 | haproxy h1 -cli { |
| 200 | barrier b1 sync |
| 201 | send "show servers state" |
| 202 | expect ~ "# be_id be_name srv_id srv_name srv_addr srv_op_state srv_admin_state srv_uweight srv_iweight srv_time_since_last_change srv_check_status srv_check_result srv_check_health srv_check_state srv_agent_state bk_f_forced_id srv_f_forced_id srv_fqdn srv_port srvrecord\n6 be1 1 srv1 ${s1_addr} 2 0 1 1 [[:digit:]]+ 6 [03] 1 [67] 0 0 0 - ${s1_port} -\n7 be2 1 srv2 ${s2_addr} 2 0 1 1 [[:digit:]]+ 6 [03] 1 [67] 0 0 0 - ${s2_port} -\n8 be3 1 srv3 ${s3_addr} 2 0 1 1 [[:digit:]]+ 6 [03] 1 [67] 0 0 0 - ${s3_port} -\n9 be4 1 srv4 ${s4_addr} 2 0 1 1 [[:digit:]]+ 6 [03] 1 [67] 0 0 0 - ${s4_port} -" |
| 203 | } |
| 204 | |
| 205 | syslog S1 -wait |
| 206 | syslog S2 -wait |
| 207 | syslog S3 -wait |
| 208 | syslog S4 -wait |
| 209 | |