Skip to content

Commit efd67e7

Browse files
committed
refactor(e2e-setup): update Kind cluster naming for e2e tests
change default Kind cluster names to be project-specific for e2e tests Previously, the default Kind cluster name was "kind", which could lead to conflicts when running multiple e2e tests concurrently across different projects. This change updates the Kind cluster name to be project-specific, reducing potential conflicts and improving the isolation of e2e test environments.
1 parent d177b65 commit efd67e7

File tree

21 files changed

+86
-70
lines changed

21 files changed

+86
-70
lines changed

Diff for: docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/test-e2e.yml

-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ jobs:
2626
- name: Verify kind installation
2727
run: kind version
2828

29-
- name: Create kind cluster
30-
run: kind create cluster
31-
3229
- name: Running Test e2e
3330
run: |
3431
go mod tidy

Diff for: docs/book/src/cronjob-tutorial/testdata/project/Makefile

+11-6
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,22 @@ test: manifests generate fmt vet setup-envtest ## Run tests.
6969
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
7070
# CertManager is installed by default; skip with:
7171
# - CERT_MANAGER_INSTALL_SKIP=true
72-
.PHONY: test-e2e
73-
test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
72+
.PHONY: setup-test-e2e
73+
setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist
7474
@command -v $(KIND) >/dev/null 2>&1 || { \
7575
echo "Kind is not installed. Please install Kind manually."; \
7676
exit 1; \
7777
}
78-
@$(KIND) get clusters | grep -q 'kind' || { \
79-
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
80-
exit 1; \
81-
}
78+
$(KIND) create cluster --name project-test-e2e --wait 5m
79+
80+
.PHONY: test-e2e
81+
test-e2e: setup-test-e2e manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
8282
go test ./test/e2e/ -v -ginkgo.v
83+
$(MAKE) teardown-test-e2e
84+
85+
.PHONY: teardown-test-e2e
86+
teardown-test-e2e: ## Tear down the Kind cluster used for e2e tests
87+
@$(KIND) delete cluster --name project-test-e2e
8388

8489
.PHONY: lint
8590
lint: golangci-lint ## Run golangci-lint linter

