Commit f9051e18 authored by Geoff Simmons's avatar Geoff Simmons

Automate un-/deployment & test of the request disposition examples.

parent 2af30bfb
# looks like -*- vcl -*-
varnishtest "cafe example, alternative reconstruction of builtin vcl_recv"
client c1 -connect "${localhost} ${localport}" {
txreq -url /coffee -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
expect resp.body ~ "(?m)^URI: /coffee$"
expect resp.body ~ "(?m)^Server name: coffee-[a-z0-9]+-[a-z0-9]+$"
txreq -url /tea -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
expect resp.body ~ "(?m)^URI: /tea$"
expect resp.body ~ "(?m)^Server name: tea-[a-z0-9]+-[a-z0-9]+$"
txreq -url /beer
rxresp
expect resp.status == 404
txreq -req PRI -url /coffee -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 405
expect resp.reason == "Method Not Allowed"
txreq -req HACK -url /coffee -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 405
expect resp.reason == "Method Not Allowed"
txreq -url /coffee -nohost
rxresp
expect resp.status == 400
expect resp.reason == "Bad Request"
txreq -req PUT -url /coffee -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
txreq -url /coffee -hdr "Host: cafe.example.com" \
-hdr "Cookie: foo=bar"
rxresp
expect resp.status == 200
} -run
## Pipe currently fails, not routed to a backend.
# client c1 -connect "${localhost} ${localport}" {
# txreq -req CONNECT -url /coffee -hdr "Host: cafe.example.com" \
# -hdr "Connection: close"
# rxresp
# expect resp.status == 200
# } -run
# looks like -*- vcl -*-
varnishtest "cafe example, req-disposition reconstructs builtin vcl_recv"
client c1 -connect "${localhost} ${localport}" {
txreq -url /coffee -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
expect resp.body ~ "(?m)^URI: /coffee$"
expect resp.body ~ "(?m)^Server name: coffee-[a-z0-9]+-[a-z0-9]+$"
txreq -url /tea -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
expect resp.body ~ "(?m)^URI: /tea$"
expect resp.body ~ "(?m)^Server name: tea-[a-z0-9]+-[a-z0-9]+$"
txreq -url /beer
rxresp
expect resp.status == 404
txreq -req PRI -url /coffee -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 405
expect resp.reason == "Method Not Allowed"
txreq -url /coffee -nohost
rxresp
expect resp.status == 400
expect resp.reason == "Bad Request"
txreq -req PUT -url /coffee -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
txreq -url /coffee -hdr "Host: cafe.example.com" \
-hdr "Cookie: foo=bar"
rxresp
expect resp.status == 200
} -run
## Pipe currently fails, not routed to a backend.
# client c1 -connect "${localhost} ${localport}" {
# txreq -req CONNECT -url /coffee -hdr "Host: cafe.example.com" \
# -hdr "Connection: close"
# rxresp
# expect resp.status == 200
# } -run
# looks like -*- vcl -*-
varnishtest "cafe example, cacheability rules based on URL patterns"
client c1 -connect "${localhost} ${localport}" {
# XXX verify pass or lookup
txreq -url /coffee/black.js -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
txreq -url /tea/sugar.css -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
txreq -url /interactive/foo/bar -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 404
txreq -url /dynamic/baz/quux -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 404
} -run
# looks like -*- vcl -*-
varnishtest "cafe example, pass on some cookies but not others"
client c1 -connect "${localhost} ${localport}" {
txreq -url /coffee -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
expect resp.body ~ "(?m)^URI: /coffee$"
expect resp.body ~ "(?m)^Server name: coffee-[a-z0-9]+-[a-z0-9]+$"
txreq -url /tea -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
expect resp.body ~ "(?m)^URI: /tea$"
expect resp.body ~ "(?m)^Server name: tea-[a-z0-9]+-[a-z0-9]+$"
txreq -url /beer
rxresp
expect resp.status == 404
txreq -req PRI -url /coffee -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 405
expect resp.reason == "Method Not Allowed"
txreq -url /coffee -nohost
rxresp
expect resp.status == 400
expect resp.reason == "Bad Request"
txreq -req PUT -url /coffee -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
# XXX verify pass or lookup
txreq -url /coffee -hdr "Host: cafe.example.com" \
-hdr "Cookie: SESSIONID=0123456789abcdef0123456789abcdef"
rxresp
expect resp.status == 200
txreq -url /coffee -hdr "Host: cafe.example.com" \
-hdr "Cookie: LOGIN=foobar"
rxresp
expect resp.status == 200
txreq -url /coffee -hdr "Host: cafe.example.com" \
-hdr "Cookie: foo=bar"
rxresp
expect resp.status == 200
} -run
# looks like -*- vcl -*-
varnishtest "cafe example, PURGE method"
client c1 -connect "${localhost} ${localport}" {
txreq -req PURGE -url /coffee -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
expect resp.reason == "Purged"
} -run
# looks like -*- vcl -*-
varnishtest "cafe example, white-/blacklisting based on URL patterns"
client c1 -connect "${localhost} ${localport}" {
txreq -url /coffee/sugar/foo -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
txreq -url /tea/sugar/bar -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
txreq -url /coffee/baz -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 403
expect resp.reason == "Forbidden"
txreq -url /tea/quux -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 403
expect resp.reason == "Forbidden"
txreq -url /coffee/sugar/black/foo -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 403
expect resp.reason == "Blacklisted"
txreq -url /tea/sugar/black/bar -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 403
expect resp.reason == "Blacklisted"
} -run
#! /bin/bash -ex
kubectl apply -f ../hello/cafe.yaml
kubectl apply -f ../hello/cafe-ingress.yaml
kubectl apply -f alt-builtin.yaml
#! /bin/bash -ex
kubectl apply -f ../hello/cafe.yaml
kubectl apply -f ../hello/cafe-ingress.yaml
kubectl apply -f builtin.yaml
#! /bin/bash -ex
kubectl apply -f ../hello/cafe.yaml
kubectl apply -f ../hello/cafe-ingress.yaml
kubectl apply -f cacheability.yaml
#! /bin/bash -ex
kubectl apply -f ../hello/cafe.yaml
kubectl apply -f ../hello/cafe-ingress.yaml
kubectl apply -f pass-on-session-cookie.yaml
#! /bin/bash -ex
kubectl apply -f ../hello/cafe.yaml
kubectl apply -f ../hello/cafe-ingress.yaml
kubectl apply -f purge-method.yaml
#! /bin/bash -ex
kubectl apply -f ../hello/cafe.yaml
kubectl apply -f ../hello/cafe-ingress.yaml
kubectl apply -f url-whitelist.yaml
#! /bin/bash -ex
kubectl delete -f alt-builtin.yaml
kubectl delete -f ../hello/cafe-ingress.yaml
kubectl delete -f ../hello/cafe.yaml
echo "Waiting until varnish-ingress Pods are not ready"
N=0
until [ $N -ge 120 ]
do
if kubectl get pods -l app=varnish-ingress | grep -q ' 1/1'; then
sleep 10
N=$(( N + 10 ))
continue
fi
exit 0
done
echo "Giving up"
exit 1
#! /bin/bash -ex
kubectl delete -f builtin.yaml
kubectl delete -f ../hello/cafe-ingress.yaml
kubectl delete -f ../hello/cafe.yaml
echo "Waiting until varnish-ingress Pods are not ready"
N=0
until [ $N -ge 120 ]
do
if kubectl get pods -l app=varnish-ingress | grep -q ' 1/1'; then
sleep 10
N=$(( N + 10 ))
continue
fi
exit 0
done
echo "Giving up"
exit 1
#! /bin/bash -ex
kubectl delete -f cacheability.yaml
kubectl delete -f ../hello/cafe-ingress.yaml
kubectl delete -f ../hello/cafe.yaml
echo "Waiting until varnish-ingress Pods are not ready"
N=0
until [ $N -ge 120 ]
do
if kubectl get pods -l app=varnish-ingress | grep -q ' 1/1'; then
sleep 10
N=$(( N + 10 ))
continue
fi
exit 0
done
echo "Giving up"
exit 1
#! /bin/bash -ex
kubectl delete -f pass-on-session-cookie.yaml
kubectl delete -f ../hello/cafe-ingress.yaml
kubectl delete -f ../hello/cafe.yaml
echo "Waiting until varnish-ingress Pods are not ready"
N=0
until [ $N -ge 120 ]
do
if kubectl get pods -l app=varnish-ingress | grep -q ' 1/1'; then
sleep 10
N=$(( N + 10 ))
continue
fi
exit 0
done
echo "Giving up"
exit 1
#! /bin/bash -ex
kubectl delete -f purge-method.yaml
kubectl delete -f ../hello/cafe-ingress.yaml
kubectl delete -f ../hello/cafe.yaml
echo "Waiting until varnish-ingress Pods are not ready"
N=0
until [ $N -ge 120 ]
do
if kubectl get pods -l app=varnish-ingress | grep -q ' 1/1'; then
sleep 10
N=$(( N + 10 ))
continue
fi
exit 0
done
echo "Giving up"
exit 1
#! /bin/bash -ex
kubectl delete -f url-whitelist.yaml
kubectl delete -f ../hello/cafe-ingress.yaml
kubectl delete -f ../hello/cafe.yaml
echo "Waiting until varnish-ingress Pods are not ready"
N=0
until [ $N -ge 120 ]
do
if kubectl get pods -l app=varnish-ingress | grep -q ' 1/1'; then
sleep 10
N=$(( N + 10 ))
continue
fi
exit 0
done
echo "Giving up"
exit 1
#! /bin/bash -ex
function killforward {
kill $KUBEPID
}
LOCALPORT=${LOCALPORT:-8888}
kubectl wait --timeout=2m pod -l app=varnish-ingress --for=condition=Ready
kubectl port-forward svc/varnish-ingress ${LOCALPORT}:80 >/dev/null &
KUBEPID=$!
trap killforward EXIT
sleep 1
varnishtest ${TESTOPTS} -Dlocalport=${LOCALPORT} cafe_alt-builtin.vtc
#! /bin/bash -ex
function killforward {
kill $KUBEPID
}
LOCALPORT=${LOCALPORT:-8888}
kubectl wait --timeout=2m pod -l app=varnish-ingress --for=condition=Ready
kubectl port-forward svc/varnish-ingress ${LOCALPORT}:80 >/dev/null &
KUBEPID=$!
trap killforward EXIT
sleep 1
varnishtest ${TESTOPTS} -Dlocalport=${LOCALPORT} cafe_builtin.vtc
#! /bin/bash -ex
function killforward {
kill $KUBEPID
}
LOCALPORT=${LOCALPORT:-8888}
kubectl wait --timeout=2m pod -l app=varnish-ingress --for=condition=Ready
kubectl port-forward svc/varnish-ingress ${LOCALPORT}:80 >/dev/null &
KUBEPID=$!
trap killforward EXIT
sleep 1
varnishtest ${TESTOPTS} -Dlocalport=${LOCALPORT} cafe_cacheability.vtc
#! /bin/bash -ex
function killforward {
kill $KUBEPID
}
LOCALPORT=${LOCALPORT:-8888}
kubectl wait --timeout=2m pod -l app=varnish-ingress --for=condition=Ready
kubectl port-forward svc/varnish-ingress ${LOCALPORT}:80 >/dev/null &
KUBEPID=$!
trap killforward EXIT
sleep 1
varnishtest ${TESTOPTS} -Dlocalport=${LOCALPORT} cafe_pass-on-session-cookie.vtc
#! /bin/bash -ex
function killforward {
kill $KUBEPID
}
LOCALPORT=${LOCALPORT:-8888}
kubectl wait --timeout=2m pod -l app=varnish-ingress --for=condition=Ready
kubectl port-forward svc/varnish-ingress ${LOCALPORT}:80 >/dev/null &
KUBEPID=$!
trap killforward EXIT
sleep 1
varnishtest ${TESTOPTS} -Dlocalport=${LOCALPORT} cafe_purge.vtc
#! /bin/bash -ex
function killforward {
kill $KUBEPID
}
LOCALPORT=${LOCALPORT:-8888}
kubectl wait --timeout=2m pod -l app=varnish-ingress --for=condition=Ready
kubectl port-forward svc/varnish-ingress ${LOCALPORT}:80 >/dev/null &
KUBEPID=$!
trap killforward EXIT
sleep 1
varnishtest ${TESTOPTS} -Dlocalport=${LOCALPORT} cafe_url-whitelist.vtc
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