Commit 18c6a221 authored by Geoff Simmons's avatar Geoff Simmons

Automate un-/deployment & test of the cluster-wide Ingress example.

parent 20f4ac89
# looks like -*- vcl -*-
varnishtest "cafe example in separate namespaces"
client c1 -connect "${localhost} ${localport}" {
txreq -url /foo -hdr "Host: coffee.example.com"
rxresp
expect resp.status == 200
expect resp.body ~ "(?m)^Server name: coffee-[a-z0-9]+-[a-z0-9]+$"
txreq -url /bar -hdr "Host: tea.example.com"
rxresp
expect resp.status == 200
expect resp.body ~ "(?m)^Server name: tea-[a-z0-9]+-[a-z0-9]+$"
txreq -url /baz -hdr "Host: anything.else"
rxresp
expect resp.status == 200
expect resp.body ~ "(?m)^Server name: other-[a-z0-9]+-[a-z0-9]+$"
} -run
#! /bin/bash -ex
# Delete the Varnish Service in namespace default.
# Otherwise the Service in kube-system is not unique in the cluster,
# and a Service for the Ingresses in the other namespaces cannot be
# determined.
kubectl delete -f ../../../deploy/nodeport.yaml
kubectl apply -f namespace.yaml
kubectl apply -f coffee.yaml
kubectl apply -f tea.yaml
kubectl apply -f other.yaml
kubectl apply -f adm-secret.yaml
kubectl apply -f nodeport.yaml
kubectl apply -f varnish.yaml
kubectl apply -f coffee-ingress.yaml
kubectl apply -f tea-ingress.yaml
kubectl apply -f other-ingress.yaml
#! /bin/bash -ex
kubectl delete -f other-ingress.yaml
kubectl delete -f tea-ingress.yaml
kubectl delete -f coffee-ingress.yaml
kubectl delete -f varnish.yaml
kubectl delete -f nodeport.yaml
kubectl delete -f adm-secret.yaml
kubectl delete -f other.yaml
kubectl delete -f tea.yaml
kubectl delete -f coffee.yaml
kubectl delete -f namespace.yaml
# Restores the Varnish Service in namespace default.
kubectl apply -f ../../../deploy/nodeport.yaml
echo Waiting until varnish-ingress Pods are running
kubectl wait --timeout=2m pod -l app=varnish-ingress --for=condition=Initialized
#! /bin/bash -ex
function killforward {
kill $KUBEPID
}
LOCALPORT=${LOCALPORT:-8888}
kubectl wait -n kube-system --timeout=2m pod -l app=varnish-ingress \
--for=condition=Ready
kubectl port-forward -n kube-system svc/varnish-ingress ${LOCALPORT}:80 >/dev/null &
KUBEPID=$!
trap killforward EXIT
sleep 1
varnishtest ${TESTOPTS} -Dlocalport=${LOCALPORT} cafe.vtc
# Parse the controller log for this line (Ingress names in any order):
# Ingresses implemented by Varnish Service kube-system/varnish-ingress: [coffee/coffee-ingress tea/tea-ingress other/other-ingress]
# Get the name of the controller Pod
CTLPOD=$(kubectl get pods -n kube-system -l app=varnish-ingress-controller -o jsonpath={.items[0].metadata.name})
# Extract the last matching line
INGS=$(kubectl logs -n kube-system $CTLPOD | grep 'Ingresses implemented by Varnish Service kube-system/varnish-ingress' | tail -1)
# Check that line for the three Ingress names
echo $INGS | grep 'coffee/coffee-ingress'
echo $INGS | grep 'tea/tea-ingress'
echo $INGS | grep 'other/other-ingress'
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