Commit fd5f3373 authored by Geoff Simmons's avatar Geoff Simmons

Automate un-/deployment & test of multi-Ingress in ns example.

parent 36e6de41
# looks like -*- vcl -*-
varnishtest "cafe example, multiple Varnish Services in a namespace"
client c1 -connect "${localhost} ${coffeeport}" {
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 /foo -hdr "Host: tea.example.com"
rxresp
expect resp.status == 404
} -run
client c1 -connect "${localhost} ${teaport}" {
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 /foo -hdr "Host: coffee.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 adm-secret-tea.yaml
kubectl apply -f nodeport-tea.yaml
kubectl apply -f varnish-tea.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
#! /bin/bash -ex
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-tea.yaml
kubectl delete -f nodeport-tea.yaml
kubectl delete -f adm-secret-tea.yaml
kubectl delete -f tea.yaml
kubectl delete -f coffee.yaml
kubectl delete -f namespace.yaml
#! /bin/bash -ex
function killcoffee {
kill $COFFEEPID
}
function killcafe {
kill $COFFEEPID
kill $TEAPID
}
COFFEEPORT=${COFFEEPORT:-8888}
TEAPORT=${TEAPORT:-9999}
kubectl wait -n cafe --timeout=2m pod -l app=varnish-ingress --for=condition=Ready
kubectl port-forward -n cafe svc/varnish-coffee ${COFFEEPORT}:80 >/dev/null &
COFFEEPID=$!
trap killcoffee EXIT
kubectl port-forward -n cafe svc/varnish-tea ${TEAPORT}:80 >/dev/null &
TEAPID=$!
trap killcafe EXIT
sleep 1
varnishtest ${TESTOPTS} -Dcoffeeport=${COFFEEPORT} -Dteaport=${TEAPORT} cafe.vtc
# Parse the controller log for these lines
# Ingresses implemented by Varnish Service cafe/varnish-tea: [cafe/tea-ingress]
# Ingresses implemented by Varnish Service cafe/varnish-coffee: [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})
# Match the logs
kubectl logs -n kube-system $CTLPOD | grep -q 'Ingresses implemented by Varnish Service cafe/varnish-coffee: \[cafe/coffee-ingress\]'
kubectl logs -n kube-system $CTLPOD | grep -q 'Ingresses implemented by Varnish Service cafe/varnish-tea: \[cafe/tea-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