Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 1 | varnishtest "Health-checks: http-check send test" |
Christopher Faulet | aec7f76 | 2020-04-22 15:16:58 +0200 | [diff] [blame] | 2 | #REGTEST_TYPE=slow |
Willy Tarreau | a0be859 | 2020-05-07 18:42:22 +0200 | [diff] [blame] | 3 | #REQUIRE_VERSION=2.2 |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 4 | feature ignore_unknown_macro |
| 5 | |
| 6 | # This script tests HTTP health-checks and more particularly the "http-check |
| 7 | # send" directive. |
| 8 | |
| 9 | server s1 { |
| 10 | rxreq |
| 11 | expect req.method == OPTIONS |
| 12 | expect req.url == / |
| 13 | expect req.proto == HTTP/1.0 |
| 14 | txresp |
| 15 | } -start |
| 16 | |
| 17 | server s2 { |
| 18 | rxreq |
| 19 | expect req.method == GET |
| 20 | expect req.url == /test |
| 21 | expect req.proto == HTTP/1.1 |
| 22 | txresp |
| 23 | } -start |
| 24 | |
| 25 | server s3 { |
| 26 | rxreq |
| 27 | expect req.method == OPTIONS |
| 28 | expect req.url == / |
| 29 | expect req.proto == HTTP/1.0 |
| 30 | expect req.http.hdr == <undef> |
| 31 | expect req.http.host == <undef> |
| 32 | expect req.http.x-test == <undef> |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 33 | expect req.bodylen == 0 |
| 34 | txresp |
| 35 | } -start |
| 36 | |
| 37 | server s4 { |
| 38 | rxreq |
| 39 | expect req.method == GET |
| 40 | expect req.url == /status |
| 41 | expect req.proto == HTTP/1.1 |
| 42 | expect req.http.hdr == <undef> |
| 43 | expect req.http.host == "my-www-host" |
| 44 | expect req.http.x-test == true |
| 45 | expect req.http.content-length == 4 |
| 46 | expect req.bodylen == 4 |
| 47 | expect req.body == "test" |
| 48 | txresp |
| 49 | } -start |
| 50 | |
| 51 | server s5 { |
| 52 | rxreq |
Christopher Faulet | a67ed43 | 2020-04-20 14:59:20 +0200 | [diff] [blame] | 53 | expect req.method == OPTIONS |
| 54 | expect req.url == / |
| 55 | expect req.proto == HTTP/1.0 |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 56 | expect req.http.hdr == <undef> |
| 57 | expect req.http.host == "other-www-host" |
| 58 | expect req.http.x-test == <undef> |
| 59 | expect req.http.x-new-test == true |
| 60 | expect req.http.content-length == 10 |
| 61 | expect req.bodylen == 10 |
| 62 | expect req.body == "other test" |
| 63 | txresp |
| 64 | } -start |
| 65 | |
| 66 | |
| 67 | syslog S1 -level notice { |
| 68 | recv |
| 69 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be1 started." |
| 70 | recv |
| 71 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded.*code: 200" |
| 72 | } -start |
| 73 | |
| 74 | syslog S2 -level notice { |
| 75 | recv |
| 76 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be2 started." |
| 77 | recv |
| 78 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be2/srv succeeded.*code: 200" |
| 79 | } -start |
| 80 | |
| 81 | syslog S3 -level notice { |
| 82 | recv |
| 83 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be3 started." |
| 84 | recv |
| 85 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be3/srv succeeded.*code: 200" |
| 86 | } -start |
| 87 | |
| 88 | syslog S4 -level notice { |
| 89 | recv |
| 90 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be4 started." |
| 91 | recv |
| 92 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be4/srv succeeded.*code: 200" |
| 93 | } -start |
| 94 | |
| 95 | syslog S5 -level notice { |
| 96 | recv |
| 97 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be5 started." |
| 98 | recv |
| 99 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be5/srv succeeded.*code: 200" |
| 100 | } -start |
| 101 | |
| 102 | |
| 103 | haproxy h1 -conf { |
| 104 | defaults |
| 105 | mode http |
| 106 | timeout client 1s |
| 107 | timeout server 1s |
| 108 | timeout connect 200ms |
| 109 | option httpchk |
| 110 | option log-health-checks |
| 111 | |
| 112 | backend be1 |
| 113 | log ${S1_addr}:${S1_port} len 2048 local0 |
| 114 | server srv ${s1_addr}:${s1_port} check inter 200ms rise 1 fall 1 |
| 115 | |
| 116 | backend be2 |
| 117 | log ${S2_addr}:${S2_port} len 2048 local0 |
| 118 | option httpchk GET /test HTTP/1.1 |
| 119 | server srv ${s2_addr}:${s2_port} check inter 200ms rise 1 fall 1 |
| 120 | |
| 121 | defaults |
| 122 | mode http |
| 123 | timeout client 1s |
| 124 | timeout server 1s |
| 125 | timeout connect 200ms |
| 126 | option httpchk GET /status HTTP/1.1\r\nHdr:\ must-be-removed |
| 127 | option log-health-checks |
| 128 | http-check send hdr Host "my-www-host" hdr X-test true body "test" |
| 129 | |
| 130 | backend be3 |
| 131 | option httpchk |
| 132 | log ${S3_addr}:${S3_port} len 2048 local0 |
| 133 | server srv ${s3_addr}:${s3_port} check inter 200ms rise 1 fall 1 |
| 134 | |
| 135 | backend be4 |
| 136 | log ${S4_addr}:${S4_port} len 2048 local0 |
| 137 | server srv ${s4_addr}:${s4_port} check inter 200ms rise 1 fall 1 |
| 138 | |
| 139 | backend be5 |
| 140 | log ${S5_addr}:${S5_port} len 2058 local0 |
| 141 | http-check send hdr Host "other-www-host" hdr X-New-Test true body "other test" |
| 142 | server srv ${s5_addr}:${s5_port} check inter 200ms rise 1 fall 1 |
| 143 | |
| 144 | } -start |
| 145 | |
| 146 | syslog S1 -wait |
| 147 | syslog S2 -wait |
| 148 | syslog S3 -wait |
| 149 | syslog S4 -wait |
| 150 | syslog S5 -wait |