Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 1 | varnishtest "Health-check test" |
| 2 | feature ignore_unknown_macro |
| 3 | |
Christopher Faulet | 85a8136 | 2020-12-15 17:13:39 +0100 | [diff] [blame] | 4 | #REQUIRE_VERSION=2.4 |
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 | |
Ilya Shipitsin | 77e3b4a | 2020-03-10 12:06:11 +0500 | [diff] [blame] | 22 | # Cyclic barrier to synchronize 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 |
Christopher Faulet | 617780f | 2020-04-07 08:00:35 +0200 | [diff] [blame] | 40 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv1 succeeded.+reason: Layer4 check passed.+check duration: [[:digit:]]+ms.+status: 1/1 UP" |
Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 41 | barrier b1 sync |
| 42 | recv alert |
| 43 | 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." |
| 44 | recv emerg |
| 45 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: backend be1 has no server available!" |
| 46 | barrier b1 sync |
| 47 | recv |
Christopher Faulet | 617780f | 2020-04-07 08:00:35 +0200 | [diff] [blame] | 48 | 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)" |
Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 49 | barrier b1 sync |
| 50 | } -start |
| 51 | |
| 52 | syslog S2 -level notice { |
| 53 | recv |
Christopher Faulet | 617780f | 2020-04-07 08:00:35 +0200 | [diff] [blame] | 54 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be2/srv2 succeeded.+reason: Layer4 check passed.+check duration: [[:digit:]]+ms.+status: 1/1 UP" |
Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 55 | barrier b1 sync |
| 56 | recv alert |
| 57 | 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." |
| 58 | recv emerg |
| 59 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: backend be2 has no server available!" |
| 60 | barrier b1 sync |
| 61 | recv |
Christopher Faulet | 617780f | 2020-04-07 08:00:35 +0200 | [diff] [blame] | 62 | 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)" |
Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 63 | barrier b1 sync |
| 64 | } -start |
| 65 | |
| 66 | syslog S3 -level notice { |
| 67 | recv |
Christopher Faulet | 617780f | 2020-04-07 08:00:35 +0200 | [diff] [blame] | 68 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be3/srv3 succeeded.+reason: Layer4 check passed.+check duration: [[:digit:]]+ms.+status: 1/1 UP" |
Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 69 | barrier b1 sync |
| 70 | recv alert |
| 71 | 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." |
| 72 | recv emerg |
| 73 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: backend be3 has no server available!" |
| 74 | barrier b1 sync |
| 75 | recv |
Christopher Faulet | 617780f | 2020-04-07 08:00:35 +0200 | [diff] [blame] | 76 | 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)" |
Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 77 | barrier b1 sync |
| 78 | } -start |
| 79 | |
| 80 | syslog S4 -level notice { |
| 81 | recv |
Christopher Faulet | 617780f | 2020-04-07 08:00:35 +0200 | [diff] [blame] | 82 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be4/srv4 succeeded.+reason: Layer4 check passed.+check duration: [[:digit:]]+ms.+status: 1/1 UP" |
Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 83 | barrier b1 sync |
| 84 | recv alert |
| 85 | 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." |
| 86 | recv emerg |
| 87 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: backend be4 has no server available!" |
| 88 | barrier b1 sync |
| 89 | recv |
Christopher Faulet | 617780f | 2020-04-07 08:00:35 +0200 | [diff] [blame] | 90 | 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)" |
Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 91 | barrier b1 sync |
| 92 | } -start |
| 93 | |
| 94 | |
| 95 | haproxy h1 -conf { |
| 96 | defaults |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 97 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 98 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
| 99 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
Christopher Faulet | 617780f | 2020-04-07 08:00:35 +0200 | [diff] [blame] | 100 | default-server check inter 200ms downinter 100s rise 1 fall 1 |
Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 101 | |
| 102 | frontend fe1 |
| 103 | bind "fd@${fe1}" |
| 104 | use_backend be1 |
| 105 | |
| 106 | frontend fe2 |
| 107 | bind "fd@${fe2}" |
| 108 | use_backend be2 |
| 109 | |
| 110 | frontend fe3 |
| 111 | bind "fd@${fe3}" |
| 112 | use_backend be3 |
| 113 | |
| 114 | frontend fe4 |
| 115 | bind "fd@${fe4}" |
| 116 | use_backend be4 |
| 117 | |
| 118 | backend be1 |
| 119 | option log-health-checks |
| 120 | log ${S1_addr}:${S1_port} daemon |
| 121 | server srv1 ${s1_addr}:${s1_port} |
| 122 | |
| 123 | backend be2 |
| 124 | option log-health-checks |
| 125 | log ${S2_addr}:${S2_port} daemon |
| 126 | server srv2 ${s2_addr}:${s2_port} |
| 127 | |
| 128 | backend be3 |
| 129 | option log-health-checks |
| 130 | log ${S3_addr}:${S3_port} daemon |
| 131 | server srv3 ${s3_addr}:${s3_port} |
| 132 | |
| 133 | backend be4 |
| 134 | option log-health-checks |
| 135 | log ${S4_addr}:${S4_port} daemon |
| 136 | server srv4 ${s4_addr}:${s4_port} |
| 137 | } -start |
| 138 | |
| 139 | haproxy h1 -cli { |
| 140 | barrier b1 sync |
| 141 | send "show servers state" |
William Dauchy | d1a7b85 | 2021-02-11 22:51:26 +0100 | [diff] [blame] | 142 | 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 srv_use_ssl srv_check_port srv_check_addr srv_agent_addr srv_agent_port\n6 be1 1 srv1 ${s1_addr} 2 0 1 1 [[:digit:]]+ 6 3 1 [67] 0 0 0 - ${s1_port} - 0 0 - - 0\n7 be2 1 srv2 ${s2_addr} 2 0 1 1 [[:digit:]]+ 6 3 1 [67] 0 0 0 - ${s2_port} - 0 0 - - 0\n8 be3 1 srv3 ${s3_addr} 2 0 1 1 [[:digit:]]+ 6 3 1 [67] 0 0 0 - ${s3_port} - 0 0 - - 0\n9 be4 1 srv4 ${s4_addr} 2 0 1 1 [[:digit:]]+ 6 3 1 [67] 0 0 0 - ${s4_port} - 0 0 - - 0" |
Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | haproxy h1 -cli { |
| 146 | send "disable server be1/srv1" |
| 147 | expect ~ .* |
| 148 | } |
| 149 | |
| 150 | haproxy h1 -cli { |
| 151 | send "disable server be2/srv2" |
| 152 | expect ~ .* |
| 153 | } |
| 154 | |
| 155 | haproxy h1 -cli { |
| 156 | send "disable server be3/srv3" |
| 157 | expect ~ .* |
| 158 | } |
| 159 | |
| 160 | haproxy h1 -cli { |
| 161 | send "disable server be4/srv4" |
| 162 | expect ~ .* |
| 163 | } |
| 164 | |
| 165 | haproxy h1 -cli { |
| 166 | barrier b1 sync |
| 167 | send "show servers state" |
William Dauchy | d1a7b85 | 2021-02-11 22:51:26 +0100 | [diff] [blame] | 168 | 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 srv_use_ssl srv_check_port srv_check_addr srv_agent_addr srv_agent_port\n6 be1 1 srv1 ${s1_addr} 0 1 1 1 [[:digit:]]+ 6 3 [01] 1[45] 0 0 0 - ${s1_port} - 0 0 - - 0\n7 be2 1 srv2 ${s2_addr} 0 1 1 1 [[:digit:]]+ 6 3 [01] 1[45] 0 0 0 - ${s2_port} - 0 0 - - 0\n8 be3 1 srv3 ${s3_addr} 0 1 1 1 [[:digit:]]+ 6 3 [01] 1[45] 0 0 0 - ${s3_port} - 0 0 - - 0\n9 be4 1 srv4 ${s4_addr} 0 1 1 1 [[:digit:]]+ 6 3 [01] 1[45] 0 0 0 - ${s4_port} - 0 0 - - 0" |
Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | haproxy h1 -cli { |
| 172 | send "enable server be1/srv1" |
| 173 | expect ~ .* |
| 174 | } |
| 175 | |
| 176 | haproxy h1 -cli { |
| 177 | send "enable server be2/srv2" |
| 178 | expect ~ .* |
| 179 | } |
| 180 | |
| 181 | haproxy h1 -cli { |
| 182 | send "enable server be3/srv3" |
| 183 | expect ~ .* |
| 184 | } |
| 185 | |
| 186 | haproxy h1 -cli { |
| 187 | send "enable server be4/srv4" |
| 188 | expect ~ .* |
| 189 | } |
| 190 | |
| 191 | haproxy h1 -cli { |
| 192 | barrier b1 sync |
| 193 | send "show servers state" |
William Dauchy | d1a7b85 | 2021-02-11 22:51:26 +0100 | [diff] [blame] | 194 | 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 srv_use_ssl srv_check_port srv_check_addr srv_agent_addr srv_agent_port\n6 be1 1 srv1 ${s1_addr} 2 0 1 1 [[:digit:]]+ 6 [03] 1 [67] 0 0 0 - ${s1_port} - 0 0 - - 0\n7 be2 1 srv2 ${s2_addr} 2 0 1 1 [[:digit:]]+ 6 [03] 1 [67] 0 0 0 - ${s2_port} - 0 0 - - 0\n8 be3 1 srv3 ${s3_addr} 2 0 1 1 [[:digit:]]+ 6 [03] 1 [67] 0 0 0 - ${s3_port} - 0 0 - - 0\n9 be4 1 srv4 ${s4_addr} 2 0 1 1 [[:digit:]]+ 6 [03] 1 [67] 0 0 0 - ${s4_port} - 0 0 - - 0" |
Frederic Lecaille | 9be3489 | 2018-12-13 22:15:06 +0100 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | syslog S1 -wait |
| 198 | syslog S2 -wait |
| 199 | syslog S3 -wait |
| 200 | syslog S4 -wait |
| 201 | |