Re: [PATCH 1/1] TMP: Add reg-test to check scoping of txn:get_priv()
On 08/22/2018 04:20 PM, Tim Düsterhus wrote: Frederic, Am 22.08.2018 um 15:21 schrieb Frederic Lecaille: Thank you a lot for this reg testing file. Just a little detail (see below). You are correct of course. It was quickly cobbled together to provide a reproducer, not meant for committing (a patch is just a convenient means of shipping the files). That's why I tagged it with 'TMP' and why it's missing a proper commit message description. Ok, did not notice the TMP flag. Also it should be included with the actual commit fixing the issue, like I did in http://git.haproxy.org/?p=haproxy.git;a=commitdiff;h=65189c17c694b0b44e0d324d63c055f5329e61c9, not added separately. Test + Fix should be an atomic unit. Yes, even if not mandatory, it would be preferable. Whoever fixes the actual issue should just copy the reg-test into their commit, fix your remark and add me to the commit message as I agree again. We will check that. Co-authored-by: Tim Düsterhus :-) Also note that -run is a shorcut for -start -wait. Good to know, thanks. Best regards Tim Düsterhus
Re: [PATCH 1/1] TMP: Add reg-test to check scoping of txn:get_priv()
Frederic, Am 22.08.2018 um 15:21 schrieb Frederic Lecaille: > Thank you a lot for this reg testing file. > > Just a little detail (see below). You are correct of course. It was quickly cobbled together to provide a reproducer, not meant for committing (a patch is just a convenient means of shipping the files). That's why I tagged it with 'TMP' and why it's missing a proper commit message description. Also it should be included with the actual commit fixing the issue, like I did in http://git.haproxy.org/?p=haproxy.git;a=commitdiff;h=65189c17c694b0b44e0d324d63c055f5329e61c9, not added separately. Test + Fix should be an atomic unit. Whoever fixes the actual issue should just copy the reg-test into their commit, fix your remark and add me to the commit message as Co-authored-by: Tim Düsterhus :-) > Also note that -run is a shorcut for -start -wait. Good to know, thanks. Best regards Tim Düsterhus
Re: [PATCH 1/1] TMP: Add reg-test to check scoping of txn:get_priv()
Hello Tim, Thank you a lot for this reg testing file. Just a little detail (see below). Also note that -run is a shorcut for -start -wait. Regards. On 08/22/2018 02:47 PM, Tim Duesterhus wrote: diff --git a/reg-tests/lua/h1.lua b/reg-tests/lua/h1.lua new file mode 100644 index ..999ea887 --- /dev/null +++ b/reg-tests/lua/h1.lua @@ -0,0 +1,15 @@ +core.register_action("bug", { "http-res" }, function(txn) + data = txn:get_priv() + if not data then + data = 0 + end + data = data + 1 + print(string.format("set to %d", data)) + txn.http:res_set_status(200 + data) + txn:set_priv(data) +end) + +core.register_service("fakeserv", "http", function(applet) + applet:set_status(200) + applet:start_response() +end) diff --git a/reg-tests/lua/h1.vtc b/reg-tests/lua/h1.vtc new file mode 100644 index ..b11f21c9 --- /dev/null +++ b/reg-tests/lua/h1.vtc @@ -0,0 +1,36 @@ +varnishtest "Lua: txn:get_priv() scope" +feature ignore_unknown_macro + 's1' server is useless in this case because 'h1' haproxy configuration below does not use any server as backend. +server s1 -repeat 2 { +rxreq +txresp +} -start + +haproxy h1 -conf { +global +lua-load ${testdir}/h1.lua + +frontend fe1 +mode http +bind "fd@${fe1}" +default_backend b1 + +http-response lua.bug + +backend b1 +mode http +http-request use-service lua.fakeserv +} -start + +client c0 -connect ${h1_fe1_sock} { +txreq -url "/" +rxresp +expect resp.status == 201 +txreq -url "/" +rxresp +expect resp.status == 201 +} + +client c0 -start + +client c0 -wait
[PATCH 1/1] TMP: Add reg-test to check scoping of txn:get_priv()
see https://www.mail-archive.com/haproxy@formilux.org/msg31015.html --- reg-tests/lua/h1.lua | 15 +++ reg-tests/lua/h1.vtc | 36 2 files changed, 51 insertions(+) create mode 100644 reg-tests/lua/h1.lua create mode 100644 reg-tests/lua/h1.vtc diff --git a/reg-tests/lua/h1.lua b/reg-tests/lua/h1.lua new file mode 100644 index ..999ea887 --- /dev/null +++ b/reg-tests/lua/h1.lua @@ -0,0 +1,15 @@ +core.register_action("bug", { "http-res" }, function(txn) + data = txn:get_priv() + if not data then + data = 0 + end + data = data + 1 + print(string.format("set to %d", data)) + txn.http:res_set_status(200 + data) + txn:set_priv(data) +end) + +core.register_service("fakeserv", "http", function(applet) + applet:set_status(200) + applet:start_response() +end) diff --git a/reg-tests/lua/h1.vtc b/reg-tests/lua/h1.vtc new file mode 100644 index ..b11f21c9 --- /dev/null +++ b/reg-tests/lua/h1.vtc @@ -0,0 +1,36 @@ +varnishtest "Lua: txn:get_priv() scope" +feature ignore_unknown_macro + +server s1 -repeat 2 { +rxreq +txresp +} -start + +haproxy h1 -conf { +global +lua-load ${testdir}/h1.lua + +frontend fe1 +mode http +bind "fd@${fe1}" +default_backend b1 + +http-response lua.bug + +backend b1 +mode http +http-request use-service lua.fakeserv +} -start + +client c0 -connect ${h1_fe1_sock} { +txreq -url "/" +rxresp +expect resp.status == 201 +txreq -url "/" +rxresp +expect resp.status == 201 +} + +client c0 -start + +client c0 -wait -- 2.18.0