Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 1 | varnishtest "Health-checks: Redis health-check" |
| 2 | #REQUIRE_VERSION=2.2 |
| 3 | #REGTEST_TYPE=slow |
| 4 | feature 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 | |
| 11 | server s1 { |
| 12 | recv 14 |
| 13 | send "+PONG\r\n" |
| 14 | } -start |
| 15 | |
| 16 | server s2 { |
| 17 | recv 14 |
| 18 | send "-Error message\r\n" |
| 19 | } -start |
| 20 | |
| 21 | syslog S1 -level notice { |
| 22 | recv |
Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 23 | 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 | |
| 26 | syslog S2 -level notice { |
| 27 | recv |
Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 28 | 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 | |
| 32 | haproxy h1 -conf { |
| 33 | defaults |
| 34 | mode tcp |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 35 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 36 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
| 37 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 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 | |
| 60 | syslog S1 -wait |
| 61 | syslog S2 -wait |