blob: 208d350f6fd28964cb6823812585fc1c3cbcdacc [file] [log] [blame]
Christopher Faulet52912572022-06-08 11:57:52 +02001varnishtest "Check health-check email alerts"
PiBa-NLc3949d42018-12-23 21:06:31 +01002#REQUIRE_OPTIONS=LUA
PiBa-NLc3949d42018-12-23 21:06:31 +01003
4feature ignore_unknown_macro
5
Christopher Faulet52912572022-06-08 11:57:52 +02006syslog S1 -level notice {
7 recv
Christopher Faulet28bc1522022-09-12 09:58:47 +02008 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv1 failed.+check duration: [[:digit:]]+ms.+status: 0/1 DOWN."
Christopher Faulet52912572022-06-08 11:57:52 +02009 recv info
10 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Result=SUCCESS Bytes=[[:digit:]]+"
PiBa-NLc3949d42018-12-23 21:06:31 +010011} -start
12
13haproxy h1 -conf {
14 global
Aurelien DARRAGON7963fb52023-05-03 16:55:52 +020015 lua-load ${testdir}/mailers.lua
Frédéric Lécailleb894f922019-03-29 16:13:48 +010016 lua-load ${testdir}/healthcheckmail.lua
Christopher Faulet52912572022-06-08 11:57:52 +020017
18 defaults
19 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
20 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
21 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
22
23 listen lisrv
PiBa-NLc3949d42018-12-23 21:06:31 +010024 mode tcp
Christopher Faulet52912572022-06-08 11:57:52 +020025 bind "fd@${lisrv}"
26 tcp-request connection reject
PiBa-NLc3949d42018-12-23 21:06:31 +010027
Christopher Faulet52912572022-06-08 11:57:52 +020028 listen lismtp
29 mode tcp
30 bind "fd@${lismtp}"
31 log ${S1_addr}:${S1_port} daemon
32 log-format "Result=%[var(txn.result)] Bytes=%B"
33 tcp-request content use-service lua.mailservice
PiBa-NLc3949d42018-12-23 21:06:31 +010034
35 frontend fe1
36 mode http
37 bind "fd@${fe1}"
Christopher Faulet52912572022-06-08 11:57:52 +020038 default_backend be1
PiBa-NLc3949d42018-12-23 21:06:31 +010039
Christopher Faulet52912572022-06-08 11:57:52 +020040 backend be1
PiBa-NLc3949d42018-12-23 21:06:31 +010041 mode http
Christopher Faulet52912572022-06-08 11:57:52 +020042 log ${S1_addr}:${S1_port} daemon
43 option httpchk
PiBa-NLc3949d42018-12-23 21:06:31 +010044 option log-health-checks
45
Christopher Faulet52912572022-06-08 11:57:52 +020046 default-server inter 200ms downinter 100ms rise 1 fall 1
47
PiBa-NLc3949d42018-12-23 21:06:31 +010048 email-alert mailers mymailers
49 email-alert level info
50 email-alert from from@domain.tld
51 email-alert to to@domain.tld
52
Christopher Faulet52912572022-06-08 11:57:52 +020053 server srv1 ${h1_lisrv_addr}:${h1_lisrv_port} check
PiBa-NLc3949d42018-12-23 21:06:31 +010054
55 mailers mymailers
Christopher Faulet52912572022-06-08 11:57:52 +020056 mailer smtp1 ${h1_lismtp_addr}:${h1_lismtp_port}
PiBa-NLc3949d42018-12-23 21:06:31 +010057
58} -start
59
Christopher Faulet52912572022-06-08 11:57:52 +020060syslog S1 -wait