aboutsummaryrefslogtreecommitdiff
path: root/tests/atlocal.in
blob: 2e3922fb38bbb5d801636eeedd546a359394c8f5 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# @configure_input@                                     -*- shell-script -*-
# Configurable variable values for vmod-dbrw test suite.
# Copyright (C) 2013-2014 Sergey Poznyakoff

PATH=@abs_builddir@:@abs_top_builddir@/src:@abs_top_srcdir@/build-aux:$top_srcdir:$srcdir:$PATH
INITFILE=@abs_builddir@/.TESTINIT
FAILFILE=@abs_builddir@/FAILURE
VARNISHTEST="@VARNISHSRC@/bin/varnishtest/varnishtest -Dvarnishd=@VARNISHSRC@/bin/varnishd/varnishd"
VARNISHVERSION=@VARNISHVERSION@
: ${DBRW_TEST_DBTYPE=@DBRW_TEST_DBTYPE@}
: ${DBRW_TEST_PARAMS=@DBRW_TEST_PARAMS@}
: ${DBRW_TEST_SERVER=@DBRW_TEST_SERVER@}
: ${DBRW_TEST_DATABASE=@DBRW_TEST_DATABASE@}
: ${DBRW_TEST_USER=@DBRW_TEST_USER@}
: ${DBRW_TEST_PASS=@DBRW_TEST_PASS@}
: ${DBRW_TEST_DEBUG=@DBRW_TEST_DEBUG@}

if [ -n "$DBRW_TEST_SERVER" ]; then
    DBRW_TEST_PARAMS="$DBRW_TEST_PARAMS;server=$DBRW_TEST_SERVER"
fi
if [ -n "$DBRW_TEST_DATABASE" ]; then
    DBRW_TEST_PARAMS="$DBRW_TEST_PARAMS;database=$DBRW_TEST_DATABASE"
fi
if [ -n "$DBRW_TEST_USER" ]; then
    DBRW_TEST_PARAMS="$DBRW_TEST_PARAMS;user=$DBRW_TEST_USER"
fi
if [ -n "$DBRW_TEST_PASS" ]; then
    DBRW_TEST_PARAMS="$DBRW_TEST_PARAMS;password=$DBRW_TEST_PASS"
fi
if [ -n "$DBRW_TEST_DEBUG" ]; then
    DBRW_TEST_PARAMS="$DBRW_TEST_PARAMS;debug=$DBRW_TEST_DEBUG"
fi

at_vcl_backend() {
	case $VARNISHVERSION in
	3) cat <<EOT
server s1 {
       rxreq
       txresp
} -start

varnish v1 -vcl+backend {
	import std;
        import dbrw from "$abs_top_builddir/src/.libs/libvmod_dbrw.so";
	sub vcl_init {
		dbrw.config("$DBRW_TEST_DBTYPE", "$DBRW_TEST_PARAMS",
		            {"$1"});
	}

	sub vcl_recv {
		set req.http.X-Redirect-To =
			dbrw.rewrite("host=" + req.http.Host + ";" +
			             "url=" + req.url);
		error(750, "Redirect");
	}

	sub vcl_error {
		if (obj.status == 750) {
		        set obj.http.Location = req.http.X-Redirect-To;
			if (req.http.X-VMOD-DBRW-Status) {
		                set obj.status = std.integer(req.http.X-VMOD-DBRW-Status, 301);
			}
			return (deliver);
		}
	}
} -start
EOT
	;;
	4) cat <<EOT
server s1 {
       rxreq
       txresp
} -start

varnish v1 -vcl+backend {
	import std;
        import dbrw from "$abs_top_builddir/src/.libs/libvmod_dbrw.so";
	sub vcl_init {
		dbrw.config("$DBRW_TEST_DBTYPE", "$DBRW_TEST_PARAMS",
		            {"$1"});
	}

	sub vcl_recv {
		set req.http.X-Redirect-To =
			dbrw.rewrite("host=" + req.http.Host + ";" +
			             "url=" + req.url);
		return(synth(301, "Redirect"));
	}

	sub vcl_synth {
		if (resp.status == 301) {
			if (req.http.X-VMOD-DBRW-Status) {
				set resp.status = std.integer(req.http.X-VMOD-DBRW-Status, 301);
			}
		        set resp.http.Location = req.http.X-Redirect-To;
			return (deliver);
		}
	}
} -start
EOT
	;;
	*) echo >&2 "unsupported varnish version: $VARNISHVERSION"
esac
}

Return to:

Send suggestions and report system problems to the System administrator.