From c8f8938cae9a5c64990d06f4509c17e94c4fba2a Mon Sep 17 00:00:00 2001 From: Justin SB Date: Fri, 7 May 2021 08:42:06 -0400 Subject: [PATCH] Create upgrade_ab e2e scenario for complex upgrades The intent is that we'll be able to perform arbitrary upgrades/downgrades; creating a new scenario to avoid breaking existing tests. Co-authored-by: Peter Rifel --- tests/e2e/scenarios/upgrade-ab/run-test.sh | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100755 tests/e2e/scenarios/upgrade-ab/run-test.sh diff --git a/tests/e2e/scenarios/upgrade-ab/run-test.sh b/tests/e2e/scenarios/upgrade-ab/run-test.sh new file mode 100755 index 0000000000..2e371fc864 --- /dev/null +++ b/tests/e2e/scenarios/upgrade-ab/run-test.sh @@ -0,0 +1,89 @@ +#!/usr/bin/env bash + +# Copyright 2021 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +echo "CLOUD_PROVIDER=${CLOUD_PROVIDER}" + +if [ -z "$KOPS_VERSION_A" ] || [ -z "$K8S_VERSION_A" ] || [ -z "$KOPS_VERSION_B" ] || [ -z "$K8S_VERSION_B" ]; then + >&2 echo "must set all of KOPS_VERSION_A, K8S_VERSION_A, KOPS_VERSION_B, K8S_VERSION_B env vars" + exit 1 +fi + +WORKDIR=$(mktemp) + +KOPS_A=${WORKDIR}/kops-${KOPS_VERSION_A} +wget -O "${KOPS_A}" "https://github.com/kubernetes/kops/releases/download/$KOPS_VERSION_A/kops-$(go env GOOS)-$(go env GOARCH)" +chmod +x "${KOPS_A}" + +KOPS_B=${WORKDIR}/kops-${KOPS_VERSION_B} +if [[ "${KOPS_VERSION_B}" == "source" ]]; then + export KOPS_FEATURE_FLAGS="SpecOverrideFlag,${KOPS_FEATURE_FLAGS:-}" + REPO_ROOT=$(git rev-parse --show-toplevel); + + cp "${REPO_ROOT}/bazel-bin/cmd/kops/linux-amd64/kops" "${KOPS_B}" +else + wget -O "${KOPS_B}" "https://github.com/kubernetes/kops/releases/download/$KOPS_VERSION_B/kops-$(go env GOOS)-$(go env GOARCH)" + chmod +x "${KOPS_B}" +fi + +KUBETEST2="kubetest2 kops -v=2 --cloud-provider=${CLOUD_PROVIDER} --cluster-name=${CLUSTER_NAME:-}" +KUBETEST2="${KUBETEST2} --admin-access=${ADMIN_ACCESS:-}" + +export GO111MODULE=on + +cd "${REPO_ROOT}/tests/e2e" +go install sigs.k8s.io/kubetest2 +go install ./kubetest2-kops +go install ./kubetest2-tester-kops + +${KUBETEST2} --build --kops-root="${REPO_ROOT}" --stage-location="${STAGE_LOCATION:-}" --kops-binary-path="${KOPS_B}" + +# Always tear-down the cluster when we're done +function finish { + ${KUBETEST2} --kops-binary-path="${KOPS_B}" --down || echo "kubetest2 down failed" +} +trap finish EXIT + +${KUBETEST2} \ + --up \ + --kops-binary-path="${KOPS_A}" \ + --kubernetes-version="${K8S_VERSION_A}" \ + --create-args="--networking calico" + + +"${KOPS_B}" set cluster "${CLUSTER_NAME}" "cluster.spec.kubernetesVersion=${K8S_VERSION_B}" + +"${KOPS_B}" update cluster +"${KOPS_B}" update cluster --admin --yes +# Verify no additional changes +"${KOPS_B}" update cluster + +"${KOPS_B}" rolling-update cluster +"${KOPS_B}" rolling-update cluster --yes --validation-timeout 30m + +"${KOPS_B}" validate cluster + +${KUBETEST2} \ + --cloud-provider="${CLOUD_PROVIDER}" \ + --kops-binary-path="${KOPS_B}" \ + --test=kops \ + -- \ + --test-package-version="${K8S_VERSION_B}" \ + --parallel 25 \ + --skip-regex="\[Slow\]|\[Serial\]|\[Disruptive\]|\[Flaky\]|\[Feature:.+\]|\[HPA\]|Dashboard|RuntimeClass|RuntimeHandler|TCP.CLOSE_WAIT|Projected.configMap.optional.updates"