From 4ed0a3a88384a3836cbf162025df7ca41cc4fa5e Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Thu, 20 Oct 2022 11:23:02 +0200 Subject: [PATCH] REGTESTS: httpclient/lua: test the lua task timeout with the httpclient Test the httpclient when the lua action timeout. The lua timeout is reached before the httpclient is ended. This test that the httpclient are correctly cleaned when destroying the hlua context. Must be backported as far as 2.5. --- reg-tests/lua/httpclient_action.lua | 8 ++++++ reg-tests/lua/httpclient_action.vtc | 39 +++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 reg-tests/lua/httpclient_action.lua create mode 100644 reg-tests/lua/httpclient_action.vtc diff --git a/reg-tests/lua/httpclient_action.lua b/reg-tests/lua/httpclient_action.lua new file mode 100644 index 000000000..9a7209cab --- /dev/null +++ b/reg-tests/lua/httpclient_action.lua @@ -0,0 +1,8 @@ +function test() + local httpclient = core.httpclient() + local response = httpclient:get{url="http://127.0.0.1", headers={ [ "Host" ] = { "localhost" } }} + +end + + +core.register_action("test", {"tcp-req"}, test, 0) diff --git a/reg-tests/lua/httpclient_action.vtc b/reg-tests/lua/httpclient_action.vtc new file mode 100644 index 000000000..11c7d629b --- /dev/null +++ b/reg-tests/lua/httpclient_action.vtc @@ -0,0 +1,39 @@ +varnishtest "Lua: test the httpclient when the lua action timeout" +# +# Start an httpclient from "lua.test" whose lua task will expire before the +# httpclient is ended. + + +feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev7)'" +feature ignore_unknown_macro + +#REQUIRE_OPTIONS=LUA + +haproxy h1 -conf { + + global + lua-load ${testdir}/httpclient_action.lua + defaults + mode tcp + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout check 10s + + listen li1 + mode http + bind "fd@${fe1}" + tcp-request inspect-delay 10ms + tcp-request content lua.test + http-request return status 503 + +} -start + +client c0 -connect ${h1_fe1_sock} { + txreq + rxresp + expect resp.status == 503 +} -run +