blob: c6d4fe4b11acdf99f2dab311dafc791b50450e4d [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
Christopher Fauletaec7f762020-04-22 15:16:58 +020023 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."
24} -start
25
26syslog S2 -level notice {
27 recv
Christopher Fauletaec7f762020-04-22 15:16:58 +020028 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."
29} -start
30
31
32haproxy h1 -conf {
33 defaults
34 mode tcp
35 timeout client 1s
36 timeout server 1s
37 timeout connect 100ms
38
39 backend be1
40 log ${S1_addr}:${S1_port} daemon
41 option log-health-checks
42 option redis-check
43 server srv ${h1_redis_addr}:${h1_redis_port} check inter 1s rise 1 fall 1
44
45 backend be2
46 log ${S2_addr}:${S2_port} daemon
47 option log-health-checks
48 option redis-check
49 server srv ${s2_addr}:${s2_port} check inter 1s rise 1 fall 1
50
51 listen redis1
52 bind "fd@${redis}"
53 tcp-request inspect-delay 100ms
54 tcp-request content accept if { req.len eq 14 } { req.payload(0,14) -m str "*1\r\n\$4\r\nPING\r\n" }
55 tcp-request content reject
56 server srv ${s1_addr}:${s1_port}
57
58} -start
59
60syslog S1 -wait
61syslog S2 -wait