Diff for: docs/book/src/cronjob-tutorial/testdata/project/test/utils/utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func IsCertManagerCRDsInstalled() bool {
167167

168168
// LoadImageToKindClusterWithName loads a local docker image to the kind cluster
169169
func LoadImageToKindClusterWithName(name string) error {
170-
cluster := "kind"
170+
cluster := "project-test-e2e"
171171
if v, ok := os.LookupEnv("KIND_CLUSTER"); ok {
172172
cluster = v
173173
}

Diff for: docs/book/src/getting-started/testdata/project/.github/workflows/test-e2e.yml

-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ jobs:
2626
- name: Verify kind installation
2727
run: kind version
2828

29-
- name: Create kind cluster
30-
run: kind create cluster
31-
3229
- name: Running Test e2e
3330
run: |
3431
go mod tidy

Diff for: docs/book/src/getting-started/testdata/project/Makefile

+11-6
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,22 @@ test: manifests generate fmt vet setup-envtest ## Run tests.
6565
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
6666
# CertManager is installed by default; skip with:
6767
# - CERT_MANAGER_INSTALL_SKIP=true
68-
.PHONY: test-e2e
69-
test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
68+
.PHONY: setup-test-e2e
69+
setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist
7070
@command -v $(KIND) >/dev/null 2>&1 || { \
7171
echo "Kind is not installed. Please install Kind manually."; \
7272
exit 1; \
7373
}
74-
@$(KIND) get clusters | grep -q 'kind' || { \
75-
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
76-
exit 1; \
77-
}
74+
$(KIND) create cluster --name project-test-e2e --wait 5m
75+
76+
.PHONY: test-e2e
77+
test-e2e: setup-test-e2e manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
7878
go test ./test/e2e/ -v -ginkgo.v
79+
$(MAKE) teardown-test-e2e
80+
81+
.PHONY: teardown-test-e2e
82+
teardown-test-e2e: ## Tear down the Kind cluster used for e2e tests
83+
@$(KIND) delete cluster --name project-test-e2e
7984

8085
.PHONY: lint
8186
lint: golangci-lint ## Run golangci-lint linter

Diff for: docs/book/src/getting-started/testdata/project/test/utils/utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func IsCertManagerCRDsInstalled() bool {
167167

168168
// LoadImageToKindClusterWithName loads a local docker image to the kind cluster
169169
func LoadImageToKindClusterWithName(name string) error {
170-
cluster := "kind"
170+
cluster := "project-test-e2e"
171171
if v, ok := os.LookupEnv("KIND_CLUSTER"); ok {
172172
cluster = v
173173
}

Diff for: docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/test-e2e.yml

-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ jobs:
2626
- name: Verify kind installation
2727
run: kind version
2828

29-
- name: Create kind cluster
30-
run: kind create cluster
31-
3229
- name: Running Test e2e
3330
run: |
3431
go mod tidy

Diff for: docs/book/src/multiversion-tutorial/testdata/project/Makefile

+11-6
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,22 @@ test: manifests generate fmt vet setup-envtest ## Run tests.
6969
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
7070
# CertManager is installed by default; skip with:
7171
# - CERT_MANAGER_INSTALL_SKIP=true
72-
.PHONY: test-e2e
73-
test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
72+
.PHONY: setup-test-e2e
73+
setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist
7474
@command -v $(KIND) >/dev/null 2>&1 || { \
7575
echo "Kind is not installed. Please install Kind manually."; \
7676
exit 1; \
7777
}
78-
@$(KIND) get clusters | grep -q 'kind' || { \
79-
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
80-
exit 1; \
81-
}
78+
$(KIND) create cluster --name project-test-e2e --wait 5m
79+
80+
.PHONY: test-e2e
81+
test-e2e: setup-test-e2e manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
8282
go test ./test/e2e/ -v -ginkgo.v
83+
$(MAKE) teardown-test-e2e
84+
85+
.PHONY: teardown-test-e2e
86+
teardown-test-e2e: ## Tear down the Kind cluster used for e2e tests
87+
@$(KIND) delete cluster --name project-test-e2e
8388

8489
.PHONY: lint
8590
lint: golangci-lint ## Run golangci-lint linter

Diff for: docs/book/src/multiversion-tutorial/testdata/project/test/utils/utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func IsCertManagerCRDsInstalled() bool {
167167

168168
// LoadImageToKindClusterWithName loads a local docker image to the kind cluster
169169
func LoadImageToKindClusterWithName(name string) error {
170-
cluster := "kind"
170+
cluster := "project-test-e2e"
171171
if v, ok := os.LookupEnv("KIND_CLUSTER"); ok {
172172
cluster = v
173173
}

Diff for: pkg/plugins/golang/v4/scaffolds/internal/templates/github/test-e2e.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var _ machinery.Template = &E2eTestCi{}
2828
type E2eTestCi struct {
2929
machinery.TemplateMixin
3030
machinery.BoilerplateMixin
31+
machinery.ProjectNameMixin
3132
}
3233

3334
// SetTemplateDefaults implements machinery.Template
@@ -71,9 +72,6 @@ jobs:
7172
- name: Verify kind installation
7273
run: kind version
7374
74-
- name: Create kind cluster
75-
run: kind create cluster
76-
7775
- name: Running Test e2e
7876
run: |
7977
go mod tidy

Diff for: pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,22 @@ test: manifests generate fmt vet setup-envtest ## Run tests.
144144
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
145145
# CertManager is installed by default; skip with:
146146
# - CERT_MANAGER_INSTALL_SKIP=true
147-
.PHONY: test-e2e
148-
test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
147+
.PHONY: setup-test-e2e
148+
setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist
149149
@command -v $(KIND) >/dev/null 2>&1 || { \
150150
echo "Kind is not installed. Please install Kind manually."; \
151151
exit 1; \
152152
}
153-
@$(KIND) get clusters | grep -q 'kind' || { \
154-
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
155-
exit 1; \
156-
}
153+
$(KIND) create cluster --name {{ .ProjectName }}-test-e2e --wait 5m
154+
155+
.PHONY: test-e2e
156+
test-e2e: setup-test-e2e manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
157157
go test ./test/e2e/ -v -ginkgo.v
158+
$(MAKE) teardown-test-e2e
159+
160+
.PHONY: teardown-test-e2e
161+
teardown-test-e2e: ## Tear down the Kind cluster used for e2e tests
162+
@$(KIND) delete cluster --name {{ .ProjectName }}-test-e2e
158163
159164
.PHONY: lint
160165
lint: golangci-lint ## Run golangci-lint linter

Diff for: pkg/plugins/golang/v4/scaffolds/internal/templates/test/utils/utils.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var _ machinery.Template = &Utils{}
2626
type Utils struct {
2727
machinery.TemplateMixin
2828
machinery.BoilerplateMixin
29+
machinery.ProjectNameMixin
2930
}
3031

3132
// SetTemplateDefaults set the defaults for its template
@@ -194,7 +195,7 @@ func IsCertManagerCRDsInstalled() bool {
194195
195196
// LoadImageToKindClusterWithName loads a local docker image to the kind cluster
196197
func LoadImageToKindClusterWithName(name string) error {
197-
cluster := "kind"
198+
cluster := "{{ .ProjectName }}-test-e2e"
198199
if v, ok := os.LookupEnv("KIND_CLUSTER"); ok {
199200
cluster = v
200201
}

Diff for: testdata/project-v4-multigroup/.github/workflows/test-e2e.yml

-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ jobs:
2626
- name: Verify kind installation
2727
run: kind version
2828

29-
- name: Create kind cluster
30-
run: kind create cluster
31-
3229
- name: Running Test e2e
3330
run: |
3431
go mod tidy

Diff for: testdata/project-v4-multigroup/Makefile

+11-6
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,22 @@ test: manifests generate fmt vet setup-envtest ## Run tests.
6565
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
6666
# CertManager is installed by default; skip with:
6767
# - CERT_MANAGER_INSTALL_SKIP=true
68-
.PHONY: test-e2e
69-
test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
68+
.PHONY: setup-test-e2e
69+
setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist
7070
@command -v $(KIND) >/dev/null 2>&1 || { \
7171
echo "Kind is not installed. Please install Kind manually."; \
7272
exit 1; \
7373
}
74-
@$(KIND) get clusters | grep -q 'kind' || { \
75-
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
76-
exit 1; \
77-
}
74+
$(KIND) create cluster --name project-v4-multigroup-test-e2e --wait 5m
75+
76+
.PHONY: test-e2e
77+
test-e2e: setup-test-e2e manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
7878
go test ./test/e2e/ -v -ginkgo.v
79+
$(MAKE) teardown-test-e2e
80+
81+
.PHONY: teardown-test-e2e
82+
teardown-test-e2e: ## Tear down the Kind cluster used for e2e tests
83+
@$(KIND) delete cluster --name project-v4-multigroup-test-e2e
7984

8085
.PHONY: lint
8186
lint: golangci-lint ## Run golangci-lint linter

Diff for: testdata/project-v4-multigroup/test/utils/utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func IsCertManagerCRDsInstalled() bool {
167167

168168
// LoadImageToKindClusterWithName loads a local docker image to the kind cluster
169169
func LoadImageToKindClusterWithName(name string) error {
170-
cluster := "kind"
170+
cluster := "project-v4-multigroup-test-e2e"
171171
if v, ok := os.LookupEnv("KIND_CLUSTER"); ok {
172172
cluster = v
173173
}

Diff for: testdata/project-v4-with-plugins/.github/workflows/test-e2e.yml

-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ jobs:
2626
- name: Verify kind installation
2727
run: kind version
2828

29-
- name: Create kind cluster
30-
run: kind create cluster
31-
3229
- name: Running Test e2e
3330
run: |
3431
go mod tidy

Diff for: testdata/project-v4-with-plugins/Makefile

+11-6
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,22 @@ test: manifests generate fmt vet setup-envtest ## Run tests.
6565
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
6666
# CertManager is installed by default; skip with:
6767
# - CERT_MANAGER_INSTALL_SKIP=true
68-
.PHONY: test-e2e
69-
test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
68+
.PHONY: setup-test-e2e
69+
setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist
7070
@command -v $(KIND) >/dev/null 2>&1 || { \
7171
echo "Kind is not installed. Please install Kind manually."; \
7272
exit 1; \
7373
}
74-
@$(KIND) get clusters | grep -q 'kind' || { \
75-
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
76-
exit 1; \
77-
}
74+
$(KIND) create cluster --name project-v4-with-plugins-test-e2e --wait 5m
75+
76+
.PHONY: test-e2e
77+
test-e2e: setup-test-e2e manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
7878
go test ./test/e2e/ -v -ginkgo.v
79+
$(MAKE) teardown-test-e2e
80+
81+
.PHONY: teardown-test-e2e
82+
teardown-test-e2e: ## Tear down the Kind cluster used for e2e tests
83+
@$(KIND) delete cluster --name project-v4-with-plugins-test-e2e
7984

8085
.PHONY: lint
8186
lint: golangci-lint ## Run golangci-lint linter

Diff for: testdata/project-v4-with-plugins/test/utils/utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func IsCertManagerCRDsInstalled() bool {
167167

168168
// LoadImageToKindClusterWithName loads a local docker image to the kind cluster
169169
func LoadImageToKindClusterWithName(name string) error {
170-
cluster := "kind"
170+
cluster := "project-v4-with-plugins-test-e2e"
171171
if v, ok := os.LookupEnv("KIND_CLUSTER"); ok {
172172
cluster = v
173173
}

Diff for: testdata/project-v4/.github/workflows/test-e2e.yml

-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ jobs:
2626
- name: Verify kind installation
2727
run: kind version
2828

29-
- name: Create kind cluster
30-
run: kind create cluster
31-
3229
- name: Running Test e2e
3330
run: |
3431
go mod tidy

Diff for: testdata/project-v4/Makefile

+11-6
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,22 @@ test: manifests generate fmt vet setup-envtest ## Run tests.
6565
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
6666
# CertManager is installed by default; skip with:
6767
# - CERT_MANAGER_INSTALL_SKIP=true
68-
.PHONY: test-e2e
69-
test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
68+
.PHONY: setup-test-e2e
69+
setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist
7070
@command -v $(KIND) >/dev/null 2>&1 || { \
7171
echo "Kind is not installed. Please install Kind manually."; \
7272
exit 1; \
7373
}
74-
@$(KIND) get clusters | grep -q 'kind' || { \
75-
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
76-
exit 1; \
77-
}
74+
$(KIND) create cluster --name project-v4-test-e2e --wait 5m
75+
76+
.PHONY: test-e2e
77+
test-e2e: setup-test-e2e manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
7878
go test ./test/e2e/ -v -ginkgo.v
79+
$(MAKE) teardown-test-e2e
80+
81+
.PHONY: teardown-test-e2e
82+
teardown-test-e2e: ## Tear down the Kind cluster used for e2e tests
83+
@$(KIND) delete cluster --name project-v4-test-e2e
7984

8085
.PHONY: lint
8186
lint: golangci-lint ## Run golangci-lint linter

Diff for: testdata/project-v4/test/utils/utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func IsCertManagerCRDsInstalled() bool {
167167

168168
// LoadImageToKindClusterWithName loads a local docker image to the kind cluster
169169
func LoadImageToKindClusterWithName(name string) error {
170-
cluster := "kind"
170+
cluster := "project-v4-test-e2e"
171171
if v, ok := os.LookupEnv("KIND_CLUSTER"); ok {
172172
cluster = v
173173
}

0 commit comments

Comments
 (0)