diff --git a/tests/common.sh b/tests/common.sh index 39a3f725..cccf900e 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -60,12 +60,12 @@ check_url() { check_k3d_clusters() { [ -n "$EXE" ] || abort "EXE is not defined" for c in "$@" ; do - kc=$($EXE get kubeconfig "$c") - [ -n "$kc" ] || abort "could not obtain a kubeconfig for $c" - if kubectl --kubeconfig="$kc" cluster-info ; then - passed "cluster $c is reachable (with kubeconfig=$kc)" + $EXE --verbose get kubeconfig "$c" --switch + #[ -n "$kc" ] || abort "could not obtain a kubeconfig for $c" + if kubectl cluster-info ; then + passed "cluster $c is reachable" else - warn "could not obtain cluster info for $c (with kubeconfig=$kc). Contents:\n$(cat $kc)" + warn "could not obtain cluster info for $c. Kubeconfig:\n$(kubectl config view)" return 1 fi done diff --git a/tests/runner.sh b/tests/runner.sh index f3f3e10e..289d5d8b 100755 --- a/tests/runner.sh +++ b/tests/runner.sh @@ -10,6 +10,10 @@ source "$CURR_DIR/common.sh" [ -n "$EXE" ] || abort "no EXE provided" +info "Preparing filesystem and environment..." + +mkdir -p /root/.kube + info "Starting e2e tests..." for i in $CURR_DIR/test_*.sh ; do diff --git a/tests/test_multi_master.sh b/tests/test_multi_master.sh index 256c3d73..3e095f76 100755 --- a/tests/test_multi_master.sh +++ b/tests/test_multi_master.sh @@ -9,20 +9,22 @@ source "$CURR_DIR/common.sh" info "Creating cluster multimaster..." $EXE --verbose create cluster "multimaster" --masters 3 --api-port 6443 --wait --timeout 360s || failed "could not create cluster multimaster" -info "Checking we have access to the cluster..." +info "Checking that we have access to the cluster..." check_k3d_clusters "multimaster" || failed "error checking cluster" -info "Checking that we have 3 servers online..." +info "Sleeping for 5 seconds to give the cluster enough time to get ready..." +sleep 5 + +info "Checking that we have 3 master nodes online..." check_multi_master() { for c in "$@" ; do - kc=$($EXE get kubeconfig "$c") - [ -n "$kc" ] || abort "could not obtain a kubeconfig for $c" - nodeCount=$(kubectl --kubeconfig="$kc" get nodes -o=custom-columns=NAME:.metadata.name --no-headers | wc -l) + $EXE get kubeconfig "$c" --switch + nodeCount=$(kubectl get nodes -o=custom-columns=NAME:.metadata.name --no-headers | wc -l) if [[ $nodeCount == 3 ]]; then passed "cluster $c has 3 nodes, as expected" else warn "cluster $c has incorrect number of nodes: $nodeCount != 3" - kubectl --kubeconfig="$kc" get nodes -o=custom-columns=NAME:.metadata.name --no-headers + kubectl get nodes -o=custom-columns=NAME:.metadata.name --no-headers return 1 fi done