E2E: add extra tests and test different k3s versions

pull/364/head
iwilltry42 4 years ago
parent 9bf264aaa9
commit a578c32260
No known key found for this signature in database
GPG Key ID: 7BA57AD1CFF16110
  1. 3
      Makefile
  2. 7
      tests/common.sh
  3. 1
      tests/dind.sh
  4. 28
      tests/extra_test_k3s_versions.sh
  5. 22
      tests/runner.sh
  6. 11
      tests/test_multi_master.sh

@ -42,6 +42,7 @@ REC_DIRS := cmd
########## Test Settings ##########
E2E_LOG_LEVEL ?= WARN
E2E_SKIP ?=
E2E_EXTRA ?=
E2E_RUNNER_START_TIMEOUT ?= 10
########## Go Build Options ##########
@ -152,7 +153,7 @@ check: check-fmt lint
e2e: build-docker-dind
@echo "Running e2e tests in k3d:$(K3D_IMAGE_TAG)"
LOG_LEVEL="$(E2E_LOG_LEVEL)" E2E_SKIP="$(E2E_SKIP)" E2E_RUNNER_START_TIMEOUT=$(E2E_RUNNER_START_TIMEOUT) tests/dind.sh "${K3D_IMAGE_TAG}-dind"
LOG_LEVEL="$(E2E_LOG_LEVEL)" E2E_SKIP="$(E2E_SKIP)" E2E_EXTRA="$(E2E_EXTRA)" E2E_RUNNER_START_TIMEOUT=$(E2E_RUNNER_START_TIMEOUT) tests/dind.sh "${K3D_IMAGE_TAG}-dind"
ci-tests: fmt check e2e

@ -51,6 +51,13 @@ passed() {
fi
}
section() {
title_length=$((${#1}+4))
log "$(printf "${CYA}#%.0s${END}" $(eval "echo {1.."$(($title_length))"}"); printf "\n";)"
log "$(printf "${CYA}#${END} %s ${CYA}#${END}\n" "$1")"
log "$(printf "${CYA}#%.0s${END}" $(eval "echo {1.."$(($title_length))"}"); printf "\n";)"
}
# checks that a URL is available, with an optional error message
check_url() {
command_exists curl || abort "curl is not installed"

@ -20,6 +20,7 @@ k3de2e=$(docker run -d \
-e CI="true" \
-e LOG_LEVEL="$LOG_LEVEL" \
-e E2E_SKIP="$E2E_SKIP" \
-e E2E_EXTRA="$E2E_EXTRA" \
--name "k3d-e2e-runner-$TIMESTAMP" \
"k3d:$K3D_IMAGE_TAG")

@ -0,0 +1,28 @@
#!/bin/bash
CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
[ -d "$CURR_DIR" ] || { echo "FATAL: no current dir (maybe running in zsh?)"; exit 1; }
K3S_VERSIONS=("v1.17.12-k3s1" "v1.18.9-k3s1" "v1.19.1-k3s1")
# shellcheck source=./common.sh
source "$CURR_DIR/common.sh"
for version in "${K3S_VERSIONS[@]}"; do
info "Creating a cluster with k3s version $version ..."
$EXE cluster create c1 --wait --timeout 60s --api-port 6443 --image "rancher/k3s:$version" || failed "could not create cluster with k3s version $version"
info "Checking we have access to the cluster ..."
check_clusters "c1" || failed "error checking cluster with k3s version $version"
info "Deleting cluster ..."
$EXE cluster delete c1 || failed "could not delete the cluster c1"
K3S_IMAGE_TAG="$version" $CURR_DIR/test_multi_master.sh
done
exit 0

@ -4,6 +4,7 @@ CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
[ -d "$CURR_DIR" ] || { echo "FATAL: no current dir (maybe running in zsh?)"; exit 1; }
: "${E2E_SKIP:=""}"
: "${E2E_EXTRA:=""}"
# shellcheck source=./common.sh
source "$CURR_DIR/common.sh"
@ -16,15 +17,32 @@ info "Preparing filesystem and environment..."
mkdir -p $HOME/.kube
section "BASIC TESTS"
for i in $CURR_DIR/test_*.sh ; do
base=$(basename $i .sh)
base=$(basename "$i" .sh)
if [[ $E2E_SKIP =~ (^| )$base($| ) ]]; then
highlight "***** Skipping $base *****"
else
highlight "***** Running $base *****"
$i || abort "test $base failed"
"$i" || abort "test $base failed"
fi
done
if [[ -n "$E2E_EXTRA" ]]; then
section "EXTRA TESTS"
for i in $CURR_DIR/extra_test_*.sh ; do
base=$(basename "$i" .sh)
if [[ $E2E_SKIP =~ (^| )$base($| ) ]]; then
highlight "***** Skipping $base *****"
else
highlight "***** Running $base *****"
"$i" || abort "test $base failed"
fi
done
else
info "NOT running EXTRA tests, please set E2E_EXTRA=1 if you wish to do so"
fi
exit 0

@ -6,9 +6,16 @@ CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# shellcheck source=./common.sh
source "$CURR_DIR/common.sh"
info "Creating cluster multiserver..."
$EXE cluster create "multiserver" --servers 3 --api-port 6443 --wait --timeout 360s || failed "could not create cluster multiserver"
: "${EXTRA_FLAG:=""}"
: "${EXTRA_TITLE:=""}"
if [[ -n "$K3S_IMAGE_TAG" ]]; then
EXTRA_FLAG="--image rancher/k3s:$K3S_IMAGE_TAG"
EXTRA_TITLE="(rancher/k3s:$K3S_IMAGE_TAG)"
fi
info "Creating cluster multiserver $EXTRA_TITLE ..."
$EXE cluster create "multiserver" --servers 3 --api-port 6443 --wait --timeout 360s $EXTRA_FLAG || failed "could not create cluster multiserver"
info "Checking that we have access to the cluster..."
check_clusters "multiserver" || failed "error checking cluster"

Loading…
Cancel
Save