blob: 29d0ddbb8ce1836101d19d251da2814ea5b62dc6 [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"
13} -start
14
15server s2 {
16 send "220 smtp-check.vtc SMTP Server\r\n"
17 recv 17
18 send "250-smtp-check.vtc\r\n"
19 send "250-KEYWORD\r\n"
20 send "250 LAST KEYWORD\r\n"
21} -start
22
23server s3 {
24 send "I'm not a SMTP server\r\n"
25} -start
26
27server s4 {
28 send "421 Try again later\r\n"
29} -start
30
31server s5 {
32 send "220 smtp-check.vtc SMTP Server\r\n"
33 recv 16
34 send "512 DNS error\r\n"
35} -start
36
37syslog S1 -level notice {
38 recv
Christopher Fauletaec7f762020-04-22 15:16:58 +020039 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded, reason: Layer7 check passed.+code: 250.+info: \"smtp-check.vtc\".+check duration: [[:digit:]]+ms, status: 1/1 UP."
40} -start
41
42syslog S2 -level notice {
43 recv
Christopher Fauletaec7f762020-04-22 15:16:58 +020044 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be2/srv succeeded, reason: Layer7 check passed.+code: 250.+info: \"smtp-check.vtc\".+check duration: [[:digit:]]+ms, status: 1/1 UP."
45} -start
46
47syslog S3 -level notice {
48 recv
Christopher Fauletaec7f762020-04-22 15:16:58 +020049 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."
50} -start
51
52syslog S4 -level notice {
53 recv
Christopher Fauletaec7f762020-04-22 15:16:58 +020054 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."
55} -start
56
57syslog S5 -level notice {
58 recv
Christopher Fauletaec7f762020-04-22 15:16:58 +020059 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."
60} -start
61
62
63haproxy h1 -conf {
64 defaults
65 mode tcp
66 timeout client 1s
67 timeout server 1s
68 timeout connect 100ms
69
70 backend be1
71 log ${S1_addr}:${S1_port} daemon
72 option log-health-checks
73 option smtpchk
74 server srv ${s1_addr}:${s1_port} check inter 1s rise 1 fall 1
75
76 backend be2
77 log ${S2_addr}:${S2_port} daemon
78 option log-health-checks
79 option smtpchk EHLO domain.tld
80 server srv ${s2_addr}:${s2_port} check inter 1s rise 1 fall 1
81
82 backend be3
83 log ${S3_addr}:${S3_port} daemon
84 option log-health-checks
85 option smtpchk
86 server srv ${s3_addr}:${s3_port} check inter 1s rise 1 fall 1
87
88 backend be4
89 log ${S4_addr}:${S4_port} daemon
90 option log-health-checks
91 option smtpchk
92 server srv ${s4_addr}:${s4_port} check inter 1s rise 1 fall 1
93
94 backend be5
95 log ${S5_addr}:${S5_port} daemon
96 option log-health-checks
97 option smtpchk EHLO domain.tld
98 server srv ${s5_addr}:${s5_port} check inter 1s rise 1 fall 1
99
100} -start
101
102syslog S1 -wait
103syslog S2 -wait
104syslog S3 -wait
105syslog S4 -wait
106syslog S5 -wait