From: Frédéric Lécaille Date: Thu, 23 Aug 2018 16:06:35 +0000 (+0200) Subject: REGEST/MINOR: Add reg testing files. X-Git-Tag: v1.9-dev2~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b083c8316b82b000b0fae6abad835b8003e9f08f;p=thirdparty%2Fhaproxy.git REGEST/MINOR: Add reg testing files. Reg testing files for a LUA bug fixed by commit 83ed5d5 ("BUG/MINOR: lua: Bad HTTP client request duration.") --- diff --git a/reg-tests/lua/b00001.lua b/reg-tests/lua/b00001.lua new file mode 100644 index 0000000000..2c2ab1dca8 --- /dev/null +++ b/reg-tests/lua/b00001.lua @@ -0,0 +1,8 @@ +core.register_service("foo.http", "http", function(applet) + core.msleep(10) + applet:start_response() +end) + +core.register_service("foo.tcp", "tcp", function(applet) + applet:send("HTTP/1.1 200 OK\r\nTransfer-encoding: chunked\r\n\r\n0\r\n\r\n") +end) diff --git a/reg-tests/lua/b00001.vtc b/reg-tests/lua/b00001.vtc new file mode 100644 index 0000000000..a7a2d6991d --- /dev/null +++ b/reg-tests/lua/b00001.vtc @@ -0,0 +1,80 @@ +# commit 7b6cc52784526c32efda44b873a4258d3ae0b8c7 +# BUG/MINOR: lua: Bad HTTP client request duration. +# +# HTTP LUA applet callback should not update the date on which the HTTP client requests +# arrive. This was done just after the LUA applet has completed its job. +# +# This patch simply removes the affected statement. The same fixe has been applied +# to TCP LUA applet callback. +# +# To reproduce this issue, as reported by Patrick Hemmer, implement an HTTP LUA applet +# which sleeps a bit before replying: +# +# core.register_service("foo", "http", function(applet) +# core.msleep(100) +# applet:set_status(200) +# applet:start_response() +# end) +# +# This had as a consequence to log %TR field with approximatively the same value as +# the LUA sleep time. + +varnishtest "LUA bug" + +feature ignore_unknown_macro + +syslog Slog { + recv notice + expect ~ "haproxy\\[[0-9]*\\]: Proxy f1 started" + + recv notice + expect ~ "haproxy\\[[0-9]*\\]: Proxy f2 started" + + recv info + expect ~ "haproxy\\[[0-9]*\\]: Ta=[0-9]* Tc=[0-9]* Td=[0-9]* Th=[0-9]* Ti=[0-9]* Tq=[0-9]* TR=[0-9]* Tr=[0-9]* Tt=[0-9]* Tw=[0-9]*$" + + recv info + expect ~ "haproxy\\[[0-9]*\\]: Tc=[0-9]* Td=[0-9]* Th=[0-9]* Tt=[0-9]* Tw=[0-9]*$" +} -start + +haproxy h1 -conf { + global + lua-load ${testdir}/b00001.lua + + defaults + timeout client 1s + timeout server 1s + timeout connect 1s + + frontend f1 + mode http + bind "fd@${f1}" + log ${Slog_addr}:${Slog_port} daemon + log-format Ta=%Ta\ Tc=%Tc\ Td=%Td\ Th=%Th\ Ti=%Ti\ Tq=%Tq\ TR=%TR\ Tr=%Tr\ Tt=%Tt\ Tw=%Tw + default_backend b1 + + backend b1 + mode http + http-request use-service lua.foo.http + + frontend f2 + mode tcp + bind "fd@${f2}" + log ${Slog_addr}:${Slog_port} daemon + log-format Tc=%Tc\ Td=%Td\ Th=%Th\ Tt=%Tt\ Tw=%Tw + + tcp-request inspect-delay 1s + tcp-request content use-service lua.foo.tcp +} -start + +client c1 -connect "${h1_f1_sock}" { + txreq + rxresp +} -run + +client c2 -connect "${h1_f2_sock}" { + txreq + rxresp +} -run + +syslog Slog -wait