blob: a67e4bc00b63e06bc3e93ab925d37202b4d06d35 [file] [log] [blame]
William Lallemand039cc082021-09-24 19:02:50 +02001varnishtest "Lua: check httpclient functionality from a lua-task"
William Lallemand207f0cb2021-10-28 15:57:33 +02002
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 Lallemand039cc082021-09-24 19:02:50 +020010feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev7)'"
11feature ignore_unknown_macro
12
13#REQUIRE_OPTIONS=LUA
14
15server s1 {
16 rxreq
William Lallemand207f0cb2021-10-28 15:57:33 +020017 txresp -bodylen 200
18 expect req.body ~ ".*2000 ABCDEFGHIJKLMNOPQRSTUVWXYZ"
William Lallemand039cc082021-09-24 19:02:50 +020019} -start
20
William Lallemand207f0cb2021-10-28 15:57:33 +020021server s2 {
22 rxreq
23 txresp
24 expect req.bodylen == 200
25} -start
26
William Lallemand039cc082021-09-24 19:02:50 +020027haproxy h1 -conf {
28 global
29 lua-load ${testdir}/lua_httpclient.lua
30
31 frontend fe1
32 mode http
33 bind "fd@${fe1}"
34 default_backend b1
35
36 backend b1
37 mode http
38 http-request use-service lua.fakeserv
39
40} -start
41
42client c0 -connect ${h1_fe1_sock} {
William Lallemand207f0cb2021-10-28 15:57:33 +020043 txreq -url "/" -hdr "vtcport: ${s1_port}" -hdr "vtcport2: ${s2_port}"
William Lallemand039cc082021-09-24 19:02:50 +020044 rxresp
45 expect resp.status == 200
46} -run
47
48
49server s1 -wait
William Lallemand207f0cb2021-10-28 15:57:33 +020050server s2 -wait