Christopher Faulet | f717727 | 2020-10-02 13:41:55 +0200 | [diff] [blame] | 1 | varnishtest "Health-checks: basic HTTP health-check though a socks4 proxy" |
| 2 | #REQUIRE_VERSION=2.0 |
| 3 | #REGTEST_TYPE=slow |
| 4 | feature ignore_unknown_macro |
| 5 | |
| 6 | # This scripts tests a simple HTTP health-checks though a socks4 proxy. |
| 7 | |
| 8 | server s1 { |
| 9 | } -start |
| 10 | |
| 11 | server socks { |
| 12 | ## get socks4 request |
| 13 | recv 16 |
| 14 | |
| 15 | ## send socks4 response : |
| 16 | ## constant(1): 0x00 |
| 17 | ## statut(1) : 0x5a (success) |
| 18 | ## padding(6) : ignored |
| 19 | sendhex "005A000000000000" |
| 20 | |
| 21 | rxreq |
| 22 | expect req.method == OPTIONS |
| 23 | expect req.url == / |
| 24 | expect req.proto == HTTP/1.0 |
| 25 | txresp |
| 26 | } -start |
| 27 | |
| 28 | syslog S1 -level notice { |
| 29 | recv |
Christopher Faulet | f717727 | 2020-10-02 13:41:55 +0200 | [diff] [blame] | 30 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded, reason: Layer7 check passed.+code: 200.+check duration: [[:digit:]]+ms, status: 1/1 UP." |
| 31 | } -start |
| 32 | |
| 33 | haproxy h1 -conf { |
| 34 | defaults |
| 35 | mode tcp |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 36 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 37 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
| 38 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
Christopher Faulet | f717727 | 2020-10-02 13:41:55 +0200 | [diff] [blame] | 39 | |
| 40 | backend be1 |
| 41 | log ${S1_addr}:${S1_port} daemon |
| 42 | option log-health-checks |
| 43 | option httpchk |
| 44 | server srv ${s1_addr}:${s1_port} socks4 ${h1_socks_addr}:${h1_socks_port} check-via-socks4 check inter 1s rise 1 fall 1 |
| 45 | |
| 46 | listen socks |
| 47 | bind "fd@${socks}" |
| 48 | tcp-request inspect-delay 500ms |
| 49 | ## Accept socks4 request on 16 bytes : |
| 50 | ## version(1) : 0x04 |
| 51 | ## command(1) : 0x01 |
| 52 | ## port(2) : ${s1_port} |
| 53 | ## addr(4) : ${s1_addr} |
| 54 | ## user-id : "HAProxy\0" |
| 55 | tcp-request content accept if { req.len eq 16 } { req.payload(0,1) -m bin "04" } { req.payload(1,1) -m bin "01" } { req.payload(2,2),hex,hex2i eq ${s1_port} } { req.payload(4,4),hex,hex2i -m ip ${s1_addr} } { req.payload(8,8) -m bin "484150726F787900" } |
| 56 | tcp-request content reject |
| 57 | server srv ${socks_addr}:${socks_port} |
| 58 | |
| 59 | } -start |
| 60 | |
| 61 | syslog S1 -wait |