blob: a9c85cb184e3dd32e66fe3cda9337699dc6fddad [file] [log] [blame]
Christopher Fauletaec7f762020-04-22 15:16:58 +02001varnishtest "Health-checks: Redis health-check"
2#REQUIRE_VERSION=2.2
3#REGTEST_TYPE=slow
4feature ignore_unknown_macro
5
6# This scripts tests health-checks for Redis application, enabled using
7# "option redis-check" line. A intermediate listener is used to validate
8# the request because it is impossible with VTEST to read and match raw
9# text.
10
11server s1 {
12 recv 14
13 send "+PONG\r\n"
14} -start
15
16server s2 {
17 recv 14
18 send "-Error message\r\n"
19} -start
20
21syslog S1 -level notice {
22 recv
23 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be1 started."
24 recv
25 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded, reason: Layer7 check passed.+info: \"Redis server is ok\".+check duration: [[:digit:]]+ms, status: 1/1 UP."
26} -start
27
28syslog S2 -level notice {
29 recv
30 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be2 started."
31 recv
32 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be2/srv failed, reason: Layer7 wrong status.+info: \"-Error message\".+check duration: [[:digit:]]+ms, status: 0/1 DOWN."
33} -start
34
35
36haproxy h1 -conf {
37 defaults
38 mode tcp
39 timeout client 1s
40 timeout server 1s
41 timeout connect 100ms
42
43 backend be1
44 log ${S1_addr}:${S1_port} daemon
45 option log-health-checks
46 option redis-check
47 server srv ${h1_redis_addr}:${h1_redis_port} check inter 1s rise 1 fall 1
48
49 backend be2
50 log ${S2_addr}:${S2_port} daemon
51 option log-health-checks
52 option redis-check
53 server srv ${s2_addr}:${s2_port} check inter 1s rise 1 fall 1
54
55 listen redis1
56 bind "fd@${redis}"
57 tcp-request inspect-delay 100ms
58 tcp-request content accept if { req.len eq 14 } { req.payload(0,14) -m str "*1\r\n\$4\r\nPING\r\n" }
59 tcp-request content reject
60 server srv ${s1_addr}:${s1_port}
61
62} -start
63
64syslog S1 -wait
65syslog S2 -wait