Skip to content

✨ (go/v4): Add new makefile target to create a cluster name to run the e2e tests #4673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

kersten
Copy link
Contributor

@kersten kersten commented Mar 26, 2025

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.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 26, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @kersten. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 26, 2025
@kersten kersten force-pushed the feat/project-specific-kind-cluster branch 2 times, most recently from e87b922 to c24a8f2 Compare March 26, 2025 16:32
@camilamacedo86 camilamacedo86 changed the title 🐛 update Kind cluster naming for e2e tests ✨ (go/v4): Add new makefile target to create a cluster name to run the e2e tests Mar 27, 2025
exit 1; \
@$(KIND) get clusters | grep -q 'project-test-e2e' || { \
echo "Kind cluster not running, creating Kind cluster: project-test-e2e"; \
$(KIND) create cluster --name project-test-e2e --wait 5m; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I the cluster exist already it will fail, so should we not remove it.
I think we will need to clean it up as well, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! We already have some cleanup logic in our code, I’ll add a dedicated target for it as we have. What do you think - should we clean it up automatically after each test, or just provide a target so it can be run manually? On our side, we usually clean it up manually to avoid long spin-up times during development.

Copy link
Member

@camilamacedo86 camilamacedo86 Mar 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we will need something like

.PHONY: kind-clean
kind-clean: 
	$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)

and call it at the end of the tests

Also, I think we do not need to check and instead only create the cluster nane

	@$(KIND) get clusters | grep -q 'project-test-e2e' || { \
		echo "Kind cluster not running, creating Kind cluster: project-test-e2e"; \
		$(KIND) create cluster --name project-test-e2e --wait 5m; \

Can we also have an env var like the others for the cluster name?

Copy link
Contributor Author

@kersten kersten Mar 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added that already. And the variable was already requested in this PR: #4617. Could you recheck the changes? There ist a teardown-test-e2e target.

I'll add another change, so that it is execute after the test.

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @kersten

I think the change looks good! We just need to make sure to clean up the cluster after the tests run.

Also, I hope you don’t mind—I updated the title of the PR to make it more suitable for the release notes.

@camilamacedo86
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 27, 2025
@kersten kersten force-pushed the feat/project-specific-kind-cluster branch from c24a8f2 to 5f5eb82 Compare March 27, 2025 13:46
@kersten kersten requested a review from camilamacedo86 March 27, 2025 14:05
@kersten kersten force-pushed the feat/project-specific-kind-cluster branch from 5f5eb82 to d48303b Compare March 27, 2025 21:24
@kersten kersten requested a review from camilamacedo86 March 27, 2025 21:27
Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @kersten,

I'm OK with the proposed changes — I think it's a good addition to the default scaffolds.

I just added a couple of minor suggestions:

a) Use KIND_CLUSTER_NAME to parameterize the cluster name used in the tests
b) Simplify the code by removing the extra check

Thanks for the contribution! 🎉

@kersten kersten force-pushed the feat/project-specific-kind-cluster branch 4 times, most recently from 06253d9 to 61a967e Compare March 28, 2025 15:12
@kersten kersten force-pushed the feat/project-specific-kind-cluster branch 3 times, most recently from 03ba85e to 4acb07d Compare March 31, 2025 17:57
@kersten kersten requested a review from camilamacedo86 March 31, 2025 17:59
@kersten kersten force-pushed the feat/project-specific-kind-cluster branch from 4acb07d to d131e27 Compare April 2, 2025 14:22
@kersten kersten requested a review from camilamacedo86 April 2, 2025 15:38
@kersten kersten force-pushed the feat/project-specific-kind-cluster branch 2 times, most recently from e853a8d to 4aac705 Compare April 3, 2025 10:11
KIND_CLUSTER=$(KIND_CLUSTER) go test ./test/e2e/ -v -ginkgo.v
$(MAKE) teardown-test-e2e

.PHONY: teardown-test-e2e
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reviewing possible naming options, it seems that cleanup-test-e2e is the most suitable choice.

It aligns well with the existing setup-test-e2e and test-e2e targets, keeping the naming consistent and intuitive. It also clearly communicates its purpose without being overly verbose or ambiguous.

Let me know if you'd prefer a different naming style, but this feels like the most balanced option for now.

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @kersten 👋

Thank you so much for this change, and sorry for the delay in reviewing it!

After going through everything, I believe we're definitely good to move forward — just two small nitpicks to address before merging:

  1. Revert the unnecessary change in the scaffolds method under utils, so that for now we keep only the Makefile improvements.
    👉 See: https://github.com/kubernetes-sigs/kubebuilder/pull/4673/files#r2030095359

  2. Consider renaming the e2e cleanup test target to cleanup-test-e2e instead of teardown-test-e2e.
    I think it would simplify the name and align better with the existing naming conventions.
    👉 See: https://github.com/kubernetes-sigs/kubebuilder/pull/4673/files#r2030095626

Thanks again for the contribution — really appreciate the effort here! 🙌

@kersten kersten force-pushed the feat/project-specific-kind-cluster branch 2 times, most recently from 1db61f0 to 37a0dd4 Compare April 7, 2025 07:45
@kersten kersten requested a review from camilamacedo86 April 7, 2025 07:47
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.
@kersten kersten force-pushed the feat/project-specific-kind-cluster branch from 37a0dd4 to 2bbb292 Compare April 7, 2025 10:40
@kersten kersten requested a review from camilamacedo86 April 7, 2025 10:40
@camilamacedo86 camilamacedo86 requested a review from Copilot April 8, 2025 09:19
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 4 out of 15 changed files in this pull request and generated no comments.

Files not reviewed (11)
  • docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/test-e2e.yml: Language not supported
  • docs/book/src/cronjob-tutorial/testdata/project/Makefile: Language not supported
  • docs/book/src/getting-started/testdata/project/.github/workflows/test-e2e.yml: Language not supported
  • docs/book/src/getting-started/testdata/project/Makefile: Language not supported
  • docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/test-e2e.yml: Language not supported
  • docs/book/src/multiversion-tutorial/testdata/project/Makefile: Language not supported
  • testdata/project-v4-multigroup/.github/workflows/test-e2e.yml: Language not supported
  • testdata/project-v4-multigroup/Makefile: Language not supported
  • testdata/project-v4-with-plugins/.github/workflows/test-e2e.yml: Language not supported
  • testdata/project-v4-with-plugins/Makefile: Language not supported
  • testdata/project-v4/Makefile: Language not supported

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems great for me 🥇
Thank you for your contribution

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 8, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86, kersten

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 8, 2025
@k8s-ci-robot k8s-ci-robot merged commit de4e5f0 into kubernetes-sigs:master Apr 8, 2025
33 checks passed
@kersten kersten deleted the feat/project-specific-kind-cluster branch April 8, 2025 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants