tests/e2e: adapt e2e tests to new kubeconfig logic

This commit is contained in:
iwilltry42 2020-04-22 09:14:55 +02:00
parent 48f8393a86
commit 347fd1e78a
No known key found for this signature in database
GPG Key ID: 7BA57AD1CFF16110
3 changed files with 17 additions and 11 deletions

View File

@ -60,12 +60,12 @@ check_url() {
check_k3d_clusters() { check_k3d_clusters() {
[ -n "$EXE" ] || abort "EXE is not defined" [ -n "$EXE" ] || abort "EXE is not defined"
for c in "$@" ; do for c in "$@" ; do
kc=$($EXE get kubeconfig "$c") $EXE --verbose get kubeconfig "$c" --switch
[ -n "$kc" ] || abort "could not obtain a kubeconfig for $c" #[ -n "$kc" ] || abort "could not obtain a kubeconfig for $c"
if kubectl --kubeconfig="$kc" cluster-info ; then if kubectl cluster-info ; then
passed "cluster $c is reachable (with kubeconfig=$kc)" passed "cluster $c is reachable"
else 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 return 1
fi fi
done done

View File

@ -10,6 +10,10 @@ source "$CURR_DIR/common.sh"
[ -n "$EXE" ] || abort "no EXE provided" [ -n "$EXE" ] || abort "no EXE provided"
info "Preparing filesystem and environment..."
mkdir -p /root/.kube
info "Starting e2e tests..." info "Starting e2e tests..."
for i in $CURR_DIR/test_*.sh ; do for i in $CURR_DIR/test_*.sh ; do

View File

@ -9,20 +9,22 @@ source "$CURR_DIR/common.sh"
info "Creating cluster multimaster..." info "Creating cluster multimaster..."
$EXE --verbose create cluster "multimaster" --masters 3 --api-port 6443 --wait --timeout 360s || failed "could not create 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" 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() { check_multi_master() {
for c in "$@" ; do for c in "$@" ; do
kc=$($EXE get kubeconfig "$c") $EXE get kubeconfig "$c" --switch
[ -n "$kc" ] || abort "could not obtain a kubeconfig for $c" nodeCount=$(kubectl get nodes -o=custom-columns=NAME:.metadata.name --no-headers | wc -l)
nodeCount=$(kubectl --kubeconfig="$kc" get nodes -o=custom-columns=NAME:.metadata.name --no-headers | wc -l)
if [[ $nodeCount == 3 ]]; then if [[ $nodeCount == 3 ]]; then
passed "cluster $c has 3 nodes, as expected" passed "cluster $c has 3 nodes, as expected"
else else
warn "cluster $c has incorrect number of nodes: $nodeCount != 3" 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 return 1
fi fi
done done