William Lallemand | 039cc08 | 2021-09-24 19:02:50 +0200 | [diff] [blame] | 1 | varnishtest "Lua: check httpclient functionality from a lua-task" |
William Lallemand | 207f0cb | 2021-10-28 15:57:33 +0200 | [diff] [blame] | 2 | |
| 3 | # A request if first made with c0 with the port of s1 and s2 so the httpclient |
| 4 | # can generate its URI with it. |
| 5 | # |
| 6 | # This reg-test sends a payload with the httpclient to s1, s1 returns another |
| 7 | # payload. The 2nd lua httpclient sends back the payload from s1 to s2. |
| 8 | # |
| 9 | |
William Lallemand | 039cc08 | 2021-09-24 19:02:50 +0200 | [diff] [blame] | 10 | feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev7)'" |
| 11 | feature ignore_unknown_macro |
| 12 | |
| 13 | #REQUIRE_OPTIONS=LUA |
| 14 | |
| 15 | server s1 { |
| 16 | rxreq |
William Lallemand | d19d776 | 2021-11-10 17:40:19 +0100 | [diff] [blame] | 17 | txresp -bodylen 54000 |
| 18 | expect req.body ~ ".*0 ABCDEFGHIJKLMNOPQRSTUVWXYZ.*" |
| 19 | expect req.body ~ ".*500 ABCDEFGHIJKLMNOPQRSTUVWXYZ.*" |
| 20 | expect req.body ~ ".*1000 ABCDEFGHIJKLMNOPQRSTUVWXYZ.*" |
| 21 | expect req.body ~ ".*1500 ABCDEFGHIJKLMNOPQRSTUVWXYZ.*" |
William Lallemand | 207f0cb | 2021-10-28 15:57:33 +0200 | [diff] [blame] | 22 | expect req.body ~ ".*2000 ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
William Lallemand | 039cc08 | 2021-09-24 19:02:50 +0200 | [diff] [blame] | 23 | } -start |
| 24 | |
William Lallemand | 207f0cb | 2021-10-28 15:57:33 +0200 | [diff] [blame] | 25 | server s2 { |
| 26 | rxreq |
| 27 | txresp |
William Lallemand | d19d776 | 2021-11-10 17:40:19 +0100 | [diff] [blame] | 28 | expect req.bodylen == 54000 |
William Lallemand | 207f0cb | 2021-10-28 15:57:33 +0200 | [diff] [blame] | 29 | } -start |
| 30 | |
William Lallemand | f03b53c | 2021-11-24 15:38:17 +0100 | [diff] [blame] | 31 | server s3 { |
| 32 | rxreq |
| 33 | txresp -bodylen 54000 |
| 34 | expect req.method == "GET" |
| 35 | expect req.http.host == "foobar.haproxy.local" |
| 36 | } -start |
| 37 | |
| 38 | |
William Lallemand | 039cc08 | 2021-09-24 19:02:50 +0200 | [diff] [blame] | 39 | haproxy h1 -conf { |
| 40 | global |
| 41 | lua-load ${testdir}/lua_httpclient.lua |
| 42 | |
| 43 | frontend fe1 |
| 44 | mode http |
| 45 | bind "fd@${fe1}" |
| 46 | default_backend b1 |
| 47 | |
| 48 | backend b1 |
| 49 | mode http |
| 50 | http-request use-service lua.fakeserv |
| 51 | |
William Lallemand | 4f4f2b7 | 2022-02-17 20:00:23 +0100 | [diff] [blame] | 52 | listen li1 |
| 53 | mode http |
| 54 | bind unix@${testdir}/srv3 |
| 55 | server srv3 ${s3_addr}:${s3_port} |
| 56 | |
William Lallemand | 039cc08 | 2021-09-24 19:02:50 +0200 | [diff] [blame] | 57 | } -start |
| 58 | |
| 59 | client c0 -connect ${h1_fe1_sock} { |
William Lallemand | 4f4f2b7 | 2022-02-17 20:00:23 +0100 | [diff] [blame] | 60 | txreq -url "/" -hdr "vtcport: ${s1_port}" -hdr "vtcport2: ${s2_port}" -hdr "vtcport3: unix@${testdir}/srv3" |
William Lallemand | 039cc08 | 2021-09-24 19:02:50 +0200 | [diff] [blame] | 61 | rxresp |
| 62 | expect resp.status == 200 |
| 63 | } -run |
| 64 | |
| 65 | |
| 66 | server s1 -wait |
William Lallemand | 207f0cb | 2021-10-28 15:57:33 +0200 | [diff] [blame] | 67 | server s2 -wait |
William Lallemand | f03b53c | 2021-11-24 15:38:17 +0100 | [diff] [blame] | 68 | server s3 -wait |