Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 1 | varnishtest "Health-checks: http-check send test" |
Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 2 | #REGTEST_TYPE=slow |
Willy Tarreau | cb4ed02 | 2021-02-04 18:06:13 +0100 | [diff] [blame] | 3 | #REQUIRE_VERSION=2.4 |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 4 | feature ignore_unknown_macro |
| 5 | |
| 6 | # This script tests HTTP health-checks and more particularly the "http-check |
| 7 | # send" directive. |
| 8 | |
| 9 | server s1 { |
| 10 | rxreq |
| 11 | expect req.method == OPTIONS |
| 12 | expect req.url == / |
| 13 | expect req.proto == HTTP/1.0 |
| 14 | txresp |
| 15 | } -start |
| 16 | |
| 17 | server s2 { |
| 18 | rxreq |
| 19 | expect req.method == GET |
| 20 | expect req.url == /test |
| 21 | expect req.proto == HTTP/1.1 |
Willy Tarreau | 2da7429 | 2021-02-05 10:13:15 +0100 | [diff] [blame] | 22 | expect req.http.connection == "close" |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 23 | txresp |
| 24 | } -start |
| 25 | |
| 26 | server s3 { |
| 27 | rxreq |
| 28 | expect req.method == OPTIONS |
| 29 | expect req.url == / |
| 30 | expect req.proto == HTTP/1.0 |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 31 | expect req.http.host == <undef> |
| 32 | expect req.http.x-test == <undef> |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 33 | expect req.bodylen == 0 |
| 34 | txresp |
| 35 | } -start |
| 36 | |
| 37 | server s4 { |
| 38 | rxreq |
| 39 | expect req.method == GET |
| 40 | expect req.url == /status |
| 41 | expect req.proto == HTTP/1.1 |
Willy Tarreau | 2da7429 | 2021-02-05 10:13:15 +0100 | [diff] [blame] | 42 | expect req.http.connection == "close" |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 43 | expect req.http.host == "my-www-host" |
| 44 | expect req.http.x-test == true |
| 45 | expect req.http.content-length == 4 |
| 46 | expect req.bodylen == 4 |
| 47 | expect req.body == "test" |
| 48 | txresp |
| 49 | } -start |
| 50 | |
| 51 | server s5 { |
| 52 | rxreq |
Christopher Faulet | a67ed43 | 2020-04-20 14:59:20 +0200 | [diff] [blame] | 53 | expect req.method == OPTIONS |
| 54 | expect req.url == / |
| 55 | expect req.proto == HTTP/1.0 |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 56 | expect req.http.host == "other-www-host" |
| 57 | expect req.http.x-test == <undef> |
| 58 | expect req.http.x-new-test == true |
| 59 | expect req.http.content-length == 10 |
| 60 | expect req.bodylen == 10 |
| 61 | expect req.body == "other test" |
| 62 | txresp |
| 63 | } -start |
| 64 | |
Willy Tarreau | 2da7429 | 2021-02-05 10:13:15 +0100 | [diff] [blame] | 65 | server s6 { |
| 66 | rxreq |
| 67 | expect req.method == GET |
| 68 | expect req.url == / |
| 69 | expect req.proto == HTTP/1.1 |
| 70 | expect req.http.host == "ws-host" |
| 71 | expect req.http.connection == "upgrade" |
| 72 | expect req.http.upgrade == "raw-proto" |
| 73 | txresp \ |
| 74 | -status 101 \ |
| 75 | -hdr "connection: upgrade" \ |
| 76 | -hdr "upgrade: raw-proto" |
| 77 | } -start |
| 78 | |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 79 | |
| 80 | syslog S1 -level notice { |
| 81 | recv |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 82 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded.*code: 200" |
| 83 | } -start |
| 84 | |
| 85 | syslog S2 -level notice { |
| 86 | recv |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 87 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be2/srv succeeded.*code: 200" |
| 88 | } -start |
| 89 | |
| 90 | syslog S3 -level notice { |
| 91 | recv |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 92 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be3/srv succeeded.*code: 200" |
| 93 | } -start |
| 94 | |
| 95 | syslog S4 -level notice { |
| 96 | recv |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 97 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be4/srv succeeded.*code: 200" |
| 98 | } -start |
| 99 | |
| 100 | syslog S5 -level notice { |
| 101 | recv |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 102 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be5/srv succeeded.*code: 200" |
| 103 | } -start |
| 104 | |
Willy Tarreau | 2da7429 | 2021-02-05 10:13:15 +0100 | [diff] [blame] | 105 | syslog S6 -level notice { |
| 106 | recv |
| 107 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be6_ws/srv succeeded.*code: 101" |
| 108 | } -start |
| 109 | |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 110 | |
| 111 | haproxy h1 -conf { |
| 112 | defaults |
| 113 | mode http |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 114 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 115 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
| 116 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 117 | option httpchk |
| 118 | option log-health-checks |
| 119 | |
| 120 | backend be1 |
| 121 | log ${S1_addr}:${S1_port} len 2048 local0 |
| 122 | server srv ${s1_addr}:${s1_port} check inter 200ms rise 1 fall 1 |
| 123 | |
| 124 | backend be2 |
| 125 | log ${S2_addr}:${S2_port} len 2048 local0 |
| 126 | option httpchk GET /test HTTP/1.1 |
| 127 | server srv ${s2_addr}:${s2_port} check inter 200ms rise 1 fall 1 |
| 128 | |
| 129 | defaults |
| 130 | mode http |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 131 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 132 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
| 133 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
Christopher Faulet | 4b5f302 | 2022-09-05 09:05:17 +0200 | [diff] [blame] | 134 | option httpchk GET /status HTTP/1.1 |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 135 | option log-health-checks |
| 136 | http-check send hdr Host "my-www-host" hdr X-test true body "test" |
| 137 | |
| 138 | backend be3 |
| 139 | option httpchk |
| 140 | log ${S3_addr}:${S3_port} len 2048 local0 |
| 141 | server srv ${s3_addr}:${s3_port} check inter 200ms rise 1 fall 1 |
| 142 | |
| 143 | backend be4 |
| 144 | log ${S4_addr}:${S4_port} len 2048 local0 |
| 145 | server srv ${s4_addr}:${s4_port} check inter 200ms rise 1 fall 1 |
| 146 | |
| 147 | backend be5 |
| 148 | log ${S5_addr}:${S5_port} len 2058 local0 |
| 149 | http-check send hdr Host "other-www-host" hdr X-New-Test true body "other test" |
| 150 | server srv ${s5_addr}:${s5_port} check inter 200ms rise 1 fall 1 |
| 151 | |
Willy Tarreau | 2da7429 | 2021-02-05 10:13:15 +0100 | [diff] [blame] | 152 | backend be6_ws |
| 153 | log ${S6_addr}:${S6_port} len 2048 local0 |
| 154 | http-check send meth GET uri / ver HTTP/1.1 hdr host ws-host hdr connection upgrade hdr upgrade raw-proto |
| 155 | http-check expect status 101 |
| 156 | server srv ${s6_addr}:${s6_port} check inter 200ms rise 1 fall 1 |
| 157 | |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 158 | } -start |
| 159 | |
| 160 | syslog S1 -wait |
| 161 | syslog S2 -wait |
| 162 | syslog S3 -wait |
| 163 | syslog S4 -wait |
| 164 | syslog S5 -wait |
Willy Tarreau | 2da7429 | 2021-02-05 10:13:15 +0100 | [diff] [blame] | 165 | syslog S6 -wait |