tests/e2e: more extensive k3s version tests
This commit is contained in:
parent
d097caf7d3
commit
5cea7eae0a
@ -23,7 +23,7 @@ bye() {
|
||||
exit 0
|
||||
}
|
||||
|
||||
warn() { log "${RED}!!! WARNING !!! $1 ${END}"; }
|
||||
warn() { log "${RED}WARN: $1 ${END}"; }
|
||||
|
||||
abort() {
|
||||
log "${RED}FATAL: $1${END}"
|
||||
@ -158,7 +158,7 @@ wait_for_pod_exec() {
|
||||
max_retries=$([[ -n "$3" ]] && echo "$3" || echo "10")
|
||||
for (( i=0; i<=max_retries; i++ )); do
|
||||
echo "Try #$i: 'kubectl exec $1 -- $2'"
|
||||
kubectl exec "$1" -- $2 && return 0
|
||||
kubectl exec "$1" -- $2 > /dev/null && return 0
|
||||
sleep 1
|
||||
done
|
||||
echo "Command '$2' in pod '$1' did NOT return successfully in $max_retries tries"
|
||||
|
@ -4,7 +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; }
|
||||
|
||||
K3S_VERSIONS=("v1.17.12-k3s1" "v1.18.9-k3s1" "v1.19.2-k3s1")
|
||||
FAILED_VERSIONS=()
|
||||
FAILED_TESTS=()
|
||||
|
||||
# shellcheck source=./common.sh
|
||||
source "$CURR_DIR/common.sh"
|
||||
@ -20,15 +20,23 @@ for version in "${K3S_VERSIONS[@]}"; do
|
||||
info "Deleting cluster ..."
|
||||
$EXE cluster delete c1 || failed "could not delete the cluster c1"
|
||||
|
||||
K3S_IMAGE_TAG="$version" $CURR_DIR/test_full_lifecycle.sh
|
||||
if [[ $? -eq 1 ]]; then
|
||||
FAILED_TESTS+=("full_lifecycle: $version")
|
||||
fi
|
||||
|
||||
K3S_IMAGE_TAG="$version" $CURR_DIR/test_multi_master.sh
|
||||
if [[ $? -eq 1 ]]; then
|
||||
FAILED_VERSIONS+=("$version")
|
||||
FAILED_TESTS+=("multi_master: $version")
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
if [[ ${#FAILED_VERSIONS[@]} -gt 0 ]]; then
|
||||
failed "Tests failed for k3s versions: ${FAILED_VERSIONS[*]}"
|
||||
if [[ ${#FAILED_TESTS[@]} -gt 0 ]]; then
|
||||
warn "FAILED TESTS"
|
||||
for failed_test in "${FAILED_TESTS[@]}"; do
|
||||
warn "- $failed_test"
|
||||
done
|
||||
else
|
||||
passed "Successfully verified all given k3s versions"
|
||||
exit 0
|
||||
|
@ -6,10 +6,22 @@ CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
# shellcheck source=./common.sh
|
||||
source "$CURR_DIR/common.sh"
|
||||
|
||||
|
||||
: "${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
|
||||
|
||||
|
||||
clustername="lifecycletest"
|
||||
|
||||
highlight "[START] Lifecycletest $EXTRA_TITLE"
|
||||
|
||||
info "Creating cluster $clustername..."
|
||||
$EXE cluster create "$clustername" --agents 1 --api-port 6443 --wait --timeout 360s || failed "could not create cluster $clustername"
|
||||
$EXE cluster create "$clustername" --agents 1 --api-port 6443 --wait --timeout 360s $EXTRA_FLAG || failed "could not create cluster $clustername $EXTRA_TITLE"
|
||||
|
||||
info "Sleeping for 5 seconds to give the cluster enough time to get ready..."
|
||||
sleep 5
|
||||
@ -71,6 +83,8 @@ wait_for_pod_exec "testimage" "nslookup host.k3d.internal" 15 || failed "DNS Loo
|
||||
info "Deleting cluster $clustername..."
|
||||
$EXE cluster delete "$clustername" || failed "could not delete the cluster $clustername"
|
||||
|
||||
highlight "[DONE] Lifecycletest $EXTRA_TITLE"
|
||||
|
||||
exit 0
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user