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

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

Lines changed: 1 addition & 1 deletion
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: |

docs/book/src/cronjob-tutorial/testdata/project/Makefile

Lines changed: 8 additions & 5 deletions
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

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

Lines changed: 1 addition & 1 deletion
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
}

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

Lines changed: 1 addition & 1 deletion
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: |

docs/book/src/getting-started/testdata/project/Makefile

Lines changed: 8 additions & 5 deletions
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

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

Lines changed: 1 addition & 1 deletion
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
}

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

Lines changed: 1 addition & 1 deletion
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: |

docs/book/src/multiversion-tutorial/testdata/project/Makefile

Lines changed: 8 additions & 5 deletions
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

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

Lines changed: 1 addition & 1 deletion
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
}

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

Lines changed: 2 additions & 1 deletion
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: |

0 commit comments

Comments
 (0)