2022-06-08 09:57:52 +00:00
|
|
|
varnishtest "Check health-check email alerts"
|
2018-12-23 20:06:31 +00:00
|
|
|
#REQUIRE_OPTIONS=LUA
|
|
|
|
|
|
|
|
feature ignore_unknown_macro
|
|
|
|
|
2022-06-08 09:57:52 +00:00
|
|
|
syslog S1 -level notice {
|
|
|
|
recv
|
2022-06-08 14:55:21 +00:00
|
|
|
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv1 failed.+reason: Socket error.+info: \".+\".+check duration: [[:digit:]]+ms.+status: 0/1 DOWN."
|
2022-06-08 09:57:52 +00:00
|
|
|
recv info
|
|
|
|
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Result=SUCCESS Bytes=[[:digit:]]+"
|
2018-12-23 20:06:31 +00:00
|
|
|
} -start
|
|
|
|
|
|
|
|
haproxy h1 -conf {
|
|
|
|
global
|
2019-03-29 15:13:48 +00:00
|
|
|
lua-load ${testdir}/healthcheckmail.lua
|
2022-06-08 09:57:52 +00:00
|
|
|
|
|
|
|
defaults
|
|
|
|
timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
|
|
|
|
timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
|
|
|
|
timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
|
|
|
|
|
|
|
|
listen lisrv
|
2018-12-23 20:06:31 +00:00
|
|
|
mode tcp
|
2022-06-08 09:57:52 +00:00
|
|
|
bind "fd@${lisrv}"
|
|
|
|
tcp-request connection reject
|
2018-12-23 20:06:31 +00:00
|
|
|
|
2022-06-08 09:57:52 +00:00
|
|
|
listen lismtp
|
|
|
|
mode tcp
|
|
|
|
bind "fd@${lismtp}"
|
|
|
|
log ${S1_addr}:${S1_port} daemon
|
|
|
|
log-format "Result=%[var(txn.result)] Bytes=%B"
|
|
|
|
tcp-request content use-service lua.mailservice
|
2018-12-23 20:06:31 +00:00
|
|
|
|
|
|
|
frontend fe1
|
|
|
|
mode http
|
|
|
|
bind "fd@${fe1}"
|
2022-06-08 09:57:52 +00:00
|
|
|
default_backend be1
|
2018-12-23 20:06:31 +00:00
|
|
|
|
2022-06-08 09:57:52 +00:00
|
|
|
backend be1
|
2018-12-23 20:06:31 +00:00
|
|
|
mode http
|
2022-06-08 09:57:52 +00:00
|
|
|
log ${S1_addr}:${S1_port} daemon
|
|
|
|
option httpchk
|
2018-12-23 20:06:31 +00:00
|
|
|
option log-health-checks
|
|
|
|
|
2022-06-08 09:57:52 +00:00
|
|
|
default-server inter 200ms downinter 100ms rise 1 fall 1
|
|
|
|
|
2018-12-23 20:06:31 +00:00
|
|
|
email-alert mailers mymailers
|
|
|
|
email-alert level info
|
|
|
|
email-alert from from@domain.tld
|
|
|
|
email-alert to to@domain.tld
|
|
|
|
|
2022-06-08 09:57:52 +00:00
|
|
|
server srv1 ${h1_lisrv_addr}:${h1_lisrv_port} check
|
2018-12-23 20:06:31 +00:00
|
|
|
|
|
|
|
mailers mymailers
|
2022-06-08 09:57:52 +00:00
|
|
|
mailer smtp1 ${h1_lismtp_addr}:${h1_lismtp_port}
|
2018-12-23 20:06:31 +00:00
|
|
|
|
|
|
|
} -start
|
|
|
|
|
2022-06-08 09:57:52 +00:00
|
|
|
syslog S1 -wait
|