Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/book/src/cronjob-tutorial/testdata/project/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist

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

.PHONY: cleanup-test-e2e
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build e2e
// +build e2e

/*
Copyright 2025 The Kubernetes authors.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build e2e
// +build e2e

/*
Copyright 2025 The Kubernetes authors.

Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/getting-started/testdata/project/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist

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

.PHONY: cleanup-test-e2e
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build e2e
// +build e2e

/*
Copyright 2025 The Kubernetes authors.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build e2e
// +build e2e

/*
Copyright 2025 The Kubernetes authors.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist

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

.PHONY: cleanup-test-e2e
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build e2e
// +build e2e

/*
Copyright 2025 The Kubernetes authors.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build e2e
// +build e2e

/*
Copyright 2025 The Kubernetes authors.

Expand Down
49 changes: 23 additions & 26 deletions hack/docs/internal/cronjob-tutorial/e2e_implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,39 @@ limitations under the License.
package cronjob

const isPrometheusInstalledVar = `
// isPrometheusOperatorAlreadyInstalled will be set true when prometheus CRDs be found on the cluster
isPrometheusOperatorAlreadyInstalled = false
`
// isPrometheusOperatorAlreadyInstalled will be set true when prometheus CRDs be found on the cluster
isPrometheusOperatorAlreadyInstalled = false`

const beforeSuitePrometheus = `
By("Ensure that Prometheus is enabled")
By("Ensure that Prometheus is enabled")
_ = utils.UncommentCode("config/default/kustomization.yaml", "#- ../prometheus", "#")
`

const afterSuitePrometheus = `
// Teardown Prometheus after the suite if it was not already installed
if !isPrometheusOperatorAlreadyInstalled {
_, _ = fmt.Fprintf(GinkgoWriter, "Uninstalling Prometheus Operator...\n")
utils.UninstallPrometheusOperator()
}
// Teardown Prometheus after the suite if it was not already installed
if !isPrometheusOperatorAlreadyInstalled {
_, _ = fmt.Fprintf(GinkgoWriter, "Uninstalling Prometheus Operator...\n")
utils.UninstallPrometheusOperator()
}
`

const checkPrometheusInstalled = `
// To prevent errors when tests run in environments with Prometheus already installed,
// we check for its presence before execution.
// Setup Prometheus before the suite if not already installed
By("checking if prometheus is installed already")
isPrometheusOperatorAlreadyInstalled = utils.IsPrometheusCRDsInstalled()
if !isPrometheusOperatorAlreadyInstalled {
_, _ = fmt.Fprintf(GinkgoWriter, "Installing Prometheus Operator...\n")
Expect(utils.InstallPrometheusOperator()).To(Succeed(), "Failed to install Prometheus Operator")
} else {
_, _ = fmt.Fprintf(GinkgoWriter, "WARNING: Prometheus Operator is already installed. Skipping installation...\n")
}
// To prevent errors when tests run in environments with Prometheus already installed,
// we check for its presence before execution.
// Setup Prometheus before the suite if not already installed
By("checking if prometheus is installed already")
isPrometheusOperatorAlreadyInstalled = utils.IsPrometheusCRDsInstalled()
if !isPrometheusOperatorAlreadyInstalled {
_, _ = fmt.Fprintf(GinkgoWriter, "Installing Prometheus Operator...\n")
Expect(utils.InstallPrometheusOperator()).To(Succeed(), "Failed to install Prometheus Operator")
} else {
_, _ = fmt.Fprintf(GinkgoWriter, "WARNING: Prometheus Operator is already installed. Skipping installation...\n")
}
`

const serviceMonitorE2e = `

By("validating that the ServiceMonitor for Prometheus is applied in the namespace")
cmd = exec.Command("kubectl", "get", "ServiceMonitor", "-n", namespace)
_, err = utils.Run(cmd)
Expect(err).NotTo(HaveOccurred(), "ServiceMonitor should exist")

`
By("validating that the ServiceMonitor for Prometheus is applied in the namespace")
cmd = exec.Command("kubectl", "get", "ServiceMonitor", "-n", namespace)
_, err = utils.Run(cmd)
Expect(err).NotTo(HaveOccurred(), "ServiceMonitor should exist")`
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist

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

.PHONY: cleanup-test-e2e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ func (f *SuiteTest) SetTemplateDefaults() error {
return nil
}

var suiteTestTemplate = `{{ .Boilerplate }}
var suiteTestTemplate = `//go:build e2e
// +build e2e

{{ .Boilerplate }}

package e2e

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ const conversionWebhookChecksFragment = `It("should have CA injection for %[1]s

`

var testCodeTemplate = `{{ .Boilerplate }}
var testCodeTemplate = `//go:build e2e
// +build e2e

{{ .Boilerplate }}

package e2e

Expand Down
12 changes: 10 additions & 2 deletions test/check-license.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,16 @@ echo "Checking for license header..."
allfiles=$(listFiles | grep -v -e './internal/bindata/...' -e '.devcontainer/post-install.sh' -e '.github/*')
licRes=""
for file in $allfiles; do
if ! head -n4 "${file}" | grep -Eq "(Copyright|generated|GENERATED|Licensed)" ; then
licRes="${licRes}\n"$(echo -e " ${file}")
if [[ -f "$file" && "$(file --mime-type -b "$file")" == text/* ]]; then
# Read the first few lines but skip build tags for Go files
# Strip up to 3 lines starting with //go:build or // +build
stripped=$(head -n 30 "$file" \
| sed '/^\/\/go:build\|^\/\/ +build/d' \
| sed '/^\s*$/d' \
| head -n 10)
if ! echo "$stripped" | grep -Eq "(Copyright|generated|GENERATED|Licensed)" ; then
licRes="${licRes}\n ${file}"
fi
fi
done
if [ -n "${licRes}" ]; then
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v4-multigroup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist

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

.PHONY: cleanup-test-e2e
Expand Down
3 changes: 3 additions & 0 deletions testdata/project-v4-multigroup/test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build e2e
// +build e2e

/*
Copyright 2025 The Kubernetes authors.

Expand Down
3 changes: 3 additions & 0 deletions testdata/project-v4-multigroup/test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build e2e
// +build e2e

/*
Copyright 2025 The Kubernetes authors.

Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v4-with-plugins/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist

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

.PHONY: cleanup-test-e2e
Expand Down
3 changes: 3 additions & 0 deletions testdata/project-v4-with-plugins/test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build e2e
// +build e2e

/*
Copyright 2025 The Kubernetes authors.

Expand Down
3 changes: 3 additions & 0 deletions testdata/project-v4-with-plugins/test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build e2e
// +build e2e

/*
Copyright 2025 The Kubernetes authors.

Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v4/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist

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

.PHONY: cleanup-test-e2e
Expand Down
3 changes: 3 additions & 0 deletions testdata/project-v4/test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build e2e
// +build e2e

/*
Copyright 2025 The Kubernetes authors.

Expand Down
3 changes: 3 additions & 0 deletions testdata/project-v4/test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build e2e
// +build e2e

/*
Copyright 2025 The Kubernetes authors.

Expand Down
Loading