blob: ab629db8e51d34348b450652ab142717324cc509 [file] [log] [blame]
Christopher Faulet39708192020-05-05 10:47:36 +02001varnishtest "Health-checks: some http-check expect tests"
2feature ignore_unknown_macro
3#REQUIRE_VERSION=2.2
4#REGTEST_TYPE=slow
5# This script tests http-check expect rules.
6
7server s1 {
8 rxreq
9 expect req.method == OPTIONS
10 expect req.url == /
11 expect req.proto == HTTP/1.0
12 txresp -status 202 \
13 -hdr "x-test1: true, next value" \
14 -hdr "x-test2: true, begin-value, value-end, value-sub-string, value-reg-123ABC" \
15 -hdr "x-begin-test: 1" \
16 -hdr "x-test-end: 1" \
17 -hdr "x-sub-test: 1" \
18 -hdr "x-reg-test1: 1" \
19 -hdr "x-hdr-name: x-test1"
20} -start
21
22syslog S1 -level notice {
23 recv
24 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be1 started."
25 recv
26 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded.*code: 202"
27} -start
28
29haproxy h1 -conf {
30 defaults
31 mode http
32 timeout client 1s
33 timeout server 1s
34 timeout connect 100ms
35 option log-health-checks
36
37 backend be1
38 log ${S1_addr}:${S1_port} len 2048 local0
39 option httpchk
40 http-check expect status 200-399
41
Christopher Fauletb5594262020-05-05 20:23:13 +020042 http-check expect hdr name "x-test1"
43 http-check expect hdr name -m str "X-Test2"
44 http-check expect hdr name -m beg "X-Begin-"
45 http-check expect hdr name -m end "-End"
46 http-check expect hdr name -m sub "-Sub-"
47 http-check expect hdr name -m reg "^[a-z]+-Reg-[a-z]+[0-9]\$"
Christopher Faulete596d182020-05-05 17:46:34 +020048 http-check set-var(check.hdr_name) res.fhdr(x-hdr-name)
Christopher Fauletb5594262020-05-05 20:23:13 +020049 http-check expect hdr name-lf -m str "%[var(check.hdr_name)]"
50 http-check expect hdr name-lf -m str "%[res.fhdr(x-hdr-name)]"
Christopher Faulet39708192020-05-05 10:47:36 +020051
Christopher Fauletb5594262020-05-05 20:23:13 +020052 http-check expect fhdr name "x-test1" value "true, next value"
53 http-check expect hdr name "x-test2" value -m str "true"
54 http-check expect hdr name -m beg "x-test" value -m beg "begin-"
55 http-check expect hdr name -m beg "x-test" value -m end "-end"
56 http-check expect hdr name -m beg "x-test" value -m sub "-sub-"
57 http-check expect hdr name -m beg "x-test" value -m reg "^value-reg-[A-Z0-9]+\$"
58 http-check expect fhdr name -m beg "x-test" value -m reg "value-reg-[A-Z0-9]+"
Christopher Faulet39708192020-05-05 10:47:36 +020059 http-check set-var(check.hdr_value) str(x-test1)
Christopher Fauletb5594262020-05-05 20:23:13 +020060 http-check expect hdr name -m beg "x-" value-lf -m str "%[var(check.hdr_value)]"
61 http-check expect fhdr name -m beg "x-" value-lf -m str "%[res.fhdr(x-hdr-name)]"
Christopher Faulet39708192020-05-05 10:47:36 +020062
63 server srv ${s1_addr}:${s1_port} check inter 100ms rise 1 fall 1
64} -start
65
66syslog S1 -wait