blob: a7a2d6991d65af997295b8c24c447a1b215a359b [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"
23
24feature ignore_unknown_macro
25
26syslog Slog {
27 recv notice
28 expect ~ "haproxy\\[[0-9]*\\]: Proxy f1 started"
29
30 recv notice
31 expect ~ "haproxy\\[[0-9]*\\]: Proxy f2 started"
32
33 recv info
34 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]*$"
35
36 recv info
37 expect ~ "haproxy\\[[0-9]*\\]: Tc=[0-9]* Td=[0-9]* Th=[0-9]* Tt=[0-9]* Tw=[0-9]*$"
38} -start
39
40haproxy h1 -conf {
41 global
42 lua-load ${testdir}/b00001.lua
43
44 defaults
45 timeout client 1s
46 timeout server 1s
47 timeout connect 1s
48
49 frontend f1
50 mode http
51 bind "fd@${f1}"
52 log ${Slog_addr}:${Slog_port} daemon
53 log-format Ta=%Ta\ Tc=%Tc\ Td=%Td\ Th=%Th\ Ti=%Ti\ Tq=%Tq\ TR=%TR\ Tr=%Tr\ Tt=%Tt\ Tw=%Tw
54 default_backend b1
55
56 backend b1
57 mode http
58 http-request use-service lua.foo.http
59
60 frontend f2
61 mode tcp
62 bind "fd@${f2}"
63 log ${Slog_addr}:${Slog_port} daemon
64 log-format Tc=%Tc\ Td=%Td\ Th=%Th\ Tt=%Tt\ Tw=%Tw
65
66 tcp-request inspect-delay 1s
67 tcp-request content use-service lua.foo.tcp
68} -start
69
70client c1 -connect "${h1_f1_sock}" {
71 txreq
72 rxresp
73} -run
74
75client c2 -connect "${h1_f2_sock}" {
76 txreq
77 rxresp
78} -run
79
80syslog Slog -wait