From 76d53e568bb0f45b1ed6de92a944a5253adc2df2 Mon Sep 17 00:00:00 2001 From: Andrey Velichkevich Date: Mon, 6 Jan 2025 15:26:11 +0000 Subject: [PATCH] Test case when job-2 depends on job-1 and job-3 depends on job-2 --- pkg/webhooks/jobset_webhook_test.go | 55 +++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/pkg/webhooks/jobset_webhook_test.go b/pkg/webhooks/jobset_webhook_test.go index 07da3ed9..ad3f3b3f 100644 --- a/pkg/webhooks/jobset_webhook_test.go +++ b/pkg/webhooks/jobset_webhook_test.go @@ -1489,7 +1489,7 @@ func TestValidateCreate(t *testing.T) { dependsOnTests := []validationTestCase{ { - name: "dependsOn is valid", + name: "DependsOn valid since job-2 depends on job-1 and job-3 depends on job-1", js: &jobset.JobSet{ ObjectMeta: validObjectMeta, Spec: jobset.JobSetSpec{ @@ -1540,7 +1540,58 @@ func TestValidateCreate(t *testing.T) { want: errors.Join(), }, { - name: "job-2 depends on job-3", + name: "DependsOn valid since job-2 depends on job-1 and job-3 depends on job-2", + js: &jobset.JobSet{ + ObjectMeta: validObjectMeta, + Spec: jobset.JobSetSpec{ + SuccessPolicy: &jobset.SuccessPolicy{}, + ReplicatedJobs: []jobset.ReplicatedJob{ + { + Name: "job-1", + Replicas: 1, + Template: batchv1.JobTemplateSpec{ + Spec: batchv1.JobSpec{ + Template: validPodTemplateSpec, + }, + }, + }, + { + Name: "job-2", + DependsOn: []jobset.DependsOn{ + { + Name: "job-1", + Status: "Complete", + }, + }, + Replicas: 1, + Template: batchv1.JobTemplateSpec{ + Spec: batchv1.JobSpec{ + Template: validPodTemplateSpec, + }, + }, + }, + { + Name: "job-3", + DependsOn: []jobset.DependsOn{ + { + Name: "job-2", + Status: "Complete", + }, + }, + Replicas: 1, + Template: batchv1.JobTemplateSpec{ + Spec: batchv1.JobSpec{ + Template: validPodTemplateSpec, + }, + }, + }, + }, + }, + }, + want: errors.Join(), + }, + { + name: "DependsOn invalid due to job-2 depends on job-3", js: &jobset.JobSet{ ObjectMeta: validObjectMeta, Spec: jobset.JobSetSpec{