blob: 9d53cfe2381da9d251c26e98066439154a1a7ed4 [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 Lallemandd19d7762021-11-10 17:40:19 +010017 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 Lallemand207f0cb2021-10-28 15:57:33 +020022 expect req.body ~ ".*2000 ABCDEFGHIJKLMNOPQRSTUVWXYZ"
William Lallemand039cc082021-09-24 19:02:50 +020023} -start
24
William Lallemand207f0cb2021-10-28 15:57:33 +020025server s2 {
26 rxreq
27 txresp
William Lallemandd19d7762021-11-10 17:40:19 +010028 expect req.bodylen == 54000
William Lallemand207f0cb2021-10-28 15:57:33 +020029} -start
30
William Lallemand039cc082021-09-24 19:02:50 +020031haproxy h1 -conf {
32 global
33 lua-load ${testdir}/lua_httpclient.lua
34
35 frontend fe1
36 mode http
37 bind "fd@${fe1}"
38 default_backend b1
39
40 backend b1
41 mode http
42 http-request use-service lua.fakeserv
43
44} -start
45
46client c0 -connect ${h1_fe1_sock} {
William Lallemand207f0cb2021-10-28 15:57:33 +020047 txreq -url "/" -hdr "vtcport: ${s1_port}" -hdr "vtcport2: ${s2_port}"
William Lallemand039cc082021-09-24 19:02:50 +020048 rxresp
49 expect resp.status == 200
50} -run
51
52
53server s1 -wait
William Lallemand207f0cb2021-10-28 15:57:33 +020054server s2 -wait