blob: 4c39e95ed7e838747e88e4382830f35625a915b4 [file] [log] [blame]
Frédéric Lécailleb083c832018-08-23 18:06:35 +02001# commit 7b6cc52784526c32efda44b873a4258d3ae0b8c7
2# BUG/MINOR: lua: Bad HTTP client request duration.
3#
4# HTTP LUA applet callback should not update the date on which the HTTP client requests
5# arrive. This was done just after the LUA applet has completed its job.
6#
7# This patch simply removes the affected statement. The same fixe has been applied
8# to TCP LUA applet callback.
9#
10# To reproduce this issue, as reported by Patrick Hemmer, implement an HTTP LUA applet
11# which sleeps a bit before replying:
12#
13# core.register_service("foo", "http", function(applet)
14# core.msleep(100)
15# applet:set_status(200)
16# applet:start_response()
17# end)
18#
19# This had as a consequence to log %TR field with approximatively the same value as
20# the LUA sleep time.
21
22varnishtest "LUA bug"
Christopher Fauletfdafd9a2018-12-19 11:50:17 +010023#REQUIRE_OPTIONS=LUA
Frédéric Lécailleb083c832018-08-23 18:06:35 +020024
25feature ignore_unknown_macro
26
27syslog Slog {
28 recv notice
Willy Tarreau9c27ea02018-11-16 15:54:23 +010029 expect ~ "[^:\\[ ]*\\[[0-9]*\\]: Proxy f1 started"
Frédéric Lécailleb083c832018-08-23 18:06:35 +020030
31 recv notice
Willy Tarreau9c27ea02018-11-16 15:54:23 +010032 expect ~ "[^:\\[ ]\\[[0-9]*\\]: Proxy f2 started"
Frédéric Lécailleb083c832018-08-23 18:06:35 +020033
34 recv info
Willy Tarreau9c27ea02018-11-16 15:54:23 +010035 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]*$"
Frédéric Lécailleb083c832018-08-23 18:06:35 +020036
37 recv info
Willy Tarreau9c27ea02018-11-16 15:54:23 +010038 expect ~ "[^:\\[ ]\\[[0-9]*\\]: Tc=[0-9]* Td=[0-9]* Th=[0-9]* Tt=[0-9]* Tw=[0-9]*$"
Frédéric Lécailleb083c832018-08-23 18:06:35 +020039} -start
40
41haproxy h1 -conf {
42 global
43 lua-load ${testdir}/b00001.lua
44
45 defaults
46 timeout client 1s
47 timeout server 1s
48 timeout connect 1s
49
50 frontend f1
51 mode http
52 bind "fd@${f1}"
53 log ${Slog_addr}:${Slog_port} daemon
54 log-format Ta=%Ta\ Tc=%Tc\ Td=%Td\ Th=%Th\ Ti=%Ti\ Tq=%Tq\ TR=%TR\ Tr=%Tr\ Tt=%Tt\ Tw=%Tw
55 default_backend b1
56
57 backend b1
58 mode http
59 http-request use-service lua.foo.http
60
61 frontend f2
62 mode tcp
63 bind "fd@${f2}"
64 log ${Slog_addr}:${Slog_port} daemon
65 log-format Tc=%Tc\ Td=%Td\ Th=%Th\ Tt=%Tt\ Tw=%Tw
66
67 tcp-request inspect-delay 1s
68 tcp-request content use-service lua.foo.tcp
69} -start
70
71client c1 -connect "${h1_f1_sock}" {
72 txreq
73 rxresp
74} -run
75
76client c2 -connect "${h1_f2_sock}" {
77 txreq
78 rxresp
79} -run
80
81syslog Slog -wait