blob: 05f09a84c05a54d72c94072af184a863c90dda2a [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 Tarreaua0be8592020-05-07 18:42:22 +02003#REQUIRE_VERSION=2.2
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
22 txresp
23} -start
24
25server s3 {
26 rxreq
27 expect req.method == OPTIONS
28 expect req.url == /
29 expect req.proto == HTTP/1.0
30 expect req.http.hdr == <undef>
31 expect req.http.host == <undef>
32 expect req.http.x-test == <undef>
Christopher Faulet8acb1282020-04-09 08:44:06 +020033 expect req.bodylen == 0
34 txresp
35} -start
36
37server s4 {
38 rxreq
39 expect req.method == GET
40 expect req.url == /status
41 expect req.proto == HTTP/1.1
42 expect req.http.hdr == <undef>
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
51server s5 {
52 rxreq
Christopher Fauleta67ed432020-04-20 14:59:20 +020053 expect req.method == OPTIONS
54 expect req.url == /
55 expect req.proto == HTTP/1.0
Christopher Faulet8acb1282020-04-09 08:44:06 +020056 expect req.http.hdr == <undef>
57 expect req.http.host == "other-www-host"
58 expect req.http.x-test == <undef>
59 expect req.http.x-new-test == true
60 expect req.http.content-length == 10
61 expect req.bodylen == 10
62 expect req.body == "other test"
63 txresp
64} -start
65
66
67syslog S1 -level notice {
68 recv
69 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be1 started."
70 recv
71 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded.*code: 200"
72} -start
73
74syslog S2 -level notice {
75 recv
76 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be2 started."
77 recv
78 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be2/srv succeeded.*code: 200"
79} -start
80
81syslog S3 -level notice {
82 recv
83 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be3 started."
84 recv
85 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be3/srv succeeded.*code: 200"
86} -start
87
88syslog S4 -level notice {
89 recv
90 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be4 started."
91 recv
92 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be4/srv succeeded.*code: 200"
93} -start
94
95syslog S5 -level notice {
96 recv
97 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be5 started."
98 recv
99 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be5/srv succeeded.*code: 200"
100} -start
101
102
103haproxy h1 -conf {
104 defaults
105 mode http
106 timeout client 1s
107 timeout server 1s
108 timeout connect 200ms
109 option httpchk
110 option log-health-checks
111
112 backend be1
113 log ${S1_addr}:${S1_port} len 2048 local0
114 server srv ${s1_addr}:${s1_port} check inter 200ms rise 1 fall 1
115
116 backend be2
117 log ${S2_addr}:${S2_port} len 2048 local0
118 option httpchk GET /test HTTP/1.1
119 server srv ${s2_addr}:${s2_port} check inter 200ms rise 1 fall 1
120
121 defaults
122 mode http
123 timeout client 1s
124 timeout server 1s
125 timeout connect 200ms
126 option httpchk GET /status HTTP/1.1\r\nHdr:\ must-be-removed
127 option log-health-checks
128 http-check send hdr Host "my-www-host" hdr X-test true body "test"
129
130 backend be3
131 option httpchk
132 log ${S3_addr}:${S3_port} len 2048 local0
133 server srv ${s3_addr}:${s3_port} check inter 200ms rise 1 fall 1
134
135 backend be4
136 log ${S4_addr}:${S4_port} len 2048 local0
137 server srv ${s4_addr}:${s4_port} check inter 200ms rise 1 fall 1
138
139 backend be5
140 log ${S5_addr}:${S5_port} len 2058 local0
141 http-check send hdr Host "other-www-host" hdr X-New-Test true body "other test"
142 server srv ${s5_addr}:${s5_port} check inter 200ms rise 1 fall 1
143
144} -start
145
146syslog S1 -wait
147syslog S2 -wait
148syslog S3 -wait
149syslog S4 -wait
150syslog S5 -wait