Skip to content

Commit e87b922

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 858b04b commit e87b922

File tree

21 files changed

+72
-49
lines changed

21 files changed

+72
-49
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: kind version
2828

2929
- name: Create kind cluster
30-
run: kind create cluster
30+
run: kind create cluster --name project-test-e2e
3131

3232
- name: Running Test e2e
3333
run: |

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

+8-5
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,19 @@ 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-e2e-test
73+
setup-e2e-test: ## 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; \
78+
@$(KIND) get clusters | grep -q 'project-e2e-test' || { \
79+
echo "Kind cluster not running, creating Kind cluster: project-e2e-test"; \
80+
$(KIND) create cluster --name project-e2e-test; \
8181
}
82+
83+
.PHONY: test-e2e
84+
test-e2e: setup-e2e-test manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
8285
go test ./test/e2e/ -v -ginkgo.v
8386

8487
.PHONY: lint

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-e2e-test"
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: kind version
2828

2929
- name: Create kind cluster
30-
run: kind create cluster
30+
run: kind create cluster --name project-test-e2e
3131

3232
- name: Running Test e2e
3333
run: |

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

+8-5
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,19 @@ 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-e2e-test
69+
setup-e2e-test: ## 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; \
74+
@$(KIND) get clusters | grep -q 'project-e2e-test' || { \
75+
echo "Kind cluster not running, creating Kind cluster: project-e2e-test"; \
76+
$(KIND) create cluster --name project-e2e-test; \
7777
}
78+
79+
.PHONY: test-e2e
80+
test-e2e: setup-e2e-test manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
7881
go test ./test/e2e/ -v -ginkgo.v
7982

8083
.PHONY: lint

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-e2e-test"
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: kind version
2828

2929
- name: Create kind cluster
30-
run: kind create cluster
30+
run: kind create cluster --name project-test-e2e
3131

3232
- name: Running Test e2e
3333
run: |

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

+8-5
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,19 @@ 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-e2e-test
73+
setup-e2e-test: ## 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; \
78+
@$(KIND) get clusters | grep -q 'project-e2e-test' || { \
79+
echo "Kind cluster not running, creating Kind cluster: project-e2e-test"; \
80+
$(KIND) create cluster --name project-e2e-test; \
8181
}
82+
83+
.PHONY: test-e2e
84+
test-e2e: setup-e2e-test manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
8285
go test ./test/e2e/ -v -ginkgo.v
8386

8487
.PHONY: lint

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-e2e-test"
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

+2-1
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
@@ -72,7 +73,7 @@ jobs:
7273
run: kind version
7374
7475
- name: Create kind cluster
75-
run: kind create cluster
76+
run: kind create cluster --name {{ .ProjectName }}-test-e2e
7677
7778
- name: Running Test e2e
7879
run: |

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

+8-5
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,19 @@ 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-e2e-test
148+
setup-e2e-test: ## 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; \
153+
@$(KIND) get clusters | grep -q '{{ .ProjectName }}-e2e-test' || { \
154+
echo "Kind cluster not running, creating Kind cluster: {{ .ProjectName }}-e2e-test"; \
155+
$(KIND) create cluster --name {{ .ProjectName }}-e2e-test; \
156156
}
157+
158+
.PHONY: test-e2e
159+
test-e2e: setup-e2e-test manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
157160
go test ./test/e2e/ -v -ginkgo.v
158161
159162
.PHONY: lint

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 }}-e2e-test"
198199
if v, ok := os.LookupEnv("KIND_CLUSTER"); ok {
199200
cluster = v
200201
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: kind version
2828

2929
- name: Create kind cluster
30-
run: kind create cluster
30+
run: kind create cluster --name project-v4-multigroup-test-e2e
3131

3232
- name: Running Test e2e
3333
run: |

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

+8-5
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,19 @@ 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-e2e-test
69+
setup-e2e-test: ## 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; \
74+
@$(KIND) get clusters | grep -q 'project-v4-multigroup-e2e-test' || { \
75+
echo "Kind cluster not running, creating Kind cluster: project-v4-multigroup-e2e-test"; \
76+
$(KIND) create cluster --name project-v4-multigroup-e2e-test; \
7777
}
78+
79+
.PHONY: test-e2e
80+
test-e2e: setup-e2e-test manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
7881
go test ./test/e2e/ -v -ginkgo.v
7982

8083
.PHONY: lint

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-e2e-test"
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: kind version
2828

2929
- name: Create kind cluster
30-
run: kind create cluster
30+
run: kind create cluster --name project-v4-with-plugins-test-e2e
3131

3232
- name: Running Test e2e
3333
run: |

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

+8-5
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,19 @@ 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-e2e-test
69+
setup-e2e-test: ## 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; \
74+
@$(KIND) get clusters | grep -q 'project-v4-with-plugins-e2e-test' || { \
75+
echo "Kind cluster not running, creating Kind cluster: project-v4-with-plugins-e2e-test"; \
76+
$(KIND) create cluster --name project-v4-with-plugins-e2e-test; \
7777
}
78+
79+
.PHONY: test-e2e
80+
test-e2e: setup-e2e-test manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
7881
go test ./test/e2e/ -v -ginkgo.v
7982

8083
.PHONY: lint

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-e2e-test"
171171
if v, ok := os.LookupEnv("KIND_CLUSTER"); ok {
172172
cluster = v
173173
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: kind version
2828

2929
- name: Create kind cluster
30-
run: kind create cluster
30+
run: kind create cluster --name project-v4-test-e2e
3131

3232
- name: Running Test e2e
3333
run: |

Diff for: testdata/project-v4/Makefile

+8-5
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,19 @@ 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-e2e-test
69+
setup-e2e-test: ## 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; \
74+
@$(KIND) get clusters | grep -q 'project-v4-e2e-test' || { \
75+
echo "Kind cluster not running, creating Kind cluster: project-v4-e2e-test"; \
76+
$(KIND) create cluster --name project-v4-e2e-test; \
7777
}
78+
79+
.PHONY: test-e2e
80+
test-e2e: setup-e2e-test manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
7881
go test ./test/e2e/ -v -ginkgo.v
7982

8083
.PHONY: lint

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-e2e-test"
171171
if v, ok := os.LookupEnv("KIND_CLUSTER"); ok {
172172
cluster = v
173173
}

0 commit comments

Comments
 (0)