-
Notifications
You must be signed in to change notification settings - Fork 55
Add test-e2e-kind target with hack script and artifact collection #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
k8s-ci-robot
merged 1 commit into
kubernetes-sigs:main
from
Priyankasaggu11929:setup-kind-e2e-tests
Jun 11, 2026
+105
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Copyright 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 | ||
|
|
||
| export KIND=${KIND:-kind} | ||
| export KUBECTL=${KUBECTL:-kubectl} | ||
|
|
||
| KIND_CLUSTER="${KIND_CLUSTER:-nrr-test}" | ||
| USE_EXISTING_CLUSTER="${USE_EXISTING_CLUSTER:-false}" | ||
| ARTIFACTS="${ARTIFACTS:-.}" | ||
| E2E_KIND_VERSION="${E2E_KIND_VERSION:-v1.36}" | ||
|
|
||
| if [[ "$E2E_KIND_VERSION" =~ ^v[0-9]+\.[0-9]+$ ]]; then | ||
| K8S_VERSION=$(curl -sf --retry 3 --retry-delay 5 --max-time 30 \ | ||
| "https://api.github.com/repos/kubernetes/kubernetes/git/matching-refs/tags/${E2E_KIND_VERSION}." \ | ||
| | grep -oP 'v[0-9]+\.[0-9]+\.[0-9]+(?=")' \ | ||
| | sort -V | tail -1) | ||
| if [ -z "$K8S_VERSION" ]; then | ||
| echo "ERROR: could not resolve latest patch for ${E2E_KIND_VERSION}" >&2 | ||
| exit 1 | ||
| fi | ||
| else | ||
| K8S_VERSION="$E2E_KIND_VERSION" | ||
| fi | ||
|
|
||
| # Use a temporary KUBECONFIG so that the script does not mess up the current user's kubeconfig. | ||
| KUBECONFIG="" | ||
|
|
||
| function cleanup { | ||
| if [ "$USE_EXISTING_CLUSTER" != 'true' ]; then | ||
| mkdir -p "$ARTIFACTS" | ||
| $KIND export logs "$ARTIFACTS" --name "$KIND_CLUSTER" || true | ||
| $KIND delete cluster --name "$KIND_CLUSTER" || true | ||
| [ -n "$KUBECONFIG" ] && rm -f "$KUBECONFIG" | ||
| fi | ||
| } | ||
|
|
||
| function build_node_image { | ||
| if [ "$USE_EXISTING_CLUSTER" != 'true' ]; then | ||
| $KIND build node-image "$K8S_VERSION" --image nrr/kind-node:"${K8S_VERSION}" | ||
| fi | ||
| } | ||
|
|
||
| function startup { | ||
| if [ "$USE_EXISTING_CLUSTER" != 'true' ]; then | ||
| KUBECONFIG="$(mktemp)" | ||
| if [ -z "$KUBECONFIG" ]; then | ||
| echo "Failed to generate temporary KUBECONFIG" 1>&2 | ||
| exit 1 | ||
| fi | ||
| export KUBECONFIG | ||
| $KIND create cluster --name "$KIND_CLUSTER" --image nrr/kind-node:"${K8S_VERSION}" --wait 1m | ||
| $KUBECTL get nodes > "$ARTIFACTS/kind-nodes.log" 2>/dev/null || true | ||
| $KUBECTL describe pods -n kube-system > "$ARTIFACTS/kube-system-pods.log" 2>/dev/null || true | ||
| fi | ||
| } | ||
|
|
||
| mkdir -p "$ARTIFACTS" | ||
| trap cleanup EXIT | ||
| build_node_image | ||
| startup | ||
|
|
||
| go test -tags=e2e ./test/e2e/ -v -ginkgo.v \ | ||
| --ginkgo.junit-report="$ARTIFACTS/junit.xml" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if there could be a way to not have v1.36 hardcoded here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a fall back value (to latest k8s version)
i think we can keep it as it is (unless you mean something else?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, the latest version is always a moving target and having any value hardcoded in here is something more we need to remember to update when we change to the next version.
But since it's a fallback value, that's fine. We can try to automate the version bump later with the release automation, check every places where k8s version is hardcoded and update.