Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 1 | varnishtest "Health-checks: SMTP health-check" |
| 2 | #REQUIRE_VERSION=2.2 |
| 3 | #REGTEST_TYPE=slow |
| 4 | feature ignore_unknown_macro |
| 5 | |
| 6 | # This scripts tests health-checks for SMTP servers, enabled using |
| 7 | # "option smtpchk" line. |
| 8 | |
| 9 | server s1 { |
| 10 | send "220 smtp-check.vtc SMTP Server\r\n" |
| 11 | recv 16 |
| 12 | send "250 smtp-check.vtc\r\n" |
wrightlaw | d67b10f | 2022-09-08 16:10:48 +0100 | [diff] [blame^] | 13 | recv 6 |
| 14 | send "221 smtp-check.vtc closing\r\n" |
Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 15 | } -start |
| 16 | |
| 17 | server 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" |
wrightlaw | d67b10f | 2022-09-08 16:10:48 +0100 | [diff] [blame^] | 23 | recv 6 |
| 24 | send "221 smtp-check.vtc closing\r\n" |
Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 25 | } -start |
| 26 | |
| 27 | server s3 { |
| 28 | send "I'm not a SMTP server\r\n" |
| 29 | } -start |
| 30 | |
| 31 | server s4 { |
| 32 | send "421 Try again later\r\n" |
| 33 | } -start |
| 34 | |
| 35 | server s5 { |
| 36 | send "220 smtp-check.vtc SMTP Server\r\n" |
| 37 | recv 16 |
| 38 | send "512 DNS error\r\n" |
| 39 | } -start |
| 40 | |
| 41 | syslog S1 -level notice { |
| 42 | recv |
wrightlaw | d67b10f | 2022-09-08 16:10:48 +0100 | [diff] [blame^] | 43 | 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 Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 44 | } -start |
| 45 | |
| 46 | syslog S2 -level notice { |
| 47 | recv |
wrightlaw | d67b10f | 2022-09-08 16:10:48 +0100 | [diff] [blame^] | 48 | 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 Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 49 | } -start |
| 50 | |
| 51 | syslog S3 -level notice { |
| 52 | recv |
Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 53 | 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 | |
| 56 | syslog S4 -level notice { |
| 57 | recv |
Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 58 | 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 | |
| 61 | syslog S5 -level notice { |
| 62 | recv |
Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 63 | 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 | |
| 67 | haproxy 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 | |
| 106 | syslog S1 -wait |
| 107 | syslog S2 -wait |
| 108 | syslog S3 -wait |
| 109 | syslog S4 -wait |
| 110 | syslog S5 -wait |