Commit 9f968efe authored by Nils Goroll's avatar Nils Goroll

add test for vcl reloading to ensure the free callback works

parent 454d086b
## added by vtc script
#
# import esicookies from "${vmod_topbuild}/src/.libs/libvmod_esicookies.so" ;
sub vcl_fetch {
if (req.url == "/body2") {
esicookies.to_http0(beresp.http.Set-Cookie);
} else {
set req.http.X-Err = esicookies.to_http0_e(beresp.http.Set-Cookie);
if (req.http.X-Err != "") {
error 503 "Error in to_http0";
}
unset req.http.X-Err;
}
set beresp.do_esi = true;
}
sub vcl_error {
if (req.http.X-Err) {
set obj.http.X-Err = req.http.X-Err;
}
}
varnishtest "test vmod_esicookies reload (mem free)"
server s1 {
rxreq
expect req.http.Cookie == "fromclient=1"
txresp -hdr "Set-Cookie: fromserver1=1" -body {
<html>
Before include
<esi:include src="/body1"/>
After include 1
}
rxreq
expect req.url == "/body1"
expect req.http.Cookie == "fromclient=1; fromserver1=1"
txresp -hdr "Set-Cookie: frombody1=1; Secure" \
-hdr "Set-Cookie: fromserver1=2; Domain=.foo.com; Path=/; Expires=Wed, 13-Jan-2021 22:23:01 GMT; HttpOnly" \
-hdr "Connection: close" \
-body {
Included file
}
close
accept
rxreq
expect req.http.Cookie == "fromclient=1"
txresp -hdr "Set-Cookie: fromserver1=1" -body {
<html>
Before include
<esi:include src="/body1"/>
After include 1
}
rxreq
expect req.url == "/body1"
expect req.http.Cookie == "fromclient=1; fromserver1=1"
txresp -hdr "Set-Cookie: frombody1=1; Secure" \
-hdr "Set-Cookie: fromserver1=2; Domain=.foo.com; Path=/; Expires=Wed, 13-Jan-2021 22:23:01 GMT; HttpOnly" \
-hdr "Connection: close" \
-body {
Included file
}
close
accept
rxreq
expect req.http.Cookie == "fromclient=1"
txresp -hdr "Set-Cookie: fromserver1=1" -body {
<html>
Before include
<esi:include src="/body1"/>
After include 1
}
rxreq
expect req.url == "/body1"
expect req.http.Cookie == "fromclient=1; fromserver1=1"
txresp -hdr "Set-Cookie: frombody1=1; Secure" \
-hdr "Set-Cookie: fromserver1=2; Domain=.foo.com; Path=/; Expires=Wed, 13-Jan-2021 22:23:01 GMT; HttpOnly" \
-hdr "Connection: close" \
-body {
Included file
}
} -start
shell "(echo 'backend foo { .host = \"${s1_addr}\"; .port = \"${s1_port}\"; }'; echo 'import esicookies from \"${vmod_topbuild}/src/.libs/libvmod_esicookies.so\";' ; cat ${vmod_topbuild}/src/tests/vmod_esicookies_reload.vcl ) >${tmpdir}/_esicookies_reload.vcl"
# only one work thread to get rid of the vcls
varnish v1 -arg "-f ${tmpdir}/_esicookies_reload.vcl -p thread_pools=1 -w1,1,300" -start
varnish v1 -cliok "vcl.load foo1 ${tmpdir}/_esicookies_reload.vcl" -cliok "vcl.use foo1"
varnish v1 -expect n_vcl == 2
varnish v1 -expect n_backend == 1
varnish v1 -cliok "vcl.discard boot"
delay 1
varnish v1 -expect n_vcl == 1
varnish v1 -expect n_backend == 1
client c1 {
txreq -url "/" -hdr "Cookie: fromclient=1"
rxresp
} -run
varnish v1 -cliok "vcl.load foo2 ${tmpdir}/_esicookies_reload.vcl" -cliok "vcl.use foo2"
varnish v1 -expect n_vcl == 2
varnish v1 -expect n_backend == 1
varnish v1 -cliok "vcl.discard foo1"
varnish v1 -cli "debug.backend" -cli "vcl.list"
client c1 {
txreq -url "/" -hdr "Cookie: fromclient=1"
rxresp
} -run
delay 3
# worker thread should have let go of the old vcl by now
varnish v1 -cli "debug.backend" -cli "vcl.list"
varnish v1 -expect n_vcl == 1
varnish v1 -expect n_backend == 1
varnish v1 -cliok "vcl.load foo3 ${tmpdir}/_esicookies_reload.vcl" -cliok "vcl.use foo3"
varnish v1 -expect n_vcl == 2
varnish v1 -expect n_backend == 1
varnish v1 -cliok "vcl.discard foo2"
client c1 {
txreq -url "/" -hdr "Cookie: fromclient=1"
rxresp
} -run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment