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