Skip to content

Commit 1a71841

Browse files
authored
Merge pull request #7329 from oscr/remove-e2e-makefile
🌱 Remove test/e2e/Makefile and move targets to root Makefile
2 parents c261173 + c8230a7 commit 1a71841

File tree

4 files changed

+93
-143
lines changed

4 files changed

+93
-143
lines changed

Makefile

Lines changed: 91 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,25 @@ else
7272
export GOPATH := $(shell go env GOPATH)
7373
endif
7474

75+
#
76+
# Ginkgo configuration.
77+
#
78+
GINKGO_FOCUS ?=
79+
GINKGO_SKIP ?=
80+
GINKGO_NODES ?= 1
81+
GINKGO_TIMEOUT ?= 2h
82+
GINKGO_POLL_PROGRESS_AFTER ?= 10m
83+
GINKGO_POLL_PROGRESS_INTERVAL ?= 1m
84+
E2E_CONF_FILE ?= $(ROOT_DIR)/$(TEST_DIR)/e2e/config/docker.yaml
85+
SKIP_RESOURCE_CLEANUP ?= false
86+
USE_EXISTING_CLUSTER ?= false
87+
GINKGO_NOCOLOR ?= false
88+
89+
# to set multiple ginkgo skip flags, if any
90+
ifneq ($(strip $(GINKGO_SKIP)),)
91+
_SKIP_ARGS := $(foreach arg,$(strip $(GINKGO_SKIP)),-skip="$(arg)")
92+
endif
93+
7594
#
7695
# Binaries.
7796
#
@@ -126,6 +145,11 @@ YQ_BIN := yq
126145
YQ := $(abspath $(TOOLS_BIN_DIR)/$(YQ_BIN)-$(YQ_VER))
127146
YQ_PKG := github.com/mikefarah/yq/v4
128147

148+
GINGKO_VER := v2.2.0
149+
GINKGO_BIN := ginkgo
150+
GINKGO := $(abspath $(TOOLS_BIN_DIR)/$(GINKGO_BIN)-$(GINGKO_VER))
151+
GINKGO_PKG := github.com/onsi/ginkgo/v2/ginkgo
152+
129153
CONVERSION_VERIFIER_BIN := conversion-verifier
130154
CONVERSION_VERIFIER := $(abspath $(TOOLS_BIN_DIR)/$(CONVERSION_VERIFIER_BIN))
131155

@@ -666,10 +690,6 @@ test-cover: ## Run unit and integration tests and generate a coverage report
666690
go tool cover -func=out/coverage.out -o out/coverage.txt
667691
go tool cover -html=out/coverage.out -o out/coverage.html
668692

669-
.PHONY: test-e2e
670-
test-e2e: ## Run e2e tests
671-
$(MAKE) -C $(TEST_DIR)/e2e run
672-
673693
.PHONY: test-capd
674694
test-capd: $(SETUP_ENVTEST) ## Run unit and integration tests for capd
675695
cd $(CAPD_DIR); KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test ./... $(TEST_ARGS)
@@ -698,6 +718,17 @@ test-test-extension-junit: $(SETUP_ENVTEST) $(GOTESTSUM) ## Run unit and integra
698718
$(GOTESTSUM) --junitfile $(ARTIFACTS)/junit.test_extension.xml --raw-command cat $(ARTIFACTS)/junit.test_extension.stdout
699719
exit $$(cat $(ARTIFACTS)/junit.test_extension.exitcode)
700720

721+
.PHONY: test-e2e
722+
test-e2e: $(GINKGO) generate-e2e-templates generate-test-extension-deployment ## Run the end-to-end tests
723+
$(GINKGO) -v --trace -poll-progress-after=$(GINKGO_POLL_PROGRESS_AFTER) \
724+
-poll-progress-interval=$(GINKGO_POLL_PROGRESS_INTERVAL) --tags=e2e --focus="$(GINKGO_FOCUS)" \
725+
$(_SKIP_ARGS) --nodes=$(GINKGO_NODES) --timeout=$(GINKGO_TIMEOUT) --no-color=$(GINKGO_NOCOLOR) \
726+
--output-dir="$(ARTIFACTS)" --junit-report="junit.e2e_suite.1.xml" $(GINKGO_ARGS) $(ROOT_DIR)/$(TEST_DIR)/e2e -- \
727+
-e2e.artifacts-folder="$(ARTIFACTS)" \
728+
-e2e.config="$(E2E_CONF_FILE)" \
729+
-e2e.skip-resource-cleanup=$(SKIP_RESOURCE_CLEANUP) -e2e.use-existing-cluster=$(USE_EXISTING_CLUSTER)
730+
731+
701732
.PHONY: kind-cluster
702733
kind-cluster: ## Create a new kind cluster designed for development with Tilt
703734
hack/kind-install-for-capd.sh
@@ -1079,6 +1110,9 @@ $(TILT_PREPARE_BIN): $(TILT_PREPARE) ## Build a local copy of tilt-prepare.
10791110
.PHONY: $(GOLANGCI_LINT_BIN)
10801111
$(GOLANGCI_LINT_BIN): $(GOLANGCI_LINT) ## Build a local copy of golangci-lint
10811112

1113+
.PHONY: $(GINKGO_BIN)
1114+
$(GINKGO_BIN): $(GINKGO) ## Build a local copy of ginkgo
1115+
10821116
$(CONTROLLER_GEN): # Build controller-gen from tools folder.
10831117
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(CONTROLLER_GEN_PKG) $(CONTROLLER_GEN_BIN) $(CONTROLLER_GEN_VER)
10841118

@@ -1128,3 +1162,56 @@ $(GOLANGCI_LINT): .github/workflows/golangci-lint.yml # Download golangci-lint u
11281162
hack/ensure-golangci-lint.sh \
11291163
-b $(TOOLS_BIN_DIR) \
11301164
$(shell cat .github/workflows/golangci-lint.yml | grep [[:space:]]version | sed 's/.*version: //')
1165+
1166+
$(GINKGO): # Build ginkgo from tools folder.
1167+
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(GINKGO_PKG) $(GINKGO_BIN) $(GINGKO_VER)
1168+
1169+
1170+
## --------------------------------------
1171+
## Templates
1172+
## --------------------------------------
1173+
DOCKER_TEMPLATES := test/e2e/data/infrastructure-docker
1174+
1175+
.PHONY: generate-e2e-templates
1176+
generate-e2e-templates: $(KUSTOMIZE) generate-e2e-templates-v1alpha3 generate-e2e-templates-v1alpha4 generate-e2e-templates-v1.2 generate-e2e-templates-v1beta1 ## Generate cluster templates for all versions
1177+
1178+
generate-e2e-templates-v1alpha3: $(KUSTOMIZE)
1179+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1alpha3/cluster-template --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1alpha3/cluster-template.yaml
1180+
1181+
generate-e2e-templates-v1alpha4: $(KUSTOMIZE)
1182+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1alpha4/cluster-template --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1alpha4/cluster-template.yaml
1183+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-md-remediation --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-md-remediation.yaml
1184+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-kcp-remediation --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-kcp-remediation.yaml
1185+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-kcp-adoption/step1 --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-kcp-adoption.yaml
1186+
echo "---" >> $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-kcp-adoption.yaml
1187+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-kcp-adoption/step2 --load-restrictor LoadRestrictionsNone >> $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-kcp-adoption.yaml
1188+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-machine-pool --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-machine-pool.yaml
1189+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-node-drain --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-node-drain.yaml
1190+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-upgrades --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-upgrades.yaml
1191+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-kcp-scale-in --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-kcp-scale-in.yaml
1192+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-ipv6 --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1alpha4/cluster-template-ipv6.yaml
1193+
1194+
generate-e2e-templates-v1.2: $(KUSTOMIZE)
1195+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/v1.2/cluster-template --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/v1.2/cluster-template.yaml
1196+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/v1.2/cluster-template-topology --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/v1.2/cluster-template-topology.yaml
1197+
1198+
generate-e2e-templates-v1beta1: $(KUSTOMIZE)
1199+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template.yaml
1200+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-md-remediation --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-md-remediation.yaml
1201+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-kcp-remediation --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-kcp-remediation.yaml
1202+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-kcp-adoption/step1 --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-kcp-adoption.yaml
1203+
echo "---" >> $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-kcp-adoption.yaml
1204+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-kcp-adoption/step2 --load-restrictor LoadRestrictionsNone >> $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-kcp-adoption.yaml
1205+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-machine-pool --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-machine-pool.yaml
1206+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-node-drain --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-node-drain.yaml
1207+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-upgrades --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-upgrades.yaml
1208+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-upgrades-cgroupfs --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-upgrades-cgroupfs.yaml
1209+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-upgrades-runtimesdk --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-upgrades-runtimesdk.yaml
1210+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-kcp-scale-in --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-kcp-scale-in.yaml
1211+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-ipv6 --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-ipv6.yaml
1212+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-topology --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-topology.yaml
1213+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-ignition --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/main/cluster-template-ignition.yaml
1214+
1215+
generate-test-extension-deployment: $(KUSTOMIZE)
1216+
mkdir -p test/e2e/data/test-extension
1217+
$(KUSTOMIZE) build test/extension/config/default > test/e2e/data/test-extension/deployment.yaml

docs/book/src/developer/testing.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,9 @@ kind images). This can be done by executing the `./scripts/ci-e2e.sh` script.
158158

159159
```bash
160160
# Notes:
161-
# * You can cancel the script as soon as it starts the actual test execution via `make -C test/e2e/ run`.
161+
# * You can cancel the script as soon as it starts the actual test execution via `make test-e2e`.
162162
# * If you want to run other tests (e.g. upgrade tests), make sure all required env variables are set (see the Prow Job config).
163163
GINKGO_FOCUS="\[PR-Blocking\]" ./scripts/ci-e2e.sh
164-
165-
# Make sure the cluster-templates have been generated.
166-
make -C test/e2e cluster-templates
167164
```
168165

169166
Now, the tests can be run in an IDE. The following describes how this can be done in Intellij IDEA and VS Code. It should work

scripts/ci-e2e.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,4 @@ ctr -n moby events > "${ARTIFACTS_LOCAL}/containerd-events.txt" 2>&1 &
9595
# Run e2e tests
9696
mkdir -p "$ARTIFACTS"
9797
echo "+ run tests!"
98-
make -C test/e2e/ run
98+
make test-e2e

test/e2e/Makefile

Lines changed: 0 additions & 134 deletions
This file was deleted.

0 commit comments

Comments
 (0)