blob: 76fd5842f75ae3d2a8c62c6c8d8ee67c2bc227c6 [file] [log] [blame]
Christopher Faulet8acb1282020-04-09 08:44:06 +02001varnishtest "Health-checks: http-check send test"
Christopher Fauletaec7f762020-04-22 15:16:58 +02002#REGTEST_TYPE=slow
Willy Tarreaucb4ed022021-02-04 18:06:13 +01003#REQUIRE_VERSION=2.4
Christopher Faulet8acb1282020-04-09 08:44:06 +02004feature ignore_unknown_macro
5
6# This script tests HTTP health-checks and more particularly the "http-check
7# send" directive.
8
9server s1 {
10 rxreq
11 expect req.method == OPTIONS
12 expect req.url == /
13 expect req.proto == HTTP/1.0
14 txresp
15} -start
16
17server s2 {
18 rxreq
19 expect req.method == GET
20 expect req.url == /test
21 expect req.proto == HTTP/1.1
Willy Tarreau2da74292021-02-05 10:13:15 +010022 expect req.http.connection == "close"
Christopher Faulet8acb1282020-04-09 08:44:06 +020023 txresp
24} -start
25
26server 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 Faulet8acb1282020-04-09 08:44:06 +020034 expect req.bodylen == 0
35 txresp
36} -start
37
38server s4 {
39 rxreq
40 expect req.method == GET
41 expect req.url == /status
42 expect req.proto == HTTP/1.1
Willy Tarreau2da74292021-02-05 10:13:15 +010043 expect req.http.connection == "close"
Christopher Faulet8acb1282020-04-09 08:44:06 +020044 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
53server s5 {
54 rxreq
Christopher Fauleta67ed432020-04-20 14:59:20 +020055 expect req.method == OPTIONS
56 expect req.url == /
57 expect req.proto == HTTP/1.0
Christopher Faulet8acb1282020-04-09 08:44:06 +020058 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 Tarreau2da74292021-02-05 10:13:15 +010068server 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 Faulet8acb1282020-04-09 08:44:06 +020082
83syslog S1 -level notice {
84 recv
Christopher Faulet8acb1282020-04-09 08:44:06 +020085 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded.*code: 200"
86} -start
87
88syslog S2 -level notice {
89 recv
Christopher Faulet8acb1282020-04-09 08:44:06 +020090 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be2/srv succeeded.*code: 200"
91} -start
92
93syslog S3 -level notice {
94 recv
Christopher Faulet8acb1282020-04-09 08:44:06 +020095 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be3/srv succeeded.*code: 200"
96} -start
97
98syslog S4 -level notice {
99 recv
Christopher Faulet8acb1282020-04-09 08:44:06 +0200100 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be4/srv succeeded.*code: 200"
101} -start
102
103syslog S5 -level notice {
104 recv
Christopher Faulet8acb1282020-04-09 08:44:06 +0200105 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be5/srv succeeded.*code: 200"
106} -start
107
Willy Tarreau2da74292021-02-05 10:13:15 +0100108syslog S6 -level notice {
109 recv
110 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be6_ws/srv succeeded.*code: 101"
111} -start
112
Christopher Faulet8acb1282020-04-09 08:44:06 +0200113
114haproxy 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 Tarreau2da74292021-02-05 10:13:15 +0100155 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 Faulet8acb1282020-04-09 08:44:06 +0200161} -start
162
163syslog S1 -wait
164syslog S2 -wait
165syslog S3 -wait
166syslog S4 -wait
167syslog S5 -wait
Willy Tarreau2da74292021-02-05 10:13:15 +0100168syslog S6 -wait