blob: ab24b0c865d4cf1ac4e0438dd7d8709483f24e7e [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
39 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be1 started."
40 recv
41 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."
42} -start
43
44syslog S2 -level notice {
45 recv
46 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be2 started."
47 recv
48 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."
49} -start
50
51syslog S3 -level notice {
52 recv
53 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be3 started."
54 recv
55 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."
56} -start
57
58syslog S4 -level notice {
59 recv
60 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be4 started."
61 recv
62 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."
63} -start
64
65syslog S5 -level notice {
66 recv
67 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be5 started."
68 recv
69 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."
70} -start
71
72
73haproxy h1 -conf {
74 defaults
75 mode tcp
76 timeout client 1s
77 timeout server 1s
78 timeout connect 100ms
79
80 backend be1
81 log ${S1_addr}:${S1_port} daemon
82 option log-health-checks
83 option smtpchk
84 server srv ${s1_addr}:${s1_port} check inter 1s rise 1 fall 1
85
86 backend be2
87 log ${S2_addr}:${S2_port} daemon
88 option log-health-checks
89 option smtpchk EHLO domain.tld
90 server srv ${s2_addr}:${s2_port} check inter 1s rise 1 fall 1
91
92 backend be3
93 log ${S3_addr}:${S3_port} daemon
94 option log-health-checks
95 option smtpchk
96 server srv ${s3_addr}:${s3_port} check inter 1s rise 1 fall 1
97
98 backend be4
99 log ${S4_addr}:${S4_port} daemon
100 option log-health-checks
101 option smtpchk
102 server srv ${s4_addr}:${s4_port} check inter 1s rise 1 fall 1
103
104 backend be5
105 log ${S5_addr}:${S5_port} daemon
106 option log-health-checks
107 option smtpchk EHLO domain.tld
108 server srv ${s5_addr}:${s5_port} check inter 1s rise 1 fall 1
109
110} -start
111
112syslog S1 -wait
113syslog S2 -wait
114syslog S3 -wait
115syslog S4 -wait
116syslog S5 -wait