Hi Frederic, Adis,

Op 29-11-2018 om 14:53 schreef Frederic Lecaille:
Hi Adis,

On 11/29/18 10:03 AM, Adis Nezirovic wrote:
On Thu, Nov 29, 2018 at 09:03:34AM +0100, Willy Tarreau wrote:
OK thanks, I'll take a look at it once I've flushed my pending stuff on
H2+HTX :-(

Great, I had my morning coffee and visited my optometrist, so here is
a fixed test script (correctly setting Host header).

P.S.
Lua usually suffers trying to do things in tasks, I don't think this is
the first time something gets broken. Can we make reg test with Lua
script (maybe strip out LuaSocket requirement)?


Yes. There already exist LUA reg tests in reg-tests/lua directory.

Fred.

Indeed some LUA tests already exists, but it didn't check to use a socket from a task.

Attached a new test which does, and does indeed fail on versions since the mentioned commit. Should i make a patch out of it for inclusion in git? Or can you guys do that once the fix is also ready.? i think it was the preferred to get bugfix+regtest 'linked' then ?

Regards,
PiBa-NL (Pieter)

varnishtest "Lua: txn:get_priv() scope"
feature ignore_unknown_macro

#REQUIRE_OPTIONS=LUA
#REQUIRE_VERSION=1.6

server s1 {
    rxreq
    txresp -bodylen 20
} -start

haproxy h1 -conf {
    global
        lua-load ${testdir}/b00004.lua

    frontend fe1
        mode http
        bind "fd@${fe1}"
        default_backend b1

    backend b1
        mode http
        http-request use-service lua.fakeserv

} -start

client c0 -connect ${h1_fe1_sock} {
    txreq -url "/" -hdr "vtcport: ${s1_port}"
    rxresp
    expect resp.status == 200
} -run


server s1 -wait
local vtc_port = 0

core.register_service("fakeserv", "http", function(applet)
       vtc_port = applet.headers["vtcport"][0]
        core.Info("APPLET START")
        local response = "OK"
        applet:add_header("Server", "haproxy/webstats")
        applet:add_header("Content-Length", string.len(response))
        applet:add_header("Content-Type", "text/html")
        applet:start_response()
        applet:send(response)
        core.Info("APPLET DONE")
end)

local function cron()
        -- wait for until the correct port is set through the c0 request..
        while vtc_port == 0 do
                core.msleep(1)
        end
        core.Debug('CRON port:' .. vtc_port)

       local socket = core.tcp()
       local success = socket:connect("127.0.0.1", vtc_port)
        core.Info("SOCKET MADE ".. (success or "??"))
        if success ~= 1 then
                core.Info("CONNECT SOCKET FAILED?")
                return
        end
        local request = "GET / HTTP/1.1\r\n\r\n"
        core.Info("SENDING REQUEST")
        socket:send(request)
        local result = ""
        repeat
                core.Info("4")
                local d = socket:receive("*a")
                if d ~= nil then
                        result = result .. d
                end
        until d == nil or d == 0
        core.Info("Received: "..result)
end

core.register_task(cron)

Reply via email to