diff options
Diffstat (limited to 'tests/test01.at')
-rw-r--r-- | tests/test01.at | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/test01.at b/tests/test01.at new file mode 100644 index 0000000..116c8f1 --- /dev/null +++ b/tests/test01.at @@ -0,0 +1,83 @@ +# This file is part of vmod-binlog testsuite -*- autotest -*- +# Copyright (C) 2013 Sergey Poznyakoff +# +# Vmod-binlog is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Vmod-binlog is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with vmod-binlog. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([appends]) +AT_KEYWORDS([append]) + +AT_CHECK([ +cwd=`pwd` +mkdir log + +cat > test.vtc <<EOT +varnishtest "Appends" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import binlog from "$abs_top_builddir/src/.libs/libvmod_binlog.so"; + sub vcl_init { + binlog.init("dir=$cwd/log;size=1M;pattern=logfile"); + } + sub vcl_fini { + binlog.close(); + } + sub vcl_recv { + binlog.sappend(req.http.X-nid, req.http.X-aid); + return (lookup); + } +} -start + +client c1 { + txreq -url / -hdr "X-nid:1" -hdr "X-aid:0" + rxresp + expect resp.status == 200 + + txreq -url / -hdr "X-nid:1" -hdr "X-aid:1" + rxresp + expect resp.status == 200 + + delay 1.0 + + txreq -url / -hdr "X-nid:2" -hdr "X-aid:0" + rxresp + expect resp.status == 200 + + delay 1.0 + + txreq -url / -hdr "X-nid:2" -hdr "X-aid:0" + rxresp + expect resp.status == 200 +} + +client c1 -run +EOT + +$VARNISHTEST test.vtc | sed 's/^#.*TEST test.vtc passed.*/OK/' +binlogcat -d log/logfile +], +[0], +[OK +0 1 0 +0 1 1 +1 2 0 +2 2 0 +]) + +AT_CLEANUP + |