Skip to content

Commit 303a896

Browse files
authored
WIP: [Slice] Test E2E quick rebuild. (#593)
[Slice] Test E2E quick rebuild.
1 parent 89974a1 commit 303a896

File tree

4 files changed

+54
-13
lines changed

4 files changed

+54
-13
lines changed

slice/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ E2E_K8S_FULL_VERSION ?= $(filter $(E2E_K8S_VERSION).%,$(E2E_K8S_VERSIONS))
6464
E2E_K8S_FULL_VERSION := $(or $(E2E_K8S_FULL_VERSION),$(E2E_K8S_VERSION).0)
6565
E2E_KIND_VERSION ?= kindest/node:v$(E2E_K8S_FULL_VERSION)
6666
E2E_RUN_ONLY_ENV ?= false
67+
E2E_RUN_ONLY_SLICE ?= false
6768

6869
.PHONY: all
6970
all: build
@@ -122,7 +123,7 @@ run-test-e2e-%:
122123
E2E_KIND_VERSION="kindest/node:v$(K8S_VERSION)" KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) CREATE_KIND_CLUSTER=$(CREATE_KIND_CLUSTER) \
123124
EXTERNAL_CRDS_DIR=$(EXTERNAL_CRDS_DIR) ARTIFACTS="$(ARTIFACTS)/$@" IMAGE_TAG=$(IMAGE_TAG) GINKGO_ARGS="$(GINKGO_ARGS)" \
124125
KUEUE_IMAGE=$(KUEUE_IMAGE) JOBSET_IMAGE=$(JOBSET_IMAGE) \
125-
TEST_LOG_LEVEL=$(TEST_LOG_LEVEL) E2E_RUN_ONLY_ENV=$(E2E_RUN_ONLY_ENV) \
126+
TEST_LOG_LEVEL=$(TEST_LOG_LEVEL) E2E_RUN_ONLY_ENV=$(E2E_RUN_ONLY_ENV) E2E_RUN_ONLY_SLICE=$(E2E_RUN_ONLY_SLICE) \
126127
./hack/e2e-test.sh
127128

128129
.PHONY: lint

slice/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,29 @@ is manually re-applied afterwards.
117117

118118
More information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html)
119119

120+
## Running e2e tests using custom build
121+
```shell
122+
make kind-image-build test-e2e
123+
```
124+
125+
## Attaching e2e tests to an existing kind cluster
126+
You can use the following approach to start up a kind cluster and then run e2e tests from commandline or VSCode,
127+
attaching them to the existing cluster. For example, suppose you want to test some of the multikueue-e2e tests.
128+
129+
Run `make kind-image-build test-e2e E2E_RUN_ONLY_ENV=true` and wait for the `Do you want to cleanup? [Y/n] ` to appear.
130+
131+
The cluster is ready, and now you can run tests from another terminal:
132+
```shell
133+
./bin/ginkgo -focus "JobSet (when )?Creating a JobSet it should create Slice based on created Workload with TPU topology 4x4x4, TPU topology 4 and parallelism 16" -v ./test/e2e/...
134+
```
135+
or from VSCode.
136+
137+
## Quick rebuild Kueue in e2e tests
138+
If the `E2E_RUN_ONLY_ENV` variable is set, you can rebuild **only the Kueue image** without needing to rebuild the entire cluster.
139+
```shell
140+
make kind-image-build test-e2e E2E_RUN_ONLY_ENV=true E2E_RUN_ONLY_SLICE=true
141+
```
142+
120143
## License
121144

122145
Copyright The Kubernetes Authors.

slice/hack/e2e-common.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ function cluster_slice_deploy {
111111
local build_output
112112
build_output=$($KUSTOMIZE build "${ROOT_DIR}/config/dev")
113113
build_output="${build_output//$DEFAULT_SLICE_NAMESPACE/$SLICE_NAMESPACE}"
114+
# Add rollout-timestamp annotation to the Deployment's pod template
115+
local timestamp
116+
timestamp=$(date +%s) # Unix timestamp for uniqueness
117+
build_output=$(yq eval "select(.kind == \"Deployment\").spec.template.metadata.annotations += {\"kubectl.kubernetes.io/timestamp\": \"$timestamp\"}" - <<< "$build_output")
114118
echo "$build_output" | kubectl apply --kubeconfig="$1" --server-side -f -
115119

116120
(cd "${ROOT_DIR}/config/manager" && $KUSTOMIZE edit set image controller="$initial_image")

slice/hack/e2e-test.sh

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,34 @@ function startup {
4444
fi
4545
}
4646

47-
trap cleanup EXIT
48-
startup
49-
prepare_docker_images
47+
if [[ "${E2E_RUN_ONLY_SLICE}" != 'true' ]]; then
48+
trap cleanup EXIT
49+
startup
50+
prepare_docker_images
51+
fi
52+
5053
kind_load "$KIND_CLUSTER_NAME" ""
5154

52-
# We need to wait for Kueue to become available;
53-
# otherwise, we encounter the error: "no endpoints available for service 'kueue-webhook-service'"
54-
echo "Waiting for Kueue to become available..."
55-
kubectl wait deploy/kueue-controller-manager -nkueue-system --for=condition=available --timeout=5m
55+
if [[ "${E2E_RUN_ONLY_SLICE}" != 'true' ]]; then
56+
# We need to wait for Kueue to become available;
57+
# otherwise, we encounter the error: "no endpoints available for service 'kueue-webhook-service'"
58+
echo "Waiting for Kueue to become available..."
59+
kubectl wait deploy/kueue-controller-manager -nkueue-system --for=condition=available --timeout=5m
60+
fi
5661

5762
cluster_slice_deploy ""
5863

59-
if [ "$E2E_RUN_ONLY_ENV" == 'true' ]; then
60-
read -rp "Press Enter to cleanup."
61-
else
62-
# shellcheck disable=SC2086
63-
$GINKGO $GINKGO_ARGS --junit-report=junit.xml --json-report=e2e.json --output-dir="$ARTIFACTS" -v ./test/e2e/...
64+
if [ "$E2E_RUN_ONLY_ENV" = "true" ]; then
65+
if [[ "${E2E_RUN_ONLY_SLICE}" != 'true' ]]; then
66+
read -rp "Do you want to cleanup? [Y/n] " reply
67+
if [[ "$reply" =~ ^[nN]$ ]]; then
68+
trap - EXIT
69+
echo "Skipping cleanup for kind cluster."
70+
echo -e "\nKind cluster cleanup:\n kind delete cluster --name $KIND_CLUSTER_NAME"
71+
fi
72+
fi
73+
exit 0
6474
fi
75+
76+
# shellcheck disable=SC2086
77+
$GINKGO $GINKGO_ARGS --junit-report=junit.xml --json-report=e2e.json --output-dir="$ARTIFACTS" -v ./test/e2e/...

0 commit comments

Comments
 (0)