Commit b6e3eb73 authored by Geoff Simmons's avatar Geoff Simmons

Add an e2e test for the use of ShardParam in a BackendConfig.

parent b7d31fea
......@@ -34,18 +34,25 @@ TESTDIR=$(mkdir)/../../test
all: deploy
deploy-helm:
deploy-bcfg-helm:
@helm install viking-ingress-backend-cfg $(CHARTDIR)/viking-test-app \
--values values.yaml
deploy-param-helm:
@helm install viking-ingress-shard-param $(CHARTDIR)/viking-test-app \
--values values-param.yaml
deploy-kubectl:
@kubectl apply -f $(mkdir)/../hello/cafe-ingress.yaml
@kubectl apply -f backend-cfg.yaml
@kubectl apply -f $(mkdir)/../hello/cafe.yaml
# TESTOPTS are passed to varnishtest, e.g.: make TESTOPTS=-v verify
verify:
$(mkdir)/verify.sh
verify-bcfg:
$(mkdir)/verify.sh cafe.vtc
verify-param:
$(mkdir)/verify.sh cafe-param.vtc
wait:
$(TESTDIR)/wait.sh app=varnish-ingress
......@@ -55,19 +62,37 @@ uninstall-kubectl:
@kubectl delete -f $(mkdir)/../hello/cafe-ingress.yaml
@kubectl delete -f $(mkdir)/../hello/cafe.yaml
uninstall-helm:
uninstall-bcfg-helm:
@helm uninstall viking-ingress-backend-cfg
uninstall-param-helm:
@helm uninstall viking-ingress-shard-param
undeploy-kubectl: uninstall-kubectl wait
undeploy-helm: uninstall-helm wait
undeploy-bcfg-helm: uninstall-bcfg-helm wait
undeploy-param-helm: uninstall-param-helm wait
ifeq ($(DEPLOY),kubectl)
deploy: deploy-kubectl
undeploy: undeploy-kubectl
verify: verify-bcfg
else
deploy-bcfg: deploy-bcfg-helm
undeploy-bcfg: undeploy-bcfg-helm
deploy-param: deploy-param-helm
undeploy-param: undeploy-param-helm
endif
ifeq ($(EXAMPLE),param)
deploy: deploy-param
undeploy: undeploy-param
verify: verify-param
else
deploy: deploy-helm
undeploy: undeploy-helm
deploy: deploy-bcfg
undeploy: undeploy-bcfg
verify: verify-bcfg
endif
.PHONY: all $(MAKECMDGOALS)
......@@ -82,6 +82,5 @@ spec:
# would be sharded if the "first" Endpoint were to be removed.
# - Requests for newly added Endpoints ramp up over five minutes.
type: shard
shard_param: caffeine
warmup: 50
rampup: 5m
# looks like -*- vcl -*-
varnishtest "cafe example using shard_param objects"
client c1 -connect "${localhost} ${localport}" {
txreq -url /coffee/foo/bar -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
expect resp.http.X-Caffeine-Warmup == "0.250"
expect resp.http.X-Caffeine-Rampup == "true"
} -run
client c1 -connect "${localhost} ${localport}" {
txreq -url /tea/baz/quux -hdr "Host: cafe.example.com"
rxresp
expect resp.status == 200
expect resp.http.X-Theobromine-Warmup == "0.750"
expect resp.http.X-Theobromine-Rampup == "false"
} -run
apps:
coffee:
image: uplex/http-echo
replicas: 2
servicePort: 80
containerPort: 7357
targetPort: 7357
config:
director:
type: shard
shard_param: caffeine
tea:
image: uplex/http-echo
replicas: 3
servicePort: 80
containerPort: 7357
targetPort: 7357
config:
director:
type: shard
shard_param: theobromine
ingress:
name: cafe-ingress
rules:
- host: cafe.example.com
paths:
- path: /tea
type: Prefix
app: tea
- path: /coffee
type: Prefix
app: coffee
vikingAdmSvc: varnish-ingress-admin
vcl: |
sub vcl_init {
vk8s_default_2f_coffee-svc_director.associate(caffeine.use());
vk8s_default_2f_tea-svc_director.associate(theobromine.use());
}
sub vcl_backend_fetch {
caffeine.set(warmup=0.25, rampup=true);
theobromine.set(warmup=0.75, rampup=false);
set bereq.http.X-Caffeine-Warmup = caffeine.get_warmup();
set bereq.http.X-Caffeine-Rampup = caffeine.get_rampup();
set bereq.http.X-Theobromine-Warmup = theobromine.get_warmup();
set bereq.http.X-Theobromine-Rampup = theobromine.get_rampup();
}
sub vcl_backend_response {
set beresp.http.X-Caffeine-Warmup = bereq.http.X-Caffeine-Warmup;
set beresp.http.X-Caffeine-Rampup = bereq.http.X-Caffeine-Rampup;
set beresp.http.X-Theobromine-Warmup = bereq.http.X-Theobromine-Warmup;
set beresp.http.X-Theobromine-Rampup = bereq.http.X-Theobromine-Rampup;
}
......@@ -28,7 +28,6 @@ apps:
# would be sharded if the "first" Endpoint were to be removed.
# - Requests for newly added Endpoints ramp up over five minutes.
type: shard
shard_param: caffeine
warmup: 50
rampup: 5m
......
#! /bin/bash -ex
MYDIR=$(dirname ${BASH_SOURCE[0]})
VTC=$1
source ${MYDIR}/../../test/utils.sh
LOCALPORT=${LOCALPORT:-8888}
......@@ -15,4 +16,4 @@ kubectl port-forward svc/varnish-ingress ${LOCALPORT}:80 >/dev/null &
trap 'kill $(jobs -p)' EXIT
wait_for_port ${LOCALPORT}
varnishtest ${TESTOPTS} -Dlocalport=${LOCALPORT} cafe.vtc
varnishtest ${TESTOPTS} -Dlocalport=${LOCALPORT} ${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