tests/e2e: adapt e2e tests to new kubeconfig logic

pull/226/head
iwilltry42 4 years ago
parent 48f8393a86
commit 347fd1e78a
No known key found for this signature in database
GPG Key ID: 7BA57AD1CFF16110
  1. 10
      tests/common.sh
  2. 4
      tests/runner.sh
  3. 14
      tests/test_multi_master.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

@ -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

@ -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

Loading…
Cancel
Save