chore(test): add UTs for Build, Status, and ReconcilerBuilders inter…#3215
chore(test): add UTs for Build, Status, and ReconcilerBuilders inter…#3215Hitanshi7556 wants to merge 1 commit intokubeflow:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
🎉 Welcome to the Kubeflow Trainer! 🎉 Thanks for opening your first PR! We're happy to have you as part of our community 🚀 Here's what happens next:
Join the community:
Feel free to ask questions in the comments if you need any help or clarification! |
…faces Adds missing unit tests for JobSet plugin interfaces as tracked in kubeflow#2468. - TestReconcilerBuilders: verifies watcher wiring returns non-nil builder - TestBuild: covers object generation, nil inputs, and suspended/unsuspended cases - TestStatus: covers condition mapping and ReplicatedJobsStatus to JobsStatus Signed-off-by: Hitanshi Goklani <hitanshigoklani@gmail.com> Signed-off-by: Hitanshi Goklani <hitanshigoklani33@gmail.com>
There was a problem hiding this comment.
Pull request overview
Adds unit tests for the JobSet runtime plugin to cover the remaining framework interfaces and improve decoupling of plugin UTs from the framework tests (Issue #2468).
Changes:
- Removed the TODO placeholder about missing interface tests.
- Added new unit tests for
ReconcilerBuilders,Build, andStatus. - Updated error assertions in the existing
IdentifyPodNetworktest block.
| trainJob *trainer.TrainJob | ||
| info *runtime.Info | ||
| jobSet *jobsetv1alpha2.JobSet | ||
| clientErr error | ||
| wantObjs int |
There was a problem hiding this comment.
TestBuild defines clientErr and sets up an interceptor when it’s non-nil, but none of the test cases set clientErr, so this branch is currently dead code; either remove clientErr/interceptor wiring or add a case that simulates a non-NotFound Get error to assert Build returns that error.
| } | ||
| if err == nil && len(objs) != tc.wantObjs { | ||
| t.Errorf("Expected %d objects, got %d", tc.wantObjs, len(objs)) | ||
| } |
There was a problem hiding this comment.
TestBuild only asserts the number of returned objects, which can still pass if the generated JobSet is malformed or missing key fields (labels/annotations, suspend, owner refs, parallelism/completions updates); consider converting the returned ApplyConfigurations to typed objects and asserting important metadata/spec fields (similar to other plugin Build tests).
| } | |
| } | |
| // When build succeeds and we expect objects, verify the JobSet object is well-formed. | |
| if err == nil && tc.wantObjs > 0 { | |
| var js *jobsetv1alpha2.JobSet | |
| for _, obj := range objs { | |
| if typed, ok := obj.(*jobsetv1alpha2.JobSet); ok { | |
| js = typed | |
| break | |
| } | |
| } | |
| if js == nil { | |
| t.Fatalf("expected at least one JobSet object, but got types: %T", objs) | |
| } | |
| if tc.trainJob != nil { | |
| if js.Namespace != tc.trainJob.Namespace { | |
| t.Errorf("JobSet namespace = %q, want %q", js.Namespace, tc.trainJob.Namespace) | |
| } | |
| if js.Name != tc.trainJob.Name { | |
| t.Errorf("JobSet name = %q, want %q", js.Name, tc.trainJob.Name) | |
| } | |
| } | |
| if js.Spec.Suspend == nil { | |
| t.Errorf("JobSet.Spec.Suspend must be set") | |
| } | |
| } |
| "maps ReplicatedJobsStatus to JobsStatus": { | ||
| trainJob: utiltesting.MakeTrainJobWrapper(metav1.NamespaceDefault, "test").Obj(), | ||
| jobSet: utiltesting.MakeJobSetWrapper(metav1.NamespaceDefault, "test"). | ||
| ReplicatedJobsStatuses([]jobsetv1alpha2.ReplicatedJobStatus{ | ||
| { |
There was a problem hiding this comment.
The ReplicatedJobsStatus -> JobsStatus test uses a single ReplicatedJobStatus entry, so it won’t catch issues that only appear with multiple entries (e.g., pointer reuse when taking addresses inside a range loop); consider adding at least one more ReplicatedJobStatus and asserting the mapped per-entry values are distinct/correct.
| builders := p.(framework.WatchExtensionPlugin).ReconcilerBuilders() | ||
| if len(builders) == 0 { | ||
| t.Error("ReconcilerBuilders must return at least one builder") | ||
| } |
There was a problem hiding this comment.
TestReconcilerBuilders only asserts that the returned slice is non-empty, but it doesn’t verify that the builder functions themselves are non-nil (or that invoking them returns a non-nil *builder.Builder), so it can pass even if wiring is broken; consider iterating builders to assert each entry is non-nil and/or updating the test to exercise the builder function contract (or adjust the PR description accordingly).
29c03a2 to
66b2255
Compare
Adds missing unit tests for JobSet plugin interfaces as tracked in #2468.
TestJobSet and TestValidate already existed, but JobSet implements 5 interfaces.
This PR adds tests for the 3 remaining ones:
related #2468