aboutsummaryrefslogtreecommitdiff
path: root/tests/test01.at
blob: 6fd8fc5471cbd68beebbdb972497bd20567cea5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# This file is part of vmod-binlog testsuite -*- autotest -*-
# Copyright (C) 2013-2018 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([test01 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("$cwd/log", "LL", "size=1M;pattern=logfile");
        }
        sub vcl_fini {
                binlog.close();
        }
        sub vcl_recv {
		binlog.start();
		binlog.pack(req.http.X-nid);
		binlog.pack(req.http.X-aid);
		binlog.commit();
                return (hash);
        }
} -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

Return to:

Send suggestions and report system problems to the System administrator.