Skip to content

Commit 535aa82

Browse files
chore: add e2e build tag to prevent accidental execution of end-to-end tests
1 parent 574a3da commit 535aa82

File tree

23 files changed

+80
-37
lines changed

23 files changed

+80
-37
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist
8787

8888
.PHONY: test-e2e
8989
test-e2e: setup-test-e2e manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
90-
KIND=$(KIND) KIND_CLUSTER=$(KIND_CLUSTER) go test ./test/e2e/ -v -ginkgo.v
90+
KIND=$(KIND) KIND_CLUSTER=$(KIND_CLUSTER) go test -tags=e2e ./test/e2e/ -v -ginkgo.v
9191
$(MAKE) cleanup-test-e2e
9292

9393
.PHONY: cleanup-test-e2e

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build e2e
2+
// +build e2e
3+
14
/*
25
Copyright 2025 The Kubernetes authors.
36

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build e2e
2+
// +build e2e
3+
14
/*
25
Copyright 2025 The Kubernetes authors.
36

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist
8383

8484
.PHONY: test-e2e
8585
test-e2e: setup-test-e2e manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
86-
KIND=$(KIND) KIND_CLUSTER=$(KIND_CLUSTER) go test ./test/e2e/ -v -ginkgo.v
86+
KIND=$(KIND) KIND_CLUSTER=$(KIND_CLUSTER) go test -tags=e2e ./test/e2e/ -v -ginkgo.v
8787
$(MAKE) cleanup-test-e2e
8888

8989
.PHONY: cleanup-test-e2e

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build e2e
2+
// +build e2e
3+
14
/*
25
Copyright 2025 The Kubernetes authors.
36

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build e2e
2+
// +build e2e
3+
14
/*
25
Copyright 2025 The Kubernetes authors.
36

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist
8787

8888
.PHONY: test-e2e
8989
test-e2e: setup-test-e2e manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
90-
KIND=$(KIND) KIND_CLUSTER=$(KIND_CLUSTER) go test ./test/e2e/ -v -ginkgo.v
90+
KIND=$(KIND) KIND_CLUSTER=$(KIND_CLUSTER) go test -tags=e2e ./test/e2e/ -v -ginkgo.v
9191
$(MAKE) cleanup-test-e2e
9292

9393
.PHONY: cleanup-test-e2e

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build e2e
2+
// +build e2e
3+
14
/*
25
Copyright 2025 The Kubernetes authors.
36

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build e2e
2+
// +build e2e
3+
14
/*
25
Copyright 2025 The Kubernetes authors.
36

hack/docs/internal/cronjob-tutorial/e2e_implementation.go

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,39 @@ limitations under the License.
1717
package cronjob
1818

1919
const isPrometheusInstalledVar = `
20-
// isPrometheusOperatorAlreadyInstalled will be set true when prometheus CRDs be found on the cluster
21-
isPrometheusOperatorAlreadyInstalled = false
22-
`
20+
// isPrometheusOperatorAlreadyInstalled will be set true when prometheus CRDs be found on the cluster
21+
isPrometheusOperatorAlreadyInstalled = false`
2322

2423
const beforeSuitePrometheus = `
25-
By("Ensure that Prometheus is enabled")
24+
By("Ensure that Prometheus is enabled")
2625
_ = utils.UncommentCode("config/default/kustomization.yaml", "#- ../prometheus", "#")
2726
`
2827

2928
const afterSuitePrometheus = `
30-
// Teardown Prometheus after the suite if it was not already installed
31-
if !isPrometheusOperatorAlreadyInstalled {
32-
_, _ = fmt.Fprintf(GinkgoWriter, "Uninstalling Prometheus Operator...\n")
33-
utils.UninstallPrometheusOperator()
34-
}
29+
// Teardown Prometheus after the suite if it was not already installed
30+
if !isPrometheusOperatorAlreadyInstalled {
31+
_, _ = fmt.Fprintf(GinkgoWriter, "Uninstalling Prometheus Operator...\n")
32+
utils.UninstallPrometheusOperator()
33+
}
3534
`
3635

3736
const checkPrometheusInstalled = `
38-
// To prevent errors when tests run in environments with Prometheus already installed,
39-
// we check for its presence before execution.
40-
// Setup Prometheus before the suite if not already installed
41-
By("checking if prometheus is installed already")
42-
isPrometheusOperatorAlreadyInstalled = utils.IsPrometheusCRDsInstalled()
43-
if !isPrometheusOperatorAlreadyInstalled {
44-
_, _ = fmt.Fprintf(GinkgoWriter, "Installing Prometheus Operator...\n")
45-
Expect(utils.InstallPrometheusOperator()).To(Succeed(), "Failed to install Prometheus Operator")
46-
} else {
47-
_, _ = fmt.Fprintf(GinkgoWriter, "WARNING: Prometheus Operator is already installed. Skipping installation...\n")
48-
}
37+
// To prevent errors when tests run in environments with Prometheus already installed,
38+
// we check for its presence before execution.
39+
// Setup Prometheus before the suite if not already installed
40+
By("checking if prometheus is installed already")
41+
isPrometheusOperatorAlreadyInstalled = utils.IsPrometheusCRDsInstalled()
42+
if !isPrometheusOperatorAlreadyInstalled {
43+
_, _ = fmt.Fprintf(GinkgoWriter, "Installing Prometheus Operator...\n")
44+
Expect(utils.InstallPrometheusOperator()).To(Succeed(), "Failed to install Prometheus Operator")
45+
} else {
46+
_, _ = fmt.Fprintf(GinkgoWriter, "WARNING: Prometheus Operator is already installed. Skipping installation...\n")
47+
}
4948
`
5049

5150
const serviceMonitorE2e = `
5251
53-
By("validating that the ServiceMonitor for Prometheus is applied in the namespace")
54-
cmd = exec.Command("kubectl", "get", "ServiceMonitor", "-n", namespace)
55-
_, err = utils.Run(cmd)
56-
Expect(err).NotTo(HaveOccurred(), "ServiceMonitor should exist")
57-
58-
`
52+
By("validating that the ServiceMonitor for Prometheus is applied in the namespace")
53+
cmd = exec.Command("kubectl", "get", "ServiceMonitor", "-n", namespace)
54+
_, err = utils.Run(cmd)
55+
Expect(err).NotTo(HaveOccurred(), "ServiceMonitor should exist")`

0 commit comments

Comments
 (0)