From 66b9e9c4c8138a2265b95f78dc5e9b3a0c54f22a Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Mon, 1 Mar 2021 11:49:26 -0800 Subject: [PATCH] Suppress test failure due to incompatible server Signed-off-by: Brad Davidson --- scripts/test-helpers | 17 ++++++++++++++--- scripts/test-run-compat | 9 +++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/scripts/test-helpers b/scripts/test-helpers index bb3aa2a5a1..b59fec2982 100755 --- a/scripts/test-helpers +++ b/scripts/test-helpers @@ -134,7 +134,7 @@ dump-logs() { mkdir -p $node/logs local hostname=$(docker exec $name hostname) docker logs $name >$node/logs/system.log 2>&1 - if [[ $name == k3s-* ]]; then + if [[ ! -z "$hostname" && $name == k3s-* ]]; then docker exec $server kubectl describe node/$hostname >$node/logs/kubectl-describe-node.txt docker cp $name:/var/lib/rancher/k3s/agent/containerd/containerd.log $node/logs/containerd.log 2>/dev/null docker exec $name crictl pods >$node/logs/crictl-pods.txt @@ -263,12 +263,16 @@ test-cleanup() { echo "Removing container $container" docker rm -f -v $container done + echo + if has-function test-post-hook; then + test-post-hook $code + code=$? + fi if [ "$TEST_CLEANUP" = true ]; then echo "Removing test directory $TEST_DIR" rm -rf $TEST_DIR fi [ -f "$PROVISION_LOCK" ] && rm $PROVISION_LOCK - echo echo -n "Test $(basename $TEST_DIR) " if [ $code -eq 0 ]; then echo "passed." @@ -392,8 +396,15 @@ export -f inc-count # --- +has-function() { + [[ ! -z "$1" && $(type -t $1) == "function" ]] +} 2> /dev/null +export -f has-function + +# --- + run-function() { - declare -f $1 >/dev/null 2>&1 || return 0 + has-function $1 || return 0 $@ } export -f run-function diff --git a/scripts/test-run-compat b/scripts/test-run-compat index 4833e650e4..78ba93f345 100755 --- a/scripts/test-run-compat +++ b/scripts/test-run-compat @@ -17,6 +17,15 @@ start-test() { } export -f start-test +# --- suppress test failures if the agent is intentionally incompatible with the server version +test-post-hook() { + if [[ $1 -eq 0 ]]; then + return + fi + grep -sqF 'incompatible down-level server detected' $TEST_DIR/agents/*/logs/system.log +} +export -f test-post-hook + REPO=${REPO:-rancher} IMAGE_NAME=${IMAGE_NAME:-k3s} PREVIOUS_CHANNEL=$(curl -s https://update.k3s.io/v1-release/channels/stable -o /dev/null -w '%{redirect_url}' | awk -F. '{print "v1." ($(NF - 1) - 1)}')