Commit 36e6de41 authored by Geoff Simmons's avatar Geoff Simmons

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

parent 18c6a221
# looks like -*- vcl -*-
varnishtest "cafe example, cluster-wide and namespace-specific Services"
client c1 -connect "${localhost} ${systemport}" {
txreq -url /foo -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 /bar -hdr "Host: anything.else"
rxresp
expect resp.status == 200
expect resp.body ~ "(?m)^Server name: other-[a-z0-9]+-[a-z0-9]+$"
} -run
client c1 -connect "${localhost} ${cafeport}" {
txreq -url /coffee -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 /foo -hdr "Host: tea.example.com"
rxresp
expect resp.status == 404
} -run
#! /bin/bash -ex
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-system.yaml
kubectl apply -f nodeport-system.yaml
kubectl apply -f varnish-system.yaml
kubectl apply -f adm-secret-coffee.yaml
kubectl apply -f nodeport-coffee.yaml
kubectl apply -f varnish-coffee.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-coffee.yaml
kubectl delete -f nodeport-coffee.yaml
kubectl delete -f adm-secret-coffee.yaml
kubectl delete -f varnish-system.yaml
kubectl wait --timeout=2m pod -l app=varnish-ingress -n kube-system \
--for=delete
kubectl delete -f nodeport-system.yaml
kubectl delete -f adm-secret-system.yaml
kubectl delete -f other.yaml
kubectl delete -f tea.yaml
kubectl delete -f coffee.yaml
kubectl delete -f namespace.yaml
#! /bin/bash -ex
function killsystem {
kill $SYSTEMPID
}
function killcafe {
kill $SYSTEMPID
kill $CAFEPID
}
SYSTEMPORT=${SYSTEMPORT:-8888}
CAFEPORT=${CAFEPORT:-9999}
kubectl wait -n kube-system --timeout=2m pod -l app=varnish-ingress --for=condition=Ready
kubectl wait -n cafe --timeout=2m pod -l app=varnish-ingress --for=condition=Ready
kubectl port-forward -n kube-system svc/varnish-ingress ${SYSTEMPORT}:80 >/dev/null &
SYSTEMPID=$!
trap killsystem EXIT
kubectl port-forward -n cafe svc/varnish-ingress ${CAFEPORT}:80 >/dev/null &
CAFEPID=$!
trap killcafe EXIT
sleep 1
varnishtest ${TESTOPTS} -Dsystemport=${SYSTEMPORT} -Dcafeport=${CAFEPORT} cafe.vtc
# Parse the controller log for these lines (Ingress names in any order):
# Ingresses implemented by Varnish Service kube-system/varnish-ingress: [other/other-ingress cafe/tea-ingress]
# Ingresses implemented by Varnish Service cafe/varnish-ingress: [cafe/coffee-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 lines
SYSINGS=$(kubectl logs -n kube-system $CTLPOD | grep 'Ingresses implemented by Varnish Service kube-system/varnish-ingress' | tail -1)
CAFEINGS=$(kubectl logs -n kube-system $CTLPOD | grep 'Ingresses implemented by Varnish Service cafe/varnish-ingress' | tail -1)
# Check those line for the Ingress names
echo $SYSINGS | grep 'other/other-ingress'
echo $SYSINGS | grep 'cafe/tea-ingress'
echo $CAFEINGS | grep 'cafe/coffee-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