tests: Add helpers for namespace management
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This helper is now used everywhere for setup/teardown, which makes tests more readable, removing duplicate code.
Which issue(s) this PR fixes:
Perhaps preparing ground for https://github.com/kubernetes-sigs/jobset/issues/791
Special notes for your reviewer:
N/A
Does this PR introduce a user-facing change?
NONE
Deploy Preview for kubernetes-sigs-jobset canceled.
| Name | Link |
|---|---|
| Latest commit | dc7fe35b16ba4068d46a64de003e260b76cb9b11 |
| Latest deploy log | https://app.netlify.com/projects/kubernetes-sigs-jobset/deploys/68be98c9122efa0008d7f1c5 |
Hi @tchap. 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.
/ok-to-test
@GiuseppeTT would you please have a moment to review this? It's basically refactoring/cleanup, no new logic 🙏🏻
Hi @tchap, sorry for the delay.
When I run make test-integration using your PR, I get many errors like the following which do not show when using the the code available in the main branch. Can you fix it?
------------------------------
JobSet controller jobset is created and its jobs go through a series of updates [failure policy] jobset restarts with RestartJobSet failure policy action.
.../jobset/test/integration/controller/jobset_controller_test.go:498
2025-09-02T16:46:30-07:00 ERROR creating jobs {"controller": "jobset", "controllerGroup": "jobset.x-k8s.io", "controllerKind": "JobSet", "JobSet": {"name":"test-js","namespace":"jobset-ns-bxwzd"}, "namespace": "jobset-ns-bxwzd", "name": "test-js", "reconcileID": "8accb00a-2be7-4bc3-befa-713c1564b807", "jobset": {"name":"test-js","namespace":"jobset-ns-bxwzd"}, "error": "job \"test-js-replicated-job-b-2\" creation failed with error: jobs.batch \"test-js-replicated-job-b-2\" is forbidden: unable to create new content in namespace jobset-ns-bxwzd because it is being terminated"}
sigs.k8s.io/jobset/pkg/controllers.(*JobSetReconciler).reconcileReplicatedJobs
...jobset/pkg/controllers/jobset_controller.go:566
sigs.k8s.io/jobset/pkg/controllers.(*JobSetReconciler).reconcile
.../jobset/pkg/controllers/jobset_controller.go:207
sigs.k8s.io/jobset/pkg/controllers.(*JobSetReconciler).Reconcile
.../jobset/pkg/controllers/jobset_controller.go:123
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile
.../go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:119
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler
...go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:340
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem
.../go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:300
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.1
.../go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:202
@GiuseppeTT Nice catch. Actually I was deleting the ns directly instead of using util.DeleteNamespace. Fixed.
Code-wise the PR is good so I'll LGTM it. I also manually broke a few tests to check if they would fail as expected.
About merging the refactor itself, it's not clear it's a positive change. Like, it removes code duplication but also makes the code a little bit more complex. Overall I'm neutral, so I'll leave the final call to the approvers.
/lgtm
/assign @kannon92 @andreyvelich
@tenzen-y is this a good step for you to cleaning up the integration tests?
ref: https://github.com/kubernetes-sigs/jobset/issues/791
New changes are detected. LGTM label has been removed.
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: tchap Once this PR has been reviewed and has the lgtm label, please ask for approval from andreyvelich. For more information see the Code Review Process.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
Would somebody please review this? It's starting to rot a bit.