diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a310ace9d..a40bd3b6f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -36,7 +36,13 @@ jobs: run: make test - name: Run E2E Tests timeout-minutes: 20 - run: make e2e -e E2E_LOG_LEVEL=trace + # Quite often, tests were failing due to "too many open files" errors, so we're fixing this here + # Also, we want to see trace level logs if tests fail and the pipeline should exit on first error + run: | + sudo prlimit --pid $$ --nofile=1048576:1048576 + sudo sysctl fs.inotify.max_user_instances=1280 + sudo sysctl fs.inotify.max_user_watches=655360 + make e2e -e E2E_LOG_LEVEL=trace -e E2E_FAIL_FAST=true # Builds - name: Test Platform Builds run: make build-cross diff --git a/Makefile b/Makefile index fa7efb869..c7ef0abca 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,7 @@ E2E_KEEP ?= E2E_PARALLEL ?= E2E_DIND_VERSION ?= E2E_K3S_VERSION ?= +E2E_FAIL_FAST ?= ########## Go Build Options ########## # Build targets @@ -179,7 +180,7 @@ test: e2e: @echo "Running e2e tests" - LOG_LEVEL="$(E2E_LOG_LEVEL)" E2E_INCLUDE="$(E2E_INCLUDE)" E2E_EXCLUDE="$(E2E_EXCLUDE)" E2E_EXTRA="$(E2E_EXTRA)" E2E_RUNNER_START_TIMEOUT=$(E2E_RUNNER_START_TIMEOUT) E2E_HELPER_IMAGE_TAG="$(E2E_HELPER_IMAGE_TAG)" E2E_KEEP="$(E2E_KEEP)" E2E_PARALLEL="$(E2E_PARALLEL)" E2E_DIND_VERSION="$(E2E_DIND_VERSION)" E2E_K3S_VERSION="$(E2E_K3S_VERSION)" tests/dind.sh "${K3D_IMAGE_TAG}" + LOG_LEVEL="$(E2E_LOG_LEVEL)" E2E_INCLUDE="$(E2E_INCLUDE)" E2E_EXCLUDE="$(E2E_EXCLUDE)" E2E_EXTRA="$(E2E_EXTRA)" E2E_RUNNER_START_TIMEOUT=$(E2E_RUNNER_START_TIMEOUT) E2E_HELPER_IMAGE_TAG="$(E2E_HELPER_IMAGE_TAG)" E2E_KEEP="$(E2E_KEEP)" E2E_PARALLEL="$(E2E_PARALLEL)" E2E_DIND_VERSION="$(E2E_DIND_VERSION)" E2E_K3S_VERSION="$(E2E_K3S_VERSION)" E2E_FAIL_FAST="$(E2E_FAIL_FAST)" tests/dind.sh "${K3D_IMAGE_TAG}" ci-tests: fmt check e2e diff --git a/tests/common.sh b/tests/common.sh index 0ecafdc07..bd6689af1 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -45,7 +45,10 @@ failed() { elif [[ -n "$LOG_FILE" ]]; then mv "$LOG_FILE" "$LOG_FILE.failed" fi - abort "test failed" + abort "$CURRENT_STAGE: test failed" + if [[ "$E2E_FAIL_FAST" == "true" ]]; then + exit 1 + fi } passed() { @@ -73,11 +76,16 @@ check_url() { check_clusters() { [ -n "$EXE" ] || abort "EXE is not defined" for c in "$@" ; do - $EXE kubeconfig merge "$c" --kubeconfig-switch-context || return 1 - if kubectl cluster-info ; then - passed "cluster $c is reachable" + if $EXE kubeconfig merge "$c" --kubeconfig-switch-context; then + if kubectl cluster-info ; then + passed "cluster $c is reachable" + else + warn "could not obtain cluster info for $c. Kubeconfig:\n$(kubectl config view)" + docker ps -a + return 1 + fi else - warn "could not obtain cluster info for $c. Kubeconfig:\n$(kubectl config view)" + warn "could not merge kubeconfig for $c." docker ps -a return 1 fi diff --git a/tests/dind.sh b/tests/dind.sh index ae0e00183..20bd7493d 100755 --- a/tests/dind.sh +++ b/tests/dind.sh @@ -15,6 +15,9 @@ RUNNER_START_TIMEOUT=${E2E_RUNNER_START_TIMEOUT:-10} # Override Docker-in-Docker version E2E_DIND_VERSION=${E2E_DIND_VERSION:-} +# Fail on first error instead of waiting until all tests are done. Useful in CI. +E2E_FAIL_FAST=${E2E_FAIL_FAST:-} + #################################################################################### CURR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" @@ -50,6 +53,7 @@ k3de2e=$(docker run -d \ -e EXE="$K3D_EXE" \ -e CI="true" \ -e LOG_LEVEL="$LOG_LEVEL" \ + -e E2E_FAIL_FAST="$E2E_FAIL_FAST" \ -e E2E_INCLUDE="$E2E_INCLUDE" \ -e E2E_EXCLUDE="$E2E_EXCLUDE" \ -e E2E_PARALLEL="$E2E_PARALLEL" \ diff --git a/tests/test_config_file_from_stdin.sh b/tests/test_config_file_from_stdin.sh index 802f409d2..3e0b0b093 100755 --- a/tests/test_config_file_from_stdin.sh +++ b/tests/test_config_file_from_stdin.sh @@ -28,22 +28,18 @@ fi export CURRENT_STAGE="Test | config-file-stdin | $K3S_IMAGE" -configfileoriginal="$CURR_DIR/assets/config_test_simple.yaml" -configfile="/tmp/config_test_simple-tmp_$(date -u +'%Y%m%dT%H%M%SZ').yaml" clustername="configteststdin" -sed -E "s/^ name:.+/ name: $clustername/g" < "$configfileoriginal" > "$configfile" # replace cluster name in config file so we can use it in this script without running into override issues -cat "$configfile" highlight "[START] ConfigTest $EXTRA_TITLE" info "Creating cluster $clustername..." -cat <