Просмотр исходного кода

perf: make e2e test setup concurrent

Batch the application of workloads as much as possible rather than
creating+waiting several times in a row. This will help speed up e2e
test setup.

Signed-off-by: squat <lserven@gmail.com>
squat 2 месяцев назад
Родитель
Сommit
642e015592
3 измененных файлов с 17 добавлено и 13 удалено
  1. 0 2
      e2e/handlers.sh
  2. 0 2
      e2e/kgctl.sh
  3. 17 9
      e2e/lib.sh

+ 0 - 2
e2e/handlers.sh

@@ -3,9 +3,7 @@
 . lib.sh
 
 setup_suite() {
-	# shellcheck disable=SC2016
 	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() {

+ 0 - 2
e2e/kgctl.sh

@@ -3,9 +3,7 @@
 . lib.sh
 
 setup_suite() {
-	# shellcheck disable=SC2016
 	block_until_ready_by_name kube-system kilo-userspace 
-	_kubectl wait pod -l app.kubernetes.io/name=adjacency --for=condition=Ready --timeout 3m
 }
 
 test_connect() {

+ 17 - 9
e2e/lib.sh

@@ -90,11 +90,16 @@ delete_peer() {
 	_kubectl delete peer "$1"
 }
 
+is_scheduled() {
+	for _ in $(_kubectl -n "$1" get pods -o name -l "$2" --field-selector=status.phase!=Running,status.phase!=Pending); do
+		return 1;
+	done
+	return 0
+}
+
 is_ready() {
-	for pod in $(_kubectl -n "$1" get pods -o name -l "$2"); do
-		if ! _kubectl -n "$1" get "$pod" | tail -n 1 | grep -q Running; then
-			return 1;
-		fi
+	for _ in $(_kubectl -n "$1" get pods -o name -l "$2" --field-selector=status.phase!=Running); do
+		return 1;
 	done
 	return 0
 }
@@ -126,15 +131,18 @@ create_cluster() {
 	# Apply Kilo the the cluster.
 	_kubectl apply -f ../manifests/crds.yaml
 	_kubectl apply -f kilo-kind-userspace.yaml
-	if ! block_until_ready_by_name kube-system kilo-userspace; then return 1; fi
-	_kubectl wait nodes --all --for=condition=Ready
-	# Wait for CoreDNS.
-	block_until_ready kube_system k8s-app=kube-dns
+	block_until_ready_by_name kube-system kilo-userspace || return 1
+	_kubectl wait nodes --all --for=condition=Ready --timeout=30s || return 1
 	# Ensure the curl helper is not scheduled on a control-plane node.
+	# Apply the before the node is untainted.
 	_kubectl apply -f helper-curl.yaml
-	block_until_ready_by_name default curl || return 1
+	# Ensure the pod is scheduled before untainting.
+	retry 30 5 "some curl pods are not scheduled yet" is_scheduled default curl
 	_kubectl taint node $KIND_CLUSTER-control-plane node-role.kubernetes.io/control-plane:NoSchedule-
 	_kubectl apply -f https://raw.githubusercontent.com/kilo-io/adjacency/main/example.yaml
+	# Wait for workloads.
+	block_until_ready kube_system k8s-app=kube-dns || return 1
+	block_until_ready_by_name default curl || return 1
 	block_until_ready_by_name default adjacency
 }