Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion slice/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ E2E_K8S_FULL_VERSION ?= $(filter $(E2E_K8S_VERSION).%,$(E2E_K8S_VERSIONS))
E2E_K8S_FULL_VERSION := $(or $(E2E_K8S_FULL_VERSION),$(E2E_K8S_VERSION).0)
E2E_KIND_VERSION ?= kindest/node:v$(E2E_K8S_FULL_VERSION)
E2E_RUN_ONLY_ENV ?= false
E2E_RUN_ONLY_SLICE ?= false

.PHONY: all
all: build
Expand Down Expand Up @@ -122,7 +123,7 @@ run-test-e2e-%:
E2E_KIND_VERSION="kindest/node:v$(K8S_VERSION)" KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) CREATE_KIND_CLUSTER=$(CREATE_KIND_CLUSTER) \
EXTERNAL_CRDS_DIR=$(EXTERNAL_CRDS_DIR) ARTIFACTS="$(ARTIFACTS)/$@" IMAGE_TAG=$(IMAGE_TAG) GINKGO_ARGS="$(GINKGO_ARGS)" \
KUEUE_IMAGE=$(KUEUE_IMAGE) JOBSET_IMAGE=$(JOBSET_IMAGE) \
TEST_LOG_LEVEL=$(TEST_LOG_LEVEL) E2E_RUN_ONLY_ENV=$(E2E_RUN_ONLY_ENV) \
TEST_LOG_LEVEL=$(TEST_LOG_LEVEL) E2E_RUN_ONLY_ENV=$(E2E_RUN_ONLY_ENV) E2E_RUN_ONLY_SLICE=$(E2E_RUN_ONLY_SLICE) \
./hack/e2e-test.sh

.PHONY: lint
Expand Down
23 changes: 23 additions & 0 deletions slice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,29 @@ is manually re-applied afterwards.

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

## Running e2e tests using custom build
```shell
make kind-image-build test-e2e
```

## Attaching e2e tests to an existing kind cluster
You can use the following approach to start up a kind cluster and then run e2e tests from commandline or VSCode,
attaching them to the existing cluster. For example, suppose you want to test some of the multikueue-e2e tests.

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.

The cluster is ready, and now you can run tests from another terminal:
```shell
./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/...
```
or from VSCode.

## Quick rebuild Kueue in e2e tests
If the `E2E_RUN_ONLY_ENV` variable is set, you can rebuild **only the Kueue image** without needing to rebuild the entire cluster.
```shell
make kind-image-build test-e2e E2E_RUN_ONLY_ENV=true E2E_RUN_ONLY_SLICE=true
```

## License

Copyright The Kubernetes Authors.
Expand Down
4 changes: 4 additions & 0 deletions slice/hack/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ function cluster_slice_deploy {
local build_output
build_output=$($KUSTOMIZE build "${ROOT_DIR}/config/dev")
build_output="${build_output//$DEFAULT_SLICE_NAMESPACE/$SLICE_NAMESPACE}"
# Add rollout-timestamp annotation to the Deployment's pod template
local timestamp
timestamp=$(date +%s) # Unix timestamp for uniqueness
build_output=$(yq eval "select(.kind == \"Deployment\").spec.template.metadata.annotations += {\"kubectl.kubernetes.io/timestamp\": \"$timestamp\"}" - <<< "$build_output")
echo "$build_output" | kubectl apply --kubeconfig="$1" --server-side -f -

(cd "${ROOT_DIR}/config/manager" && $KUSTOMIZE edit set image controller="$initial_image")
Expand Down
37 changes: 25 additions & 12 deletions slice/hack/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,34 @@ function startup {
fi
}

trap cleanup EXIT
startup
prepare_docker_images
if [[ "${E2E_RUN_ONLY_SLICE}" != 'true' ]]; then
trap cleanup EXIT
startup
prepare_docker_images
fi

kind_load "$KIND_CLUSTER_NAME" ""

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

cluster_slice_deploy ""

if [ "$E2E_RUN_ONLY_ENV" == 'true' ]; then
read -rp "Press Enter to cleanup."
else
# shellcheck disable=SC2086
$GINKGO $GINKGO_ARGS --junit-report=junit.xml --json-report=e2e.json --output-dir="$ARTIFACTS" -v ./test/e2e/...
if [ "$E2E_RUN_ONLY_ENV" = "true" ]; then
if [[ "${E2E_RUN_ONLY_SLICE}" != 'true' ]]; then
read -rp "Do you want to cleanup? [Y/n] " reply
if [[ "$reply" =~ ^[nN]$ ]]; then
trap - EXIT
echo "Skipping cleanup for kind cluster."
echo -e "\nKind cluster cleanup:\n kind delete cluster --name $KIND_CLUSTER_NAME"
fi
fi
exit 0
fi

# shellcheck disable=SC2086
$GINKGO $GINKGO_ARGS --junit-report=junit.xml --json-report=e2e.json --output-dir="$ARTIFACTS" -v ./test/e2e/...
Loading