Sitelet https://github.com/kubernetes/kops/commit/b3582d7e328a62a69971040d2f6be04af2f68f20
Skip to content

Commit b3582d7

Browse files
committed
Migrate more scenario scripts to --test=exec
1 parent 5599e87 commit b3582d7

10 files changed

Lines changed: 361 additions & 169 deletions

File tree

‎tests/e2e/scenarios/addon-resource-tracking/run-test.sh‎

Lines changed: 25 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -15,58 +15,32 @@
1515
# limitations under the License.
1616

1717
REPO_ROOT=$(git rev-parse --show-toplevel);
18+
TEST_ROOT="${REPO_ROOT}/tests/e2e/scenarios/addon-resource-tracking"
1819

1920
export KOPS_FEATURE_FLAGS="SpecOverrideFlag"
20-
source "${REPO_ROOT}"/tests/e2e/scenarios/lib/common.sh
2121

22-
function haveds() {
23-
local ds=0
24-
kubectl get ds -n kube-system aws-node-termination-handler --show-labels || ds=$?
25-
return $ds
26-
}
27-
28-
# Start a cluster with an old version of channel
29-
30-
export KOPS_BASE_URL
31-
KOPS_BASE_URL="https://artifacts.k8s.io/binaries/kops/1.29.2"
32-
KOPS=$(kops-download-from-base)
33-
34-
# Start with a cluster running nodeTerminationHandler
35-
ARGS="--set=cluster.spec.cloudProvider.aws.nodeTerminationHandler.enabled=true"
36-
ARGS="${ARGS} --set=cluster.spec.cloudProvider.aws.nodeTerminationHandler.enableSQSTerminationDraining=false"
37-
38-
${KUBETEST2} \
39-
--up \
22+
make test-e2e-install
23+
24+
# Download kOps 1.29.2 to create the initial cluster
25+
export KOPS_BASE_URL="https://artifacts.k8s.io/binaries/kops/1.29.2"
26+
KOPS_BIN=$(mktemp -t kops.XXXXXXXXX)
27+
wget -qO "${KOPS_BIN}" "$KOPS_BASE_URL/$(go env GOOS)/$(go env GOARCH)/kops"
28+
chmod +x "${KOPS_BIN}"
29+
30+
# Create cluster with nodeTerminationHandler enabled (DaemonSet mode)
31+
CREATE_ARGS="--networking calico"
32+
CREATE_ARGS="${CREATE_ARGS} --set=cluster.spec.cloudProvider.aws.nodeTerminationHandler.enabled=true"
33+
CREATE_ARGS="${CREATE_ARGS} --set=cluster.spec.cloudProvider.aws.nodeTerminationHandler.enableSQSTerminationDraining=false"
34+
35+
KUBETEST2_ARGS=()
36+
KUBETEST2_ARGS+=("-v=2")
37+
KUBETEST2_ARGS+=("--env=KOPS_FEATURE_FLAGS=${KOPS_FEATURE_FLAGS}")
38+
KUBETEST2_ARGS+=("--kops-binary-path=${KOPS_BIN}")
39+
40+
kubetest2 kops \
41+
--up --down \
42+
"${KUBETEST2_ARGS[@]}" \
43+
--cloud-provider=aws \
44+
--create-args="${CREATE_ARGS}" \
4045
--kubernetes-version="1.29.8" \
41-
--kops-binary-path="${KOPS}" \
42-
--create-args="$ARGS"
43-
44-
45-
if ! haveds; then
46-
echo "Expected aws-node-termination-handler to exist"
47-
exit 1
48-
fi
49-
50-
# Upgrade to a version that should adopt existing resources and apply the change below
51-
kops-acquire-latest
52-
53-
cp "${KOPS}" "${WORKSPACE}/kops"
54-
55-
# Switch to queue mode. This should remove the DS and install a Deployment instead
56-
kops edit cluster "${CLUSTER_NAME}" "--set=cluster.spec.cloudProvider.aws.nodeTerminationHandler.enableSQSTerminationDraining=true"
57-
58-
# allow downgrade is a bug where the version written to VFS is not the same as the running version.
59-
kops update cluster --allow-kops-downgrade
60-
kops update cluster --yes --allow-kops-downgrade
61-
62-
# Rolling-upgrade is needed so we get the new channels binary that supports prune
63-
kops rolling-update cluster --instance-group-roles=master --yes
64-
65-
# just make sure pods are ready
66-
kops validate cluster --wait=5m
67-
68-
# We should no longer have a daemonset called aws-node-termination-handler
69-
if haveds; then
70-
echo "Expected aws-node-termination-handler to have been pruned"
71-
exit 1
72-
fi
46+
--test=exec -- "${TEST_ROOT}/test.sh"
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2026 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
function haveds() {
22+
local ds=0
23+
kubectl get ds -n kube-system aws-node-termination-handler --show-labels || ds=$?
24+
return $ds
25+
}
26+
27+
# Verify we start with a DaemonSet
28+
if ! haveds; then
29+
echo "Expected aws-node-termination-handler to exist"
30+
exit 1
31+
fi
32+
33+
# Download latest kOps to upgrade the cluster
34+
KOPS_BASE_URL="$(curl -s https://storage.googleapis.com/k8s-staging-kops/kops/releases/markers/master/latest-ci-updown-green.txt)"
35+
KOPS=$(mktemp -t kops.XXXXXXXXX)
36+
wget -qO "${KOPS}" "$KOPS_BASE_URL/$(go env GOOS)/$(go env GOARCH)/kops"
37+
chmod +x "${KOPS}"
38+
39+
# Get cluster name from current context
40+
CLUSTER_NAME=$(kubectl config view --minify -o jsonpath='{.clusters[0].name}')
41+
42+
# Switch to queue mode. This should remove the DS and install a Deployment instead
43+
"${KOPS}" edit cluster "${CLUSTER_NAME}" "--set=cluster.spec.cloudProvider.aws.nodeTerminationHandler.enableSQSTerminationDraining=true"
44+
45+
# allow downgrade is a bug where the version written to VFS is not the same as the running version.
46+
"${KOPS}" update cluster --allow-kops-downgrade
47+
"${KOPS}" update cluster --yes --allow-kops-downgrade
48+
49+
# Rolling-upgrade is needed so we get the new channels binary that supports prune
50+
"${KOPS}" rolling-update cluster --instance-group-roles=master --yes
51+
52+
# just make sure pods are ready
53+
"${KOPS}" validate cluster --wait=5m
54+
55+
# We should no longer have a daemonset called aws-node-termination-handler
56+
if haveds; then
57+
echo "Expected aws-node-termination-handler to have been pruned"
58+
exit 1
59+
fi
60+
61+
echo "Test passed: aws-node-termination-handler DaemonSet was successfully pruned after upgrade"

‎tests/e2e/scenarios/aws-ebs-csi/run-test.sh‎

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,30 @@
1515
# limitations under the License.
1616

1717
REPO_ROOT=$(git rev-parse --show-toplevel);
18-
source "${REPO_ROOT}"/tests/e2e/scenarios/lib/common.sh
18+
TEST_ROOT="${REPO_ROOT}/tests/e2e/scenarios/aws-ebs-csi"
1919

20-
kops-acquire-latest
20+
make test-e2e-install
2121

22-
OVERRIDES="${OVERRIDES-} --set=cluster.spec.cloudProvider.aws.ebsCSIDriver.enabled=true"
23-
OVERRIDES="$OVERRIDES --set=cluster.spec.snapshotController.enabled=true"
24-
OVERRIDES="$OVERRIDES --set=cluster.spec.certManager.enabled=true"
25-
OVERRIDES="$OVERRIDES --control-plane-size=t3.medium --node-size=c5.large"
22+
KUBETEST2_ARGS=()
23+
KUBETEST2_ARGS+=("-v=2")
2624

27-
kops-up
28-
29-
ZONE=$(${KOPS} get ig -o json | jq -r '[.[] | select(.spec.role=="Node") | .spec.subnets[0]][0]')
30-
REPORT_DIR="${ARTIFACTS:-$(pwd)/_artifacts}/aws-ebs-csi-driver/"
31-
32-
# shellcheck disable=SC2164
33-
cd "$(mktemp -dt kops.XXXXXXXXX)"
34-
go get github.com/onsi/ginkgo/ginkgo
35-
36-
CSI_VERSION=$(kubectl get deployment -n kube-system ebs-csi-controller -o jsonpath='{.spec.template.spec.containers[?(@.name=="ebs-plugin")].image}' | cut -d':' -f2-)
37-
CLONE_ARGS=
38-
if [ -n "$CSI_VERSION" ]; then
39-
CLONE_ARGS="-b ${CSI_VERSION}"
25+
if [[ "${JOB_TYPE}" == "presubmit" && "${REPO_OWNER}/${REPO_NAME}" == "kubernetes/kops" ]]; then
26+
KUBETEST2_ARGS+=("--build")
27+
KUBETEST2_ARGS+=("--kops-binary-path=${GOPATH}/src/k8s.io/kops/.build/dist/linux/$(go env GOARCH)/kops")
28+
else
29+
KUBETEST2_ARGS+=("--kops-version-marker=${KOPS_VERSION_MARKER:-https://storage.googleapis.com/k8s-staging-kops/kops/releases/markers/master/latest-ci.txt}")
4030
fi
41-
# shellcheck disable=SC2086
42-
git clone ${CLONE_ARGS} https://github.com/kubernetes-sigs/aws-ebs-csi-driver.git .
43-
44-
# shellcheck disable=SC2164
45-
cd tests/e2e-kubernetes/
4631

47-
ginkgo --nodes=25 ./... -- -cluster-tag="${CLUSTER_NAME}" -ginkgo.skip="\[Disruptive\]" -report-dir="${REPORT_DIR}" -gce-zone="${ZONE}"
32+
CREATE_ARGS="--networking calico"
33+
CREATE_ARGS="${CREATE_ARGS} --set=cluster.spec.cloudProvider.aws.ebsCSIDriver.enabled=true"
34+
CREATE_ARGS="${CREATE_ARGS} --set=cluster.spec.snapshotController.enabled=true"
35+
CREATE_ARGS="${CREATE_ARGS} --set=cluster.spec.certManager.enabled=true"
36+
CREATE_ARGS="${CREATE_ARGS} --control-plane-size=t3.medium --node-size=c5.large"
37+
38+
kubetest2 kops \
39+
--up --down \
40+
"${KUBETEST2_ARGS[@]}" \
41+
--cloud-provider=aws \
42+
--create-args="${CREATE_ARGS}" \
43+
--kubernetes-version="https://dl.k8s.io/release/stable.txt" \
44+
--test=exec -- "${TEST_ROOT}/test.sh"
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2026 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
# Get the cluster name from the KUBECONFIG context
22+
CLUSTER_NAME=$(kubectl config view --minify -o jsonpath='{.clusters[0].name}')
23+
24+
# Get the zone from an instance group
25+
ZONE=$(kubectl get nodes -o jsonpath='{.items[0].metadata.labels.topology\.kubernetes\.io/zone}')
26+
27+
REPORT_DIR="${ARTIFACTS:-$(pwd)/_artifacts}/aws-ebs-csi-driver/"
28+
mkdir -p "${REPORT_DIR}"
29+
30+
# Clone the aws-ebs-csi-driver repo at the version deployed in the cluster
31+
CSI_VERSION=$(kubectl get deployment -n kube-system ebs-csi-controller -o jsonpath='{.spec.template.spec.containers[?(@.name=="ebs-plugin")].image}' | cut -d':' -f2-)
32+
TEMPDIR=$(mktemp -dt kops.XXXXXXXXX)
33+
cd "${TEMPDIR}"
34+
35+
go install github.com/onsi/ginkgo/v2/ginkgo@latest
36+
37+
CLONE_ARGS=
38+
if [ -n "$CSI_VERSION" ]; then
39+
CLONE_ARGS="-b ${CSI_VERSION}"
40+
fi
41+
# shellcheck disable=SC2086
42+
git clone ${CLONE_ARGS} https://github.com/kubernetes-sigs/aws-ebs-csi-driver.git .
43+
44+
cd tests/e2e-kubernetes/
45+
46+
ginkgo --nodes=25 ./... -- -cluster-tag="${CLUSTER_NAME}" -ginkgo.skip="\[Disruptive\]" -report-dir="${REPORT_DIR}" -gce-zone="${ZONE}"

‎tests/e2e/scenarios/cilium-connectivity-test/run-test.sh‎

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,36 @@
1515
# limitations under the License.
1616

1717
REPO_ROOT=$(git rev-parse --show-toplevel);
18-
source "${REPO_ROOT}"/tests/e2e/scenarios/lib/common.sh
18+
TEST_ROOT="${REPO_ROOT}/tests/e2e/scenarios/cilium-connectivity-test"
1919

20-
export KOPS_BASE_URL
21-
KOPS_BASE_URL="$(curl -s https://storage.googleapis.com/k8s-staging-kops/kops/releases/markers/master/latest-ci-updown-green.txt)"
22-
KOPS=$(kops-download-from-base)
20+
make test-e2e-install
2321

24-
ARGS="--set=cluster.spec.networking.cilium.hubble.enabled=true --set=cluster.spec.certManager.enabled=true"
22+
KUBETEST2_ARGS=()
23+
KUBETEST2_ARGS+=("-v=2")
2524

26-
if [[ $1 == "kube-proxy" ]]; then
27-
ARGS="${ARGS} --set=cluster.spec.networking.cilium.enableNodePort=false --set=cluster.spec.kubeProxy.enabled=true"
28-
# This test requires private topology, which kubetest2 does not support.
29-
#elif [[ $1 == "eni"]]
30-
# ARGS="${ARGS} --set=cluster.spec.cilium.ipam=eni --set=cluster.spec.cilium.disable-masquerade"
31-
# ARGS="${ARGS} --topology private"
32-
elif [[ $1 == "node-local-dns" ]]; then
33-
ARGS="${ARGS} --set=cluster.spec.kubeDNS.provider=CoreDNS --set=cluster.spec.kubeDNS.nodeLocalDNS.enabled=true"
25+
if [[ "${JOB_TYPE}" == "presubmit" && "${REPO_OWNER}/${REPO_NAME}" == "kubernetes/kops" ]]; then
26+
KUBETEST2_ARGS+=("--build")
27+
KUBETEST2_ARGS+=("--kops-binary-path=${GOPATH}/src/k8s.io/kops/.build/dist/linux/$(go env GOARCH)/kops")
28+
else
29+
KUBETEST2_ARGS+=("--kops-version-marker=${KOPS_VERSION_MARKER:-https://storage.googleapis.com/k8s-staging-kops/kops/releases/markers/master/latest-ci.txt}")
3430
fi
3531

36-
${KUBETEST2} \
37-
--up \
38-
--kubernetes-version="1.27.0" \
39-
--kops-binary-path="${KOPS}" \
40-
--create-args="--networking cilium $ARGS"
41-
42-
kubectl port-forward -n kube-system deployment/hubble-relay 4245:4245 &
32+
CREATE_ARGS="--networking cilium --set=cluster.spec.networking.cilium.hubble.enabled=true --set=cluster.spec.certManager.enabled=true"
4333

44-
wget -qO- https://github.com/cilium/cilium-cli/releases/download/v0.14.8/cilium-linux-amd64.tar.gz | tar xz -C "${WORKSPACE}"
34+
if [[ "${1:-}" == "kube-proxy" ]]; then
35+
CREATE_ARGS="${CREATE_ARGS} --set=cluster.spec.networking.cilium.enableNodePort=false --set=cluster.spec.kubeProxy.enabled=true"
36+
# This test requires private topology, which kubetest2 does not support.
37+
#elif [[ "${1:-}" == "eni"]]
38+
# CREATE_ARGS="${CREATE_ARGS} --set=cluster.spec.cilium.ipam=eni --set=cluster.spec.cilium.disable-masquerade"
39+
# CREATE_ARGS="${CREATE_ARGS} --topology private"
40+
elif [[ "${1:-}" == "node-local-dns" ]]; then
41+
CREATE_ARGS="${CREATE_ARGS} --set=cluster.spec.kubeDNS.provider=CoreDNS --set=cluster.spec.kubeDNS.nodeLocalDNS.enabled=true"
42+
fi
4543

46-
cilium connectivity test --all-flows
44+
kubetest2 kops \
45+
--up --down \
46+
"${KUBETEST2_ARGS[@]}" \
47+
--cloud-provider=aws \
48+
--create-args="${CREATE_ARGS}" \
49+
--kubernetes-version="https://dl.k8s.io/release/stable.txt" \
50+
--test=exec -- "${TEST_ROOT}/test.sh"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2026 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Start hubble-relay port-forward in background
18+
kubectl port-forward -n kube-system deployment/hubble-relay 4245:4245 &
19+
20+
# Download cilium-cli
21+
CILIUM_CLI_VERSION="v0.14.8"
22+
WORKSPACE="${WORKSPACE:-$(mktemp -d)}"
23+
wget -qO- "https://github.com/cilium/cilium-cli/releases/download/${CILIUM_CLI_VERSION}/cilium-linux-amd64.tar.gz" | tar xz -C "${WORKSPACE}"
24+
25+
# Run connectivity test
26+
"${WORKSPACE}/cilium" connectivity test --all-flows

0 commit comments

Comments
 (0)