From c9e47868935f1b20c0107014fce70deb5aebcfff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Serv=C3=A9n=20Mar=C3=ADn?= Date: Fri, 2 Jul 2021 14:32:36 +0200 Subject: [PATCH] e2e: reuse kind cluster across suites MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, each test suite spins up its own kind cluster, which results in longer e2e test times as each test suite needs to wait for the cluster to be ready and for images to download. This commit creates two new virtual test suites that are run before and after the actual e2e tests and are responsible for creating and destroying a kind cluster respectively. Any test suite that needs a fresh cluster can still spin up its own using the `create_cluster` helper in the lib.sh file. Signed-off-by: Lucas Servén Marín --- .gitignore | 1 + Makefile | 2 +- e2e/full-mesh.sh | 5 ----- e2e/location-mesh.sh | 5 ----- e2e/setup.sh | 7 +++++++ e2e/teardown.sh | 7 +++++++ 6 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 e2e/setup.sh create mode 100644 e2e/teardown.sh diff --git a/.gitignore b/.gitignore index cd2418a..1e8d72c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ .push* bin/ tmp/ +e2e/kind.yaml diff --git a/Makefile b/Makefile index c264464..907abf1 100644 --- a/Makefile +++ b/Makefile @@ -208,7 +208,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) ./e2e/full-mesh.sh ./e2e/location-mesh.sh + KILO_IMAGE=$(IMAGE):$(ARCH)-$(VERSION) KIND_BINARY=$(KIND_BINARY) KUBECTL_BINARY=$(KUBECTL_BINARY) KGCTL_BINARY=$(shell pwd)/bin/$(OS)/$(ARCH)/kgctl $(BASH_UNIT) ./e2e/setup.sh ./e2e/full-mesh.sh ./e2e/location-mesh.sh ./e2e/teardown.sh header: .header @HEADER=$$(cat .header); \ diff --git a/e2e/full-mesh.sh b/e2e/full-mesh.sh index dc196fd..a5f0d7c 100644 --- a/e2e/full-mesh.sh +++ b/e2e/full-mesh.sh @@ -3,17 +3,12 @@ . lib.sh setup_suite() { - create_cluster # shellcheck disable=SC2016 $KUBECTL_BINARY 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_BINARY wait pod -l app.kubernetes.io/name=adjacency --for=condition=Ready --timeout 3m } -teardown_suite () { - delete_cluster -} - test_full_mesh_connectivity() { assert "retry 30 5 '' check_ping" "should be able to ping all Pods" assert "retry 10 5 'the adjacency matrix is not complete yet' check_adjacent 12" "adjacency should return the right number of successful pings" diff --git a/e2e/location-mesh.sh b/e2e/location-mesh.sh index e15903c..a0e8b56 100755 --- a/e2e/location-mesh.sh +++ b/e2e/location-mesh.sh @@ -3,7 +3,6 @@ . lib.sh setup_suite() { - create_cluster # shellcheck disable=SC2016 $KUBECTL_BINARY 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=location"]}]}}}}' block_until_ready_by_name kube-system kilo-userspace @@ -25,7 +24,3 @@ test_location_mesh_peer() { test_mesh_granularity_auto_detect() { assert_equals "$($KGCTL_BINARY graph)" "$($KGCTL_BINARY graph --mesh-granularity location)" } - -teardown_suite () { - delete_cluster -} diff --git a/e2e/setup.sh b/e2e/setup.sh new file mode 100644 index 0000000..370774c --- /dev/null +++ b/e2e/setup.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# shellcheck disable=SC1091 +. lib.sh + +setup_suite() { + create_cluster +} diff --git a/e2e/teardown.sh b/e2e/teardown.sh new file mode 100644 index 0000000..3f6dd69 --- /dev/null +++ b/e2e/teardown.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# shellcheck disable=SC1091 +. lib.sh + +teardown_suite () { + delete_cluster +}