blob: 637eec69ac15351484bd2d9fb119191d79e49956 [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
Christopher Faulet39708192020-05-05 10:47:36 +020024 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded.*code: 202"
25} -start
26
27haproxy h1 -conf {
28 defaults
29 mode http
Willy Tarreauf6739232021-11-18 17:46:22 +010030 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
31 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
32 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
Christopher Faulet39708192020-05-05 10:47:36 +020033 option log-health-checks
34
35 backend be1
36 log ${S1_addr}:${S1_port} len 2048 local0
37 option httpchk
38 http-check expect status 200-399
39
Christopher Fauletb5594262020-05-05 20:23:13 +020040 http-check expect hdr name "x-test1"
41 http-check expect hdr name -m str "X-Test2"
42 http-check expect hdr name -m beg "X-Begin-"
43 http-check expect hdr name -m end "-End"
44 http-check expect hdr name -m sub "-Sub-"
45 http-check expect hdr name -m reg "^[a-z]+-Reg-[a-z]+[0-9]\$"
Christopher Faulete596d182020-05-05 17:46:34 +020046 http-check set-var(check.hdr_name) res.fhdr(x-hdr-name)
Christopher Fauletb5594262020-05-05 20:23:13 +020047 http-check expect hdr name-lf -m str "%[var(check.hdr_name)]"
48 http-check expect hdr name-lf -m str "%[res.fhdr(x-hdr-name)]"
Christopher Faulet39708192020-05-05 10:47:36 +020049
Christopher Fauletb5594262020-05-05 20:23:13 +020050 http-check expect fhdr name "x-test1" value "true, next value"
51 http-check expect hdr name "x-test2" value -m str "true"
52 http-check expect hdr name -m beg "x-test" value -m beg "begin-"
53 http-check expect hdr name -m beg "x-test" value -m end "-end"
54 http-check expect hdr name -m beg "x-test" value -m sub "-sub-"
55 http-check expect hdr name -m beg "x-test" value -m reg "^value-reg-[A-Z0-9]+\$"
56 http-check expect fhdr name -m beg "x-test" value -m reg "value-reg-[A-Z0-9]+"
Christopher Faulet39708192020-05-05 10:47:36 +020057 http-check set-var(check.hdr_value) str(x-test1)
Christopher Fauletb5594262020-05-05 20:23:13 +020058 http-check expect hdr name -m beg "x-" value-lf -m str "%[var(check.hdr_value)]"
59 http-check expect fhdr name -m beg "x-" value-lf -m str "%[res.fhdr(x-hdr-name)]"
Christopher Faulet39708192020-05-05 10:47:36 +020060
61 server srv ${s1_addr}:${s1_port} check inter 100ms rise 1 fall 1
62} -start
63
64syslog S1 -wait