diff --git a/tests/common.sh b/tests/common.sh index fe5227c9..f1529fbb 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -13,7 +13,7 @@ BLOCK='\033[1;37m' PATH=/usr/local/bin:$PATH export PATH -log() { >&2 printf "${BLOCK}>>>${END} $1\n"; } +log() { >&2 printf "$(date -u +"%Y-%m-%d %H:%M:%S %Z") [${CURRENT_STAGE:-undefined}] ${BLOCK}>>>${END} $1\n"; } info() { log "${BLU}$1${END}"; } highlight() { log "${MGT}$1${END}"; } diff --git a/tests/extra_test_k3s_versions.sh b/tests/extra_test_k3s_versions.sh index 8b2288dd..149e3c0a 100755 --- a/tests/extra_test_k3s_versions.sh +++ b/tests/extra_test_k3s_versions.sh @@ -11,6 +11,8 @@ source "$CURR_DIR/common.sh" for version in "${K3S_VERSIONS[@]}"; do + export CURRENT_STAGE="Suite | k3s-versions | $version" + info "Creating a cluster with k3s version $version ..." $EXE cluster create c1 --wait --timeout 60s --image "rancher/k3s:$version" || failed "could not create cluster with k3s version $version" diff --git a/tests/runner.sh b/tests/runner.sh index fe2a627f..b7a6c8ff 100755 --- a/tests/runner.sh +++ b/tests/runner.sh @@ -7,7 +7,9 @@ CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" : "${E2E_EXCLUDE:=""}" : "${E2E_EXTRA:=""}" -# shellcheck source=./common.sh +export CURRENT_STAGE="Runner" + +# shellcheck disable=SC1091 source "$CURR_DIR/common.sh" ######################################################################################### @@ -16,13 +18,13 @@ source "$CURR_DIR/common.sh" info "Preparing filesystem and environment..." -mkdir -p $HOME/.kube +mkdir -p "$HOME"/.kube echo "Start time inside runner: $(date)" section "BASIC TESTS" -for i in $CURR_DIR/test_*.sh ; do +for i in "$CURR_DIR"/test_*.sh ; do base=$(basename "$i" .sh) skip=false included=false @@ -64,7 +66,7 @@ done # Additional (extra) tests if [[ -n "$E2E_EXTRA" ]]; then section "EXTRA TESTS" - for i in $CURR_DIR/extra_test_*.sh ; do + for i in "$CURR_DIR"/extra_test_*.sh ; do base=$(basename "$i" .sh) if [[ $E2E_EXCLUDE =~ (^| )$base($| ) ]]; then highlight "***** Skipping $base *****" diff --git a/tests/test_basic.sh b/tests/test_basic.sh index a060cd2f..5a09aba7 100755 --- a/tests/test_basic.sh +++ b/tests/test_basic.sh @@ -6,6 +6,8 @@ CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" # shellcheck source=./common.sh source "$CURR_DIR/common.sh" +export CURRENT_STAGE="Test | basic" + info "Creating two clusters..." $EXE cluster create c1 --wait --timeout 60s --api-port 6443 --env 'TEST_VAR=user\@pass\\@server[0]' || failed "could not create cluster c1" $EXE cluster create c2 --wait --timeout 60s || failed "could not create cluster c2" diff --git a/tests/test_config_file.sh b/tests/test_config_file.sh index 989d8687..268bd4e1 100755 --- a/tests/test_config_file.sh +++ b/tests/test_config_file.sh @@ -15,6 +15,8 @@ if [[ -n "$K3S_IMAGE_TAG" ]]; then EXTRA_TITLE="(rancher/k3s:$K3S_IMAGE_TAG)" fi +export CURRENT_STAGE="Test | config-file | $K3S_IMAGE_TAG" + clustername="ConfigTest" diff --git a/tests/test_full_lifecycle.sh b/tests/test_full_lifecycle.sh index d4fd8db6..f1002b1d 100755 --- a/tests/test_full_lifecycle.sh +++ b/tests/test_full_lifecycle.sh @@ -15,6 +15,8 @@ if [[ -n "$K3S_IMAGE_TAG" ]]; then EXTRA_TITLE="(rancher/k3s:$K3S_IMAGE_TAG)" fi +export CURRENT_STAGE="Test | lifecycle | $K3S_IMAGE_TAG" + clustername="lifecycletest" diff --git a/tests/test_multi_master.sh b/tests/test_multi_master.sh index e0ce4d90..e11444b6 100755 --- a/tests/test_multi_master.sh +++ b/tests/test_multi_master.sh @@ -14,6 +14,8 @@ if [[ -n "$K3S_IMAGE_TAG" ]]; then EXTRA_TITLE="(rancher/k3s:$K3S_IMAGE_TAG)" fi +export CURRENT_STAGE="Test | multi-server | $K3S_IMAGE_TAG" + 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 $EXTRA_TITLE" info "Checking that we have access to the cluster..." diff --git a/tests/test_multi_master_start_stop.sh b/tests/test_multi_master_start_stop.sh index 2ebcb930..f1fab70d 100755 --- a/tests/test_multi_master_start_stop.sh +++ b/tests/test_multi_master_start_stop.sh @@ -14,6 +14,8 @@ if [[ -n "$K3S_IMAGE_TAG" ]]; then EXTRA_TITLE="(rancher/k3s:$K3S_IMAGE_TAG)" fi +export CURRENT_STAGE="Test | multi-server-start-stop | $K3S_IMAGE_TAG" + 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 $EXTRA_TITLE" info "Checking that we have access to the cluster..." @@ -31,8 +33,8 @@ $EXE cluster stop "multiserver" || failed "failed to stop cluster" info "Waiting for a bit..." sleep 5 -info "Restarting cluster..." -$EXE cluster start multiserver || failed "failed to restart cluster" +info "Restarting cluster (time: $(date -u +"%Y-%m-%d %H:%M:%S %Z"))..." +$EXE cluster start multiserver --timeout 180s || failed "failed to restart cluster (timeout 180s)" info "Sleeping for 5 seconds to give the cluster enough time to get ready..." sleep 5 diff --git a/tests/test_registry.sh b/tests/test_registry.sh index f323d6db..f444f750 100755 --- a/tests/test_registry.sh +++ b/tests/test_registry.sh @@ -15,6 +15,8 @@ if [[ -n "$K3S_IMAGE_TAG" ]]; then EXTRA_TITLE="(rancher/k3s:$K3S_IMAGE_TAG)" fi +export CURRENT_STAGE="Test | registry | $K3S_IMAGE_TAG" + clustername="registrytest"