haproxy/reg-tests/lua/bad_http_clt_req_duration.vtc
Aurelien DARRAGON 29b6d8af16 MINOR: hlua: rename "tune.lua.preserve-smp-bool" to "tune.lua.bool-sample-conversion"
A better name was found for the option implemented in ec74438
("MINOR: hlua: add option to preserve bool type from smp to lua")

Indeed, "tune.lua.preserve-smp-bool {on | off}" wasn't explicit enough
nor did it encourage the adoption of the new "fixed" behavior (vs
historical behavior which is now considered as a bug).

Thus it becomes "tune.lua.bool-sample-conversion { normal | pre-3.1-bug }"
which actively encourage users to switch the new behavior after having
patched in-use Lua script if needed. From a technical point of view,
the logic remains the same, as the option currently defaults to
"pre-3.1-bug" to prevent script breakage, and a warning is emitted if
the option isn't set explicily and Lua is used.

Documentation and regtests were updated.

Must be backported in 3.1 with ec74438 and f2838f5 ("REGTESTS: fix
lua-based regtests using tune.lua.smp-preserve-bool")
2024-12-20 17:34:05 +01:00

78 lines
2.1 KiB
Plaintext

# 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 fix 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 approximately the same value as
# the LUA sleep time.
varnishtest "LUA bug"
#REQUIRE_OPTIONS=LUA
#REGTEST_TYPE=bug
feature ignore_unknown_macro
syslog Slog {
recv info
expect ~ "[^:\\[ ]\\[[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 ~ "[^:\\[ ]\\[[0-9]*\\]: Tc=[0-9]* Td=[0-9]* Th=[0-9]* Tt=[0-9]* Tw=[0-9]*$"
} -start
haproxy h1 -conf {
global
tune.lua.bool-sample-conversion normal
lua-load ${testdir}/bad_http_clt_req_duration.lua
defaults
timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
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