blob: d36a0d37ca735d272388946f4693a18f7a893b14 [file] [log] [blame]
Christopher Faulet1d93aae2022-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 Faulet1d93aae2022-06-08 11:57:52 +02006syslog S1 -level notice {
7 recv
Christopher Faulet91c3baa2022-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 Faulet1d93aae2022-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
Frédéric Lécailleb894f922019-03-29 16:13:48 +010015 lua-load ${testdir}/healthcheckmail.lua
Christopher Faulet1d93aae2022-06-08 11:57:52 +020016
17 defaults
18 timeout client 1s
19 timeout server 1s
20 timeout connect 1s
21
22 listen lisrv
PiBa-NLc3949d42018-12-23 21:06:31 +010023 mode tcp
Christopher Faulet1d93aae2022-06-08 11:57:52 +020024 bind "fd@${lisrv}"
25 tcp-request connection reject
PiBa-NLc3949d42018-12-23 21:06:31 +010026
Christopher Faulet1d93aae2022-06-08 11:57:52 +020027 listen lismtp
28 mode tcp
29 bind "fd@${lismtp}"
30 log ${S1_addr}:${S1_port} daemon
31 log-format "Result=%[var(txn.result)] Bytes=%B"
32 tcp-request content use-service lua.mailservice
PiBa-NLc3949d42018-12-23 21:06:31 +010033
34 frontend fe1
35 mode http
36 bind "fd@${fe1}"
Christopher Faulet1d93aae2022-06-08 11:57:52 +020037 default_backend be1
PiBa-NLc3949d42018-12-23 21:06:31 +010038
Christopher Faulet1d93aae2022-06-08 11:57:52 +020039 backend be1
PiBa-NLc3949d42018-12-23 21:06:31 +010040 mode http
Christopher Faulet1d93aae2022-06-08 11:57:52 +020041 log ${S1_addr}:${S1_port} daemon
42 option httpchk
PiBa-NLc3949d42018-12-23 21:06:31 +010043 option log-health-checks
44
Christopher Faulet1d93aae2022-06-08 11:57:52 +020045 default-server inter 200ms downinter 100ms rise 1 fall 1
46
PiBa-NLc3949d42018-12-23 21:06:31 +010047 email-alert mailers mymailers
48 email-alert level info
49 email-alert from from@domain.tld
50 email-alert to to@domain.tld
51
Christopher Faulet1d93aae2022-06-08 11:57:52 +020052 server srv1 ${h1_lisrv_addr}:${h1_lisrv_port} check
PiBa-NLc3949d42018-12-23 21:06:31 +010053
54 mailers mymailers
Christopher Faulet1d93aae2022-06-08 11:57:52 +020055 mailer smtp1 ${h1_lismtp_addr}:${h1_lismtp_port}
PiBa-NLc3949d42018-12-23 21:06:31 +010056
57} -start
58
Christopher Faulet1d93aae2022-06-08 11:57:52 +020059syslog S1 -wait