Merge pull request #11382 from rifelpet/kubetest2

Kubetest2 - Update k8s upgrade test + add kops upgrade test
This commit is contained in:
Kubernetes Prow Robot 2021-05-05 04:09:15 -07:00 committed by GitHub
commit f3f131f745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 95 additions and 26 deletions

View File

@ -24,30 +24,30 @@ export KOPS_FEATURE_FLAGS="SpecOverrideFlag,${KOPS_FEATURE_FLAGS:-}"
REPO_ROOT=$(git rev-parse --show-toplevel);
PATH=$REPO_ROOT/bazel-bin/cmd/kops/$(go env GOOS)-$(go env GOARCH):$PATH
KUBETEST2_COMMON_ARGS="-v=2 --cloud-provider=${CLOUD_PROVIDER} --cluster-name=${CLUSTER_NAME:-} --kops-binary-path=${REPO_ROOT}/bazel-bin/cmd/kops/linux-amd64/kops"
KUBETEST2_COMMON_ARGS="${KUBETEST2_COMMON_ARGS} --admin-access=${ADMIN_ACCESS:-}"
KUBETEST2="kubetest2 kops -v=2 --cloud-provider=${CLOUD_PROVIDER} --cluster-name=${CLUSTER_NAME:-}"
KUBETEST2="${KUBETEST2} --kops-binary-path=${REPO_ROOT}/bazel-bin/cmd/kops/linux-amd64/kops --admin-access=${ADMIN_ACCESS:-}"
export GO111MODULE=on
cd ${REPO_ROOT}/tests/e2e
cd "${REPO_ROOT}/tests/e2e"
go install sigs.k8s.io/kubetest2
go install ./kubetest2-kops
go install ./kubetest2-tester-kops
kubetest2 kops ${KUBETEST2_COMMON_ARGS} --build --kops-root=${REPO_ROOT} --stage-location=${STAGE_LOCATION:-}
${KUBETEST2} --build --kops-root="${REPO_ROOT}" --stage-location="${STAGE_LOCATION:-}"
# Always tear-down the cluster when we're done
function finish {
kubetest2 kops ${KUBETEST2_COMMON_ARGS} --down || echo "kubetest2 down failed"
${KUBETEST2} --down || echo "kubetest2 down failed"
}
trap finish EXIT
kubetest2 kops ${KUBETEST2_COMMON_ARGS} \
${KUBETEST2} \
--up \
--kubernetes-version=v1.18.15 \
--kubernetes-version=v1.19.10 \
--create-args="--networking calico"
kops set cluster ${CLUSTER_NAME} cluster.spec.kubernetesVersion=v1.19.7
kops set cluster "${CLUSTER_NAME}" cluster.spec.kubernetesVersion=v1.20.6
kops update cluster
kops update cluster --admin --yes
@ -56,26 +56,11 @@ kops rolling-update cluster --yes --validation-timeout 30m
kops validate cluster
KUBECONFIG=${HOME}/.kube/config
TEST_ARGS="--kubeconfig=${KUBECONFIG}"
if [[ "${CLOUD_PROVIDER}" == "aws" ]]; then
ZONES=`kops get cluster ${CLUSTER_NAME} -ojson | jq -r .spec.subnets[].zone`
CLUSTER_TAG="${CLUSTER_NAME}"
TEST_ARGS="${TEST_ARGS} --provider=aws --cluster-tag=${CLUSTER_TAG}"
# For historical reasons, the flag name for e2e tests on AWS is --gce-zone
TEST_ARGS="${TEST_ARGS} --gce-zone=${ZONES[0]}"
fi
if [[ "${CLOUD_PROVIDER}" == "gce" ]]; then
ZONES=`kops get ig --name ${CLUSTER_NAME} -ojson | jq -r .[0].spec.zones[]`
GCE_PROJECT=`kops get cluster ${CLUSTER_NAME} -ojson |jq -r .spec.project`
TEST_ARGS="${TEST_ARGS} --provider=gce --gce-zone=${ZONES[0]} --gce-project=${GCE_PROJECT}"
fi
kubetest2 kops ${KUBETEST2_COMMON_ARGS} \
--cloud-provider=${CLOUD_PROVIDER} \
${KUBETEST2} \
--cloud-provider="${CLOUD_PROVIDER}" \
--test=kops \
-- \
--test-package-version=v1.18.15 \
--test-package-version=v1.20.6 \
--parallel 25 \
--skip-regex="\[Slow\]|\[Serial\]|\[Disruptive\]|\[Flaky\]|\[Feature:.+\]|\[HPA\]|Dashboard|RuntimeClass|RuntimeHandler|TCP.CLOSE_WAIT|Projected.configMap.optional.updates" \
--test-args="${TEST_ARGS}"

View File

@ -0,0 +1,84 @@
#!/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}"
FIRST_VERSION=$1
K8S_VERSION=$2
if [ -z "$FIRST_VERSION" ] || [ -z "$K8S_VERSION" ]; then
>&2 echo "Usage: '$0 <first-kops-version> <k8s-version>'"
exit 1
fi
FIRST_KOPS=$(mktemp -t kops)
wget -o "${FIRST_KOPS}" "https://github.com/kubernetes/kops/releases/download/$FIRST_VERSION/kops-$(go env GOOS)-$(go env GOARCH)"
chmod +x "${FIRST_KOPS}"
export KOPS_FEATURE_FLAGS="SpecOverrideFlag,${KOPS_FEATURE_FLAGS:-}"
REPO_ROOT=$(git rev-parse --show-toplevel);
SECOND_KOPS="${REPO_ROOT}/bazel-bin/cmd/kops/linux-amd64/kops"
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="${SECOND_KOPS}"
# Always tear-down the cluster when we're done
function finish {
${KUBETEST2} --kops-binary-path="${SECOND_KOPS}" --down || echo "kubetest2 down failed"
}
trap finish EXIT
${KUBETEST2} \
--up \
--kops-binary-path="${FIRST_KOPS}" \
--kubernetes-version="${K8S_VERSION}" \
--create-args="--networking calico"
"${SECOND_KOPS}" update cluster
"${SECOND_KOPS}" update cluster --admin --yes
"${SECOND_KOPS}" rolling-update cluster
"${SECOND_KOPS}" rolling-update cluster --yes --validation-timeout 30m
"${SECOND_KOPS}" validate cluster
KUBECONFIG=${HOME}/.kube/config
TEST_ARGS="--kubeconfig=${KUBECONFIG}"
${KUBETEST2} \
--cloud-provider="${CLOUD_PROVIDER}" \
--kops-binary-path="${SECOND_KOPS}" \
--test=kops \
-- \
--test-package-version="${K8S_VERSION}" \
--parallel 25 \
--skip-regex="\[Slow\]|\[Serial\]|\[Disruptive\]|\[Flaky\]|\[Feature:.+\]|\[HPA\]|Dashboard|RuntimeClass|RuntimeHandler|TCP.CLOSE_WAIT|Projected.configMap.optional.updates" \
--test-args="${TEST_ARGS}"