Skip to content

Commit

Permalink
Add some simple tests of the VCL files
Browse files Browse the repository at this point in the history
  • Loading branch information
audunmg committed Apr 19, 2024
1 parent 7905c32 commit 7994dce
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/varnishtests/001-simple-request.vtc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
varnishtest "Simple request"


server s1 {
rxreq
txresp
} -start


shell {
sed "s/.host =.*/.host = \"${s1_addr}\";/;s/.port = .*/.port = \"${s1_port}\";/" ${pwd}/docs/varnish/vcl/parameters.vcl > ${tmpdir}/parameters.vcl
echo "${s1_addr} ${s1_port}"
} -run

varnish v1 -arg "-p vcl_path=${tmpdir} -f $PWD/docs/varnish/vcl/${vclfile}" -start

client c1 {
txreq
rxresp
} -run
22 changes: 22 additions & 0 deletions tests/varnishtests/002-cookie-handling.vtc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
varnishtest "Simple request"


server s1 {
rxreq
expect req.http.cookie == "eZSESSID=session"
txresp
} -start


shell {
sed "s/.host =.*/.host = \"${s1_addr}\";/;s/.port = .*/.port = \"${s1_port}\";/" ${pwd}/docs/varnish/vcl/parameters.vcl > ${tmpdir}/parameters.vcl
echo "${s1_addr} ${s1_port}"
} -run

varnish v1 -arg "-p vcl_path=${tmpdir} -f $PWD/docs/varnish/vcl/${vclfile}" -start

client c1 {
txreq -hdr "Cookie: unrelated_cookie=something; eZSESSID=session; another_cooke=something_else;"
rxresp
} -run

9 changes: 9 additions & 0 deletions tests/varnishtests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Varnishtest files

Varnishtests can be ran using the official docker images:

Varnish6:
docker run --rm --entrypoint varnishtest --volume $PWD:/etc/varnish varnish:stable -t 5 -D vclfile=varnish6.vcl tests/varnishtests/001-simple-request.vtc

Varnish7:
docker run --rm --entrypoint varnishtest --volume $PWD:/etc/varnish varnish:fresh -t 5 -D vclfile=varnish7.vcl tests/varnishtests/001-simple-request.vtc

0 comments on commit 7994dce

Please sign in to comment.