Skip to content

Commit

Permalink
Merge pull request #10467 from cahillsf/improve-tilt-doc
Browse files Browse the repository at this point in the history
🌱 improve tilt setup for local e2e
  • Loading branch information
k8s-ci-robot authored May 2, 2024
2 parents 2fbed5b + 6658b9d commit 8e8cf93
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 7 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -642,11 +642,11 @@ lint: $(GOLANGCI_LINT) ## Lint the codebase
$(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS)
cd $(TEST_DIR); $(GOLANGCI_LINT) run --path-prefix $(TEST_DIR) --config $(ROOT_DIR)/.golangci.yml -v $(GOLANGCI_LINT_EXTRA_ARGS)
cd $(TOOLS_DIR); $(GOLANGCI_LINT) run --path-prefix $(TOOLS_DIR) --config $(ROOT_DIR)/.golangci.yml -v $(GOLANGCI_LINT_EXTRA_ARGS)
./scripts/ci-lint-dockerfiles.sh $(HADOLINT_VER) $(HADOLINT_FAILURE_THRESHOLD)
./scripts/lint-dockerfiles.sh $(HADOLINT_VER) $(HADOLINT_FAILURE_THRESHOLD)

.PHONY: lint-dockerfiles
lint-dockerfiles:
./scripts/ci-lint-dockerfiles.sh $(HADOLINT_VER) $(HADOLINT_FAILURE_THRESHOLD)
./scripts/lint-dockerfiles.sh $(HADOLINT_VER) $(HADOLINT_FAILURE_THRESHOLD)

.PHONY: lint-fix
lint-fix: $(GOLANGCI_LINT) ## Lint the codebase and run auto-fixers if supported by the linter
Expand Down Expand Up @@ -961,6 +961,11 @@ test-e2e: $(GINKGO) generate-e2e-templates ## Run the end-to-end tests
kind-cluster: ## Create a new kind cluster designed for development with Tilt
hack/kind-install-for-capd.sh

.PHONY: tilt-e2e-prerequisites
tilt-e2e-prerequisites: ## Build the corresponding kindest/node images required for e2e testing and generate the e2e templates
scripts/build-kind.sh
$(MAKE) generate-e2e-templates

.PHONY: tilt-up
tilt-up: kind-cluster ## Start tilt and build kind cluster if needed.
tilt up
Expand Down
2 changes: 1 addition & 1 deletion docs/book/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
TOOLS_DIR := $(realpath ../../hack/tools)
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
BIN_DIR := bin
MDBOOK_INSTALL := $(realpath ../../scripts/ci-install-mdbook.sh)
MDBOOK_INSTALL := $(realpath ../../scripts/install-mdbook.sh)

export PATH := $(TOOLS_BIN_DIR):$(PATH)

Expand Down
9 changes: 5 additions & 4 deletions docs/book/src/developer/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,12 @@ Execute the run configuration with `Debug`.
The e2e tests create a new management cluster with kind on each run. To avoid this and speed up the test execution the tests can
also be run against a management cluster created by [tilt](./tilt.md):
```bash
# Create a kind cluster
./hack/kind-install-for-capd.sh
# Set up the management cluster via tilt
tilt up
# Prereqs for e2e testing with tilt
make tilt-e2e-prerequisites
# Create a kind cluster and start tilt
make tilt-up
```

Now you can start the e2e test via IDE as described above but with the additional `-e2e.use-existing-cluster=true` flag.

**Note**: This can also be used to debug controllers during e2e tests as described in [Developing Cluster API with Tilt](./tilt.md#wiring-up-debuggers).
Expand Down
45 changes: 45 additions & 0 deletions scripts/build-kind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

# Copyright 2018 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 pipefail

REPO_ROOT=$(git rev-parse --show-toplevel)
cd "${REPO_ROOT}" || exit 1

# shellcheck source=./scripts/ci-e2e-lib.sh
source "${REPO_ROOT}/scripts/ci-e2e-lib.sh"

# Conf file is parsed to populate variables
export E2E_CONF_FILE="${REPO_ROOT}/test/e2e/config/docker.yaml"

# Prepare kindest/node images for all the required Kubernetes version; this implies
# 1. Kubernetes version labels (e.g. latest) to the corresponding version numbers.
# 2. Pre-pulling the corresponding kindest/node image if available; if not, building the image locally.
# Following variables are currently checked (if defined):
# - KUBERNETES_VERSION
# - KUBERNETES_VERSION_UPGRADE_TO
# - KUBERNETES_VERSION_UPGRADE_FROM
# - KUBERNETES_VERSION_LATEST_CI
# - KUBERNETES_VERSION_MANAGEMENT

k8s::prepareKindestImagesVariables
k8s::prepareKindestImages

# pre-pull all the images that will be used in the e2e, thus making the actual test run
# less sensible to the network speed. This includes:
# - cert-manager images
kind:prepullAdditionalImages
1 change: 1 addition & 0 deletions scripts/ci-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export USE_EXISTING_CLUSTER=false
# - KUBERNETES_VERSION_UPGRADE_TO
# - KUBERNETES_VERSION_UPGRADE_FROM
# - KUBERNETES_VERSION_LATEST_CI
# - KUBERNETES_VERSION_MANAGEMENT
k8s::prepareKindestImagesVariables
k8s::prepareKindestImages

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 8e8cf93

Please sign in to comment.