e2e: add tests for HTTP handlers

This commit is contained in:
Steffen Vogel 2021-07-16 12:37:41 +02:00
parent 5a6c878fb5
commit 08bf9b1cb4
2 changed files with 26 additions and 1 deletions

View File

@ -209,7 +209,7 @@ $(BASH_UNIT):
chmod +x $@
e2e: container $(KIND_BINARY) $(KUBECTL_BINARY) $(BASH_UNIT) bin/$(OS)/$(ARCH)/kgctl
KILO_IMAGE=$(IMAGE):$(ARCH)-$(VERSION) KIND_BINARY=$(KIND_BINARY) KUBECTL_BINARY=$(KUBECTL_BINARY) KGCTL_BINARY=$(shell pwd)/bin/$(OS)/$(ARCH)/kgctl $(BASH_UNIT) $(BASH_UNIT_FLAGS) ./e2e/setup.sh ./e2e/full-mesh.sh ./e2e/location-mesh.sh ./e2e/multi-cluster.sh ./e2e/teardown.sh
KILO_IMAGE=$(IMAGE):$(ARCH)-$(VERSION) KIND_BINARY=$(KIND_BINARY) KUBECTL_BINARY=$(KUBECTL_BINARY) KGCTL_BINARY=$(shell pwd)/bin/$(OS)/$(ARCH)/kgctl $(BASH_UNIT) $(BASH_UNIT_FLAGS) ./e2e/setup.sh ./e2e/full-mesh.sh ./e2e/location-mesh.sh ./e2e/multi-cluster.sh ./e2e/handlers.sh ./e2e/teardown.sh
header: .header
@HEADER=$$(cat .header); \

25
e2e/handlers.sh Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
# shellcheck disable=SC1091
. lib.sh
setup_suite() {
# shellcheck disable=SC2016
_kubectl patch ds -n kube-system kilo -p '{"spec": {"template":{"spec":{"containers":[{"name":"kilo","args":["--hostname=$(NODE_NAME)","--create-interface=false","--kubeconfig=/etc/kubernetes/kubeconfig","--mesh-granularity=full"]}]}}}}'
block_until_ready_by_name kube-system kilo-userspace
_kubectl wait pod -l app.kubernetes.io/name=adjacency --for=condition=Ready --timeout 3m
}
test_graph_handler() {
assert "curl_pod http://10.4.0.1:1107/graph?format=svg&layout=circo | grep -q '<svg'"
assert "curl_pod http://10.4.0.1:1107/graph&layout=circo | grep -q '<svg'"
assert "curl_pod http://10.4.0.1:1107/graph | grep -q '<svg'"
assert _not "curl_pod http://10.4.0.1:1107/graph?format=svg&layout=fake | grep -q '<svg'"
}
test_health_handler() {
assert "curl_pod http://10.4.0.1:1107/health"
}
test_metrics_handler() {
assert "curl_pod http://10.4.0.1:1107/metrics"
}