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