blob: 9d8bb8a887e10c572ac05af497400ad09874d188 [file] [log] [blame]
Christopher Fauletaec7f762020-04-22 15:16:58 +02001varnishtest "Health-checks: SMTP health-check"
2#REQUIRE_VERSION=2.2
3#REGTEST_TYPE=slow
4feature ignore_unknown_macro
5
6# This scripts tests health-checks for SMTP servers, enabled using
7# "option smtpchk" line.
8
9server s1 {
10 send "220 smtp-check.vtc SMTP Server\r\n"
11 recv 16
12 send "250 smtp-check.vtc\r\n"
wrightlawd67b10f2022-09-08 16:10:48 +010013 recv 6
14 send "221 smtp-check.vtc closing\r\n"
Christopher Fauletaec7f762020-04-22 15:16:58 +020015} -start
16
17server s2 {
18 send "220 smtp-check.vtc SMTP Server\r\n"
19 recv 17
20 send "250-smtp-check.vtc\r\n"
21 send "250-KEYWORD\r\n"
22 send "250 LAST KEYWORD\r\n"
wrightlawd67b10f2022-09-08 16:10:48 +010023 recv 6
24 send "221 smtp-check.vtc closing\r\n"
Christopher Fauletaec7f762020-04-22 15:16:58 +020025} -start
26
27server s3 {
28 send "I'm not a SMTP server\r\n"
29} -start
30
31server s4 {
32 send "421 Try again later\r\n"
33} -start
34
35server s5 {
36 send "220 smtp-check.vtc SMTP Server\r\n"
37 recv 16
38 send "512 DNS error\r\n"
39} -start
40
41syslog S1 -level notice {
42 recv
wrightlawd67b10f2022-09-08 16:10:48 +010043 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded, reason: Layer7 check passed.+code: 221.+info: \"smtp-check.vtc closing\".+check duration: [[:digit:]]+ms, status: 1/1 UP."
Christopher Fauletaec7f762020-04-22 15:16:58 +020044} -start
45
46syslog S2 -level notice {
47 recv
wrightlawd67b10f2022-09-08 16:10:48 +010048 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be2/srv succeeded, reason: Layer7 check passed.+code: 221.+info: \"smtp-check.vtc closing\".+check duration: [[:digit:]]+ms, status: 1/1 UP."
Christopher Fauletaec7f762020-04-22 15:16:58 +020049} -start
50
51syslog S3 -level notice {
52 recv
Christopher Fauletaec7f762020-04-22 15:16:58 +020053 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be3/srv failed, reason: Layer7 invalid response.+info: \"I'm not a SMTP server\".+check duration: [[:digit:]]+ms, status: 0/1 DOWN."
54} -start
55
56syslog S4 -level notice {
57 recv
Christopher Fauletaec7f762020-04-22 15:16:58 +020058 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be4/srv failed, reason: Layer7 wrong status.+code: 421.+info: \"Try again later\".+check duration: [[:digit:]]+ms, status: 0/1 DOWN."
59} -start
60
61syslog S5 -level notice {
62 recv
Christopher Fauletaec7f762020-04-22 15:16:58 +020063 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be5/srv failed, reason: Layer7 wrong status.+code: 512.+info: \"DNS error\".+check duration: [[:digit:]]+ms, status: 0/1 DOWN."
64} -start
65
66
67haproxy h1 -conf {
68 defaults
69 mode tcp
70 timeout client 1s
71 timeout server 1s
72 timeout connect 100ms
73
74 backend be1
75 log ${S1_addr}:${S1_port} daemon
76 option log-health-checks
77 option smtpchk
78 server srv ${s1_addr}:${s1_port} check inter 1s rise 1 fall 1
79
80 backend be2
81 log ${S2_addr}:${S2_port} daemon
82 option log-health-checks
83 option smtpchk EHLO domain.tld
84 server srv ${s2_addr}:${s2_port} check inter 1s rise 1 fall 1
85
86 backend be3
87 log ${S3_addr}:${S3_port} daemon
88 option log-health-checks
89 option smtpchk
90 server srv ${s3_addr}:${s3_port} check inter 1s rise 1 fall 1
91
92 backend be4
93 log ${S4_addr}:${S4_port} daemon
94 option log-health-checks
95 option smtpchk
96 server srv ${s4_addr}:${s4_port} check inter 1s rise 1 fall 1
97
98 backend be5
99 log ${S5_addr}:${S5_port} daemon
100 option log-health-checks
101 option smtpchk EHLO domain.tld
102 server srv ${s5_addr}:${s5_port} check inter 1s rise 1 fall 1
103
104} -start
105
106syslog S1 -wait
107syslog S2 -wait
108syslog S3 -wait
109syslog S4 -wait
110syslog S5 -wait