Skip to content

Commit

Permalink
Improve unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PBundyra committed Mar 22, 2024
1 parent f5f97ad commit 6cdc5b5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
2 changes: 2 additions & 0 deletions pkg/controller/jobs/job/job_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,12 @@ func TestReconciler(t *testing.T) {
"when workload is created, it has its owner ProvReq annotations": {
job: *baseJobWrapper.Clone().
SetAnnotation(controllerconsts.ProvReqAnnotationPrefix+"test-annotation", "test-val").
SetAnnotation("invalid-provreq-prefix/test-annotation-2", "test-val-2").
UID("test-uid").
Obj(),
wantJob: *baseJobWrapper.Clone().
SetAnnotation(controllerconsts.ProvReqAnnotationPrefix+"test-annotation", "test-val").
SetAnnotation("invalid-provreq-prefix/test-annotation-2", "test-val-2").
UID("test-uid").
Suspend(true).
Obj(),
Expand Down
10 changes: 8 additions & 2 deletions pkg/controller/jobs/jobset/jobset_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ func TestReconciler(t *testing.T) {
Completions: 2,
Parallelism: 2,
}).
SetAnnotations(map[string]string{controllerconsts.ProvReqAnnotationPrefix + "test-annotation": "test-val"}).
SetAnnotations(map[string]string{
controllerconsts.ProvReqAnnotationPrefix + "test-annotation": "test-val",
"invalid-provreq-prefix/test-annotation-2": "test-val-2",
}).
Obj(),
wantJob: testingjobset.MakeJobSet("jobset", "ns").ReplicatedJobs(
testingjobset.ReplicatedJobRequirements{
Expand All @@ -257,7 +260,10 @@ func TestReconciler(t *testing.T) {
Completions: 2,
Parallelism: 2,
}).
SetAnnotations(map[string]string{controllerconsts.ProvReqAnnotationPrefix + "test-annotation": "test-val"}).
SetAnnotations(map[string]string{
controllerconsts.ProvReqAnnotationPrefix + "test-annotation": "test-val",
"invalid-provreq-prefix/test-annotation-2": "test-val-2",
}).
Obj(),
wantWorkloads: []kueue.Workload{
*utiltesting.MakeWorkload("jobset", "ns").
Expand Down
11 changes: 8 additions & 3 deletions pkg/controller/jobs/kubeflow/jobs/mxjob/mxjob_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,16 @@ func TestReconciler(t *testing.T) {
jobframework.WithManageJobsWithoutQueueName(true),
},
job: testingmxjob.MakeMXJob("mxjob", "ns").
SetAnnotations(map[string]string{controllerconsts.ProvReqAnnotationPrefix + "test-annotation": "test-val"}).
SetAnnotations(map[string]string{
controllerconsts.ProvReqAnnotationPrefix + "test-annotation": "test-val",
"invalid-provreq-prefix/test-annotation-2": "test-val-2",
}).
Obj(),
wantJob: testingmxjob.MakeMXJob("mxjob", "ns").
SetAnnotations(map[string]string{controllerconsts.ProvReqAnnotationPrefix + "test-annotation": "test-val"}).
Obj(),
SetAnnotations(map[string]string{
controllerconsts.ProvReqAnnotationPrefix + "test-annotation": "test-val",
"invalid-provreq-prefix/test-annotation-2": "test-val-2",
}).Obj(),
wantWorkloads: []kueue.Workload{
*utiltesting.MakeWorkload("mxjob", "ns").
SetAnnotations(map[string]string{controllerconsts.ProvReqAnnotationPrefix + "test-annotation": "test-val"}).
Expand Down
6 changes: 6 additions & 0 deletions pkg/controller/jobs/pod/pod_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ func TestReconciler(t *testing.T) {
KueueFinalizer().
KueueSchedulingGate().
Annotation(controllerconsts.ProvReqAnnotationPrefix+"test-annotation", "test-val").
Annotation("invalid-provreq-prefix/test-annotation-2", "test-val-2").
Label("kueue.x-k8s.io/managed", "true").
Obj(),
},
Expand All @@ -509,6 +510,7 @@ func TestReconciler(t *testing.T) {
KueueFinalizer().
KueueSchedulingGate().
Annotation(controllerconsts.ProvReqAnnotationPrefix+"test-annotation", "test-val").
Annotation("invalid-provreq-prefix/test-annotation-2", "test-val-2").
Label("kueue.x-k8s.io/managed", "true").
Obj(),
},
Expand Down Expand Up @@ -546,6 +548,7 @@ func TestReconciler(t *testing.T) {
KueueFinalizer().
KueueSchedulingGate().
Annotation(controllerconsts.ProvReqAnnotationPrefix+"test-annotation", "test-val").
Annotation("invalid-provreq-prefix/test-annotation-2", "test-val-2").
Group("test-group").
GroupTotalCount("2").
Obj(),
Expand All @@ -556,6 +559,7 @@ func TestReconciler(t *testing.T) {
KueueFinalizer().
KueueSchedulingGate().
Annotation(controllerconsts.ProvReqAnnotationPrefix+"test-annotation", "test-val").
Annotation("invalid-provreq-prefix/test-annotation-2", "test-val-2").
Group("test-group").
GroupTotalCount("2").
Obj(),
Expand All @@ -567,6 +571,7 @@ func TestReconciler(t *testing.T) {
KueueFinalizer().
KueueSchedulingGate().
Annotation(controllerconsts.ProvReqAnnotationPrefix+"test-annotation", "test-val").
Annotation("invalid-provreq-prefix/test-annotation-2", "test-val-2").
Group("test-group").
GroupTotalCount("2").
Obj(),
Expand All @@ -577,6 +582,7 @@ func TestReconciler(t *testing.T) {
KueueFinalizer().
KueueSchedulingGate().
Annotation(controllerconsts.ProvReqAnnotationPrefix+"test-annotation", "test-val").
Annotation("invalid-provreq-prefix/test-annotation-2", "test-val-2").
Group("test-group").
GroupTotalCount("2").
Obj(),
Expand Down

0 comments on commit 6cdc5b5

Please sign in to comment.