diff --git a/e2e/handlers.sh b/e2e/handlers.sh index 03e9baf5..7fd5baf5 100755 --- a/e2e/handlers.sh +++ b/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() { diff --git a/e2e/kgctl.sh b/e2e/kgctl.sh index d3d0d07e..1b11c0bd 100755 --- a/e2e/kgctl.sh +++ b/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() { diff --git a/e2e/lib.sh b/e2e/lib.sh index 9fc9e776..425f9bc7 100755 --- a/e2e/lib.sh +++ b/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 }