blob: 179e149ed2ed0a69329bef8cd7a4b62b53e72c05 [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
Christopher Faulet8acb1282020-04-09 08:44:06 +020069 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded.*code: 200"
70} -start
71
72syslog S2 -level notice {
73 recv
Christopher Faulet8acb1282020-04-09 08:44:06 +020074 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be2/srv succeeded.*code: 200"
75} -start
76
77syslog S3 -level notice {
78 recv
Christopher Faulet8acb1282020-04-09 08:44:06 +020079 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be3/srv succeeded.*code: 200"
80} -start
81
82syslog S4 -level notice {
83 recv
Christopher Faulet8acb1282020-04-09 08:44:06 +020084 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be4/srv succeeded.*code: 200"
85} -start
86
87syslog S5 -level notice {
88 recv
Christopher Faulet8acb1282020-04-09 08:44:06 +020089 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be5/srv succeeded.*code: 200"
90} -start
91
92
93haproxy h1 -conf {
94 defaults
95 mode http
96 timeout client 1s
97 timeout server 1s
98 timeout connect 200ms
99 option httpchk
100 option log-health-checks
101
102 backend be1
103 log ${S1_addr}:${S1_port} len 2048 local0
104 server srv ${s1_addr}:${s1_port} check inter 200ms rise 1 fall 1
105
106 backend be2
107 log ${S2_addr}:${S2_port} len 2048 local0
108 option httpchk GET /test HTTP/1.1
109 server srv ${s2_addr}:${s2_port} check inter 200ms rise 1 fall 1
110
111 defaults
112 mode http
113 timeout client 1s
114 timeout server 1s
115 timeout connect 200ms
116 option httpchk GET /status HTTP/1.1\r\nHdr:\ must-be-removed
117 option log-health-checks
118 http-check send hdr Host "my-www-host" hdr X-test true body "test"
119
120 backend be3
121 option httpchk
122 log ${S3_addr}:${S3_port} len 2048 local0
123 server srv ${s3_addr}:${s3_port} check inter 200ms rise 1 fall 1
124
125 backend be4
126 log ${S4_addr}:${S4_port} len 2048 local0
127 server srv ${s4_addr}:${s4_port} check inter 200ms rise 1 fall 1
128
129 backend be5
130 log ${S5_addr}:${S5_port} len 2058 local0
131 http-check send hdr Host "other-www-host" hdr X-New-Test true body "other test"
132 server srv ${s5_addr}:${s5_port} check inter 200ms rise 1 fall 1
133
134} -start
135
136syslog S1 -wait
137syslog S2 -wait
138syslog S3 -wait
139syslog S4 -wait
140syslog S5 -wait