jobset icon indicating copy to clipboard operation
jobset copied to clipboard

tests: Add helpers for namespace management

Open tchap opened this issue 4 months ago • 13 comments

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

tchap avatar Jul 30 '25 12:07 tchap

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

netlify[bot] avatar Jul 30 '25 12:07 netlify[bot]

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.

k8s-ci-robot avatar Jul 30 '25 12:07 k8s-ci-robot

/ok-to-test

GiuseppeTT avatar Jul 30 '25 16:07 GiuseppeTT

@GiuseppeTT would you please have a moment to review this? It's basically refactoring/cleanup, no new logic 🙏🏻

tchap avatar Sep 02 '25 08:09 tchap

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 avatar Sep 02 '25 23:09 GiuseppeTT

@GiuseppeTT Nice catch. Actually I was deleting the ns directly instead of using util.DeleteNamespace. Fixed.

tchap avatar Sep 03 '25 13:09 tchap

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.

GiuseppeTT avatar Sep 05 '25 02:09 GiuseppeTT

/lgtm

GiuseppeTT avatar Sep 05 '25 02:09 GiuseppeTT

/assign @kannon92 @andreyvelich

GiuseppeTT avatar Sep 05 '25 02:09 GiuseppeTT

@tenzen-y is this a good step for you to cleaning up the integration tests?

ref: https://github.com/kubernetes-sigs/jobset/issues/791

kannon92 avatar Sep 05 '25 14:09 kannon92

New changes are detected. LGTM label has been removed.

k8s-ci-robot avatar Sep 08 '25 08:09 k8s-ci-robot

[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.

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 avatar Sep 08 '25 08:09 k8s-ci-robot

Would somebody please review this? It's starting to rot a bit.

tchap avatar Oct 18 '25 14:10 tchap