diff --git a/slice/Makefile b/slice/Makefile index 3f0ce48da..35aff8e61 100644 --- a/slice/Makefile +++ b/slice/Makefile @@ -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 @@ -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: cleanup-test-e2e diff --git a/slice/hack/e2e-common.sh b/slice/hack/e2e-common.sh index aaa00cf92..3c64ad839 100644 --- a/slice/hack/e2e-common.sh +++ b/slice/hack/e2e-common.sh @@ -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") diff --git a/slice/hack/e2e-test.sh b/slice/hack/e2e-test.sh index c360acac1..48f0ca48f 100755 --- a/slice/hack/e2e-test.sh +++ b/slice/hack/e2e-test.sh @@ -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/...