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 |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 69 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded.*code: 200" |
| 70 | } -start |
| 71 | |
| 72 | syslog S2 -level notice { |
| 73 | recv |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 74 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be2/srv succeeded.*code: 200" |
| 75 | } -start |
| 76 | |
| 77 | syslog S3 -level notice { |
| 78 | recv |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 79 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be3/srv succeeded.*code: 200" |
| 80 | } -start |
| 81 | |
| 82 | syslog S4 -level notice { |
| 83 | recv |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 84 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be4/srv succeeded.*code: 200" |
| 85 | } -start |
| 86 | |
| 87 | syslog S5 -level notice { |
| 88 | recv |
Christopher Faulet | 8acb128 | 2020-04-09 08:44:06 +0200 | [diff] [blame] | 89 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be5/srv succeeded.*code: 200" |
| 90 | } -start |
| 91 | |
| 92 | |
| 93 | haproxy h1 -conf { |
| 94 | defaults |
| 95 | mode http |
| 96 | timeout client 1s |
| 97 | timeout server 1s |
| 98 | timeout connect 200ms |
| 99 | option httpchk |
| 100 | option log-health-checks |
| 101 | |
| 102 | backend be1 |
| 103 | log ${S1_addr}:${S1_port} len 2048 local0 |
| 104 | server srv ${s1_addr}:${s1_port} check inter 200ms rise 1 fall 1 |
| 105 | |
| 106 | backend be2 |
| 107 | log ${S2_addr}:${S2_port} len 2048 local0 |
| 108 | option httpchk GET /test HTTP/1.1 |
| 109 | server srv ${s2_addr}:${s2_port} check inter 200ms rise 1 fall 1 |
| 110 | |
| 111 | defaults |
| 112 | mode http |
| 113 | timeout client 1s |
| 114 | timeout server 1s |
| 115 | timeout connect 200ms |
| 116 | option httpchk GET /status HTTP/1.1\r\nHdr:\ must-be-removed |
| 117 | option log-health-checks |
| 118 | http-check send hdr Host "my-www-host" hdr X-test true body "test" |
| 119 | |
| 120 | backend be3 |
| 121 | option httpchk |
| 122 | log ${S3_addr}:${S3_port} len 2048 local0 |
| 123 | server srv ${s3_addr}:${s3_port} check inter 200ms rise 1 fall 1 |
| 124 | |
| 125 | backend be4 |
| 126 | log ${S4_addr}:${S4_port} len 2048 local0 |
| 127 | server srv ${s4_addr}:${s4_port} check inter 200ms rise 1 fall 1 |
| 128 | |
| 129 | backend be5 |
| 130 | log ${S5_addr}:${S5_port} len 2058 local0 |
| 131 | http-check send hdr Host "other-www-host" hdr X-New-Test true body "other test" |
| 132 | server srv ${s5_addr}:${s5_port} check inter 200ms rise 1 fall 1 |
| 133 | |
| 134 | } -start |
| 135 | |
| 136 | syslog S1 -wait |
| 137 | syslog S2 -wait |
| 138 | syslog S3 -wait |
| 139 | syslog S4 -wait |
| 140 | syslog S5 -wait |