Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 1 | varnishtest "Health-checks: SPOP health-check" |
| 2 | #REQUIRE_VERSION=2.2 |
| 3 | #REGTEST_TYPE=slow |
| 4 | feature ignore_unknown_macro |
| 5 | |
| 6 | # This scripts tests health-checks for SPOE agent, enabled using |
| 7 | # "option spop-check" line. A intermediate listener is used to validate |
| 8 | # the request because it is impossible with VTEST to read and match raw |
| 9 | # text. |
| 10 | |
| 11 | server s1 { |
| 12 | recv 82 |
| 13 | sendhex "00000036 65 00000001 0000 0776657273696F6E 0803322E30 0E6D61782D6672616D652D73697A65 03FCF0 060C6361706162696C6974696573 0800" |
| 14 | } -start |
| 15 | |
| 16 | server s2 { |
| 17 | recv 82 |
| 18 | sendhex "00000000" |
| 19 | } -start |
| 20 | |
| 21 | server s3 { |
| 22 | recv 82 |
| 23 | sendhex "00000007 65 00000000 0000" |
| 24 | } -start |
| 25 | |
| 26 | server s4 { |
| 27 | recv 82 |
| 28 | sendhex "00000014 65 00000001 0000 0776657273696F6E 0803312E30" |
| 29 | } -start |
| 30 | |
| 31 | syslog S1 -level notice { |
| 32 | recv |
| 33 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be1 started." |
| 34 | recv |
| 35 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded, reason: Layer7 check passed.+info: \"SPOA server is ok\".+check duration: [[:digit:]]+ms, status: 1/1 UP." |
| 36 | } -start |
| 37 | |
| 38 | syslog S2 -level notice { |
| 39 | recv |
| 40 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be2 started." |
| 41 | recv |
| 42 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be2/srv failed, reason: Layer7 invalid response.+info: \"invalid frame received\".+check duration: [[:digit:]]+ms, status: 0/1 DOWN." |
| 43 | } -start |
| 44 | |
| 45 | syslog S3 -level notice { |
| 46 | recv |
| 47 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be3 started." |
| 48 | recv |
| 49 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be3/srv failed, reason: Layer7 invalid response.+info: \"fragmentation not supported\".+check duration: [[:digit:]]+ms, status: 0/1 DOWN." |
| 50 | } -start |
| 51 | |
| 52 | syslog S4 -level notice { |
| 53 | recv |
| 54 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be4 started." |
| 55 | recv |
| 56 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be4/srv failed, reason: Layer7 invalid response.+info: \"unsupported version\".+check duration: [[:digit:]]+ms, status: 0/1 DOWN." |
| 57 | } -start |
| 58 | |
| 59 | haproxy h1 -conf { |
| 60 | defaults |
| 61 | mode tcp |
| 62 | timeout client 1s |
| 63 | timeout server 1s |
| 64 | timeout connect 100ms |
| 65 | |
| 66 | backend be1 |
| 67 | log ${S1_addr}:${S1_port} daemon |
| 68 | option log-health-checks |
| 69 | option spop-check |
| 70 | server srv ${h1_spop1_addr}:${h1_spop1_port} check inter 1s rise 1 fall 1 |
| 71 | |
| 72 | backend be2 |
| 73 | log ${S2_addr}:${S2_port} daemon |
| 74 | option log-health-checks |
| 75 | option spop-check |
| 76 | server srv ${s2_addr}:${s2_port} check inter 1s rise 1 fall 1 |
| 77 | |
| 78 | backend be3 |
| 79 | log ${S3_addr}:${S3_port} daemon |
| 80 | option log-health-checks |
| 81 | option spop-check |
| 82 | server srv ${s3_addr}:${s3_port} check inter 1s rise 1 fall 1 |
| 83 | |
| 84 | backend be4 |
| 85 | log ${S4_addr}:${S4_port} daemon |
| 86 | option log-health-checks |
| 87 | option spop-check |
| 88 | server srv ${s4_addr}:${s4_port} check inter 1s rise 1 fall 1 |
| 89 | |
| 90 | listen spop1 |
| 91 | bind "fd@${spop1}" |
| 92 | tcp-request inspect-delay 100ms |
| 93 | tcp-request content accept if { req.len eq 82 } { req.payload(0,4) -m bin "0000004E" } #{ req.payload(4,4) -m bin "00000001" } { req.payload(8,2) -m bin "0000" } { req.payload(12,17) -m str "supported-version" } |
| 94 | tcp-request content reject |
| 95 | server srv ${s1_addr}:${s1_port} |
| 96 | |
| 97 | } -start |
| 98 | |
| 99 | syslog S1 -wait |
| 100 | syslog S2 -wait |
| 101 | syslog S3 -wait |
| 102 | syslog S4 -wait |