Skip to content

Commit

Permalink
Merge pull request #610 from danielvegamyhre/step
Browse files Browse the repository at this point in the history
Integration test improvement: rename "update" to "step"
  • Loading branch information
k8s-ci-robot authored Jul 1, 2024
2 parents c450428 + 6e1c108 commit 200a3a9
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions test/integration/controller/jobset_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ var _ = ginkgo.Describe("JobSet validation", func() {
}) // end of Describe

var _ = ginkgo.Describe("JobSet controller", func() {
// update contains the mutations to perform on the jobs/jobset and the
// step contains the mutations to perform on the jobs/jobset and the
// checks to perform afterwards.
type update struct {
type step struct {
jobSetUpdateFn func(*jobset.JobSet)
jobUpdateFn func(*batchv1.JobList)
checkJobCreation func(*jobset.JobSet)
Expand All @@ -129,7 +129,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
type testCase struct {
makeJobSet func(*corev1.Namespace) *testing.JobSetWrapper
skipCreationCheck bool
updates []*update
steps []*step
}

var podTemplateUpdates = &updatePodTemplateOpts{
Expand Down Expand Up @@ -174,7 +174,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
}

// Perform a series of updates to jobset resources and check resulting jobset state after each update.
for _, up := range tc.updates {
for _, up := range tc.steps {
var jobSet jobset.JobSet
gomega.Expect(k8sClient.Get(ctx, types.NamespacedName{Name: js.Name, Namespace: js.Namespace}, &jobSet)).To(gomega.Succeed())

Expand Down Expand Up @@ -210,7 +210,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
}),
ginkgo.Entry("jobset should succeed after all jobs succeed", &testCase{
makeJobSet: testJobSet,
updates: []*update{
steps: []*step{
{
jobUpdateFn: completeAllJobs,
checkJobSetCondition: testutil.JobSetCompleted,
Expand All @@ -231,7 +231,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
}),
ginkgo.Entry("jobset should not succeed if any job is not completed", &testCase{
makeJobSet: testJobSet,
updates: []*update{
steps: []*step{
{
jobUpdateFn: func(jobList *batchv1.JobList) {
ginkgo.By("completing all but 1 job")
Expand Down Expand Up @@ -265,7 +265,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
TargetReplicatedJobs: []string{},
})
},
updates: []*update{
steps: []*step{
{
// Complete all the jobs in one replicated job, then ensure the JobSet is still active.
jobUpdateFn: func(jobList *batchv1.JobList) {
Expand Down Expand Up @@ -297,7 +297,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
TargetReplicatedJobs: []string{"replicated-job-b"},
})
},
updates: []*update{
steps: []*step{
{
// Jobset has 2 replicated jobs, but only 1 is selected in the success policy.
// Complete all the jobs in the other replicated job and ensure the jobset is still active.
Expand Down Expand Up @@ -341,7 +341,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
TargetReplicatedJobs: []string{"replicated-job-b"},
})
},
updates: []*update{
steps: []*step{
{
jobUpdateFn: func(jobList *batchv1.JobList) {
ginkgo.By("completing 1 of 3 jobs in replicated-job-b")
Expand All @@ -362,7 +362,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
TargetReplicatedJobs: []string{}, // applies to all replicatedJobs
})
},
updates: []*update{
steps: []*step{
{
jobUpdateFn: func(jobList *batchv1.JobList) {
ginkgo.By("completing a job")
Expand All @@ -374,7 +374,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
}),
ginkgo.Entry("[failure policy] jobset with no failure policy should fail if any jobs fail", &testCase{
makeJobSet: testJobSet,
updates: []*update{
steps: []*step{
{
jobUpdateFn: func(jobList *batchv1.JobList) {
failJob(&jobList.Items[0])
Expand All @@ -385,7 +385,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
}),
ginkgo.Entry("jobset with DNS hostnames enabled should created 1 headless service per job and succeed when all jobs succeed", &testCase{
makeJobSet: testJobSet,
updates: []*update{
steps: []*step{
{
checkJobSetState: checkExpectedServices,
},
Expand All @@ -397,7 +397,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
}),
ginkgo.Entry("succeeds from first run", &testCase{
makeJobSet: testJobSet,
updates: []*update{
steps: []*step{
{
checkJobSetState: checkExpectedServices,
},
Expand All @@ -409,7 +409,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
}),
ginkgo.Entry("fails from first run, no restarts", &testCase{
makeJobSet: testJobSet,
updates: []*update{
steps: []*step{
{
checkJobSetState: checkExpectedServices,
},
Expand All @@ -428,7 +428,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
MaxRestarts: 1,
})
},
updates: []*update{
steps: []*step{
{
jobUpdateFn: func(jobList *batchv1.JobList) {
failJob(&jobList.Items[0])
Expand Down Expand Up @@ -463,7 +463,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
},
})
},
updates: []*update{
steps: []*step{
{
jobUpdateFn: func(jobList *batchv1.JobList) {
failJobWithOptions(&jobList.Items[0], &failJobOptions{reason: ptr.To(batchv1.JobReasonPodFailurePolicy)})
Expand Down Expand Up @@ -491,7 +491,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
},
})
},
updates: []*update{
steps: []*step{
{
jobUpdateFn: func(jobList *batchv1.JobList) {
failJobWithOptions(&jobList.Items[0], &failJobOptions{reason: ptr.To(batchv1.JobReasonPodFailurePolicy)})
Expand Down Expand Up @@ -530,7 +530,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
},
})
},
updates: []*update{
steps: []*step{
{
jobUpdateFn: func(jobList *batchv1.JobList) {
failJobWithOptions(&jobList.Items[0], &failJobOptions{reason: ptr.To(batchv1.JobReasonPodFailurePolicy)})
Expand Down Expand Up @@ -562,7 +562,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
},
})
},
updates: []*update{
steps: []*step{
{
jobUpdateFn: func(jobList *batchv1.JobList) {
failJobWithOptions(&jobList.Items[0], &failJobOptions{reason: ptr.To(batchv1.JobReasonPodFailurePolicy)})
Expand Down Expand Up @@ -636,7 +636,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
},
})
},
updates: []*update{
steps: []*step{
{
jobUpdateFn: func(jobList *batchv1.JobList) {
failFirstMatchingJobWithOptions(jobList, "replicated-job-b", &failJobOptions{reason: ptr.To(batchv1.JobReasonFailedIndexes)})
Expand Down Expand Up @@ -665,7 +665,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
},
})
},
updates: []*update{
steps: []*step{
{
jobUpdateFn: func(jobList *batchv1.JobList) {
failFirstMatchingJobWithOptions(jobList, "replicated-job-b", &failJobOptions{reason: ptr.To(batchv1.JobReasonBackoffLimitExceeded)})
Expand Down Expand Up @@ -706,7 +706,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
},
})
},
updates: []*update{
steps: []*step{
{
jobUpdateFn: func(jobList *batchv1.JobList) {
failFirstMatchingJobWithOptions(jobList, "replicated-job-a", &failJobOptions{reason: ptr.To(batchv1.JobReasonMaxFailedIndexesExceeded)})
Expand Down Expand Up @@ -740,7 +740,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
},
})
},
updates: []*update{
steps: []*step{
{
jobUpdateFn: func(jobList *batchv1.JobList) {
failFirstMatchingJobWithOptions(jobList, "replicated-job-a", &failJobOptions{reason: ptr.To(batchv1.JobReasonMaxFailedIndexesExceeded)})
Expand Down Expand Up @@ -781,7 +781,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
},
})
},
updates: []*update{
steps: []*step{
{
jobUpdateFn: func(jobList *batchv1.JobList) {
failFirstMatchingJobWithOptions(jobList, "replicated-job-a", &failJobOptions{reason: ptr.To(batchv1.JobReasonMaxFailedIndexesExceeded)})
Expand Down Expand Up @@ -860,7 +860,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
MaxRestarts: 1,
})
},
updates: []*update{
steps: []*step{
{
jobUpdateFn: func(jobList *batchv1.JobList) {
completeJob(&jobList.Items[0])
Expand All @@ -885,7 +885,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
return testJobSet(ns).
Suspend(true)
},
updates: []*update{
steps: []*step{
{
checkJobSetState: func(js *jobset.JobSet) {
ginkgo.By("checking all jobs are suspended")
Expand Down Expand Up @@ -914,7 +914,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
makeJobSet: func(ns *corev1.Namespace) *testing.JobSetWrapper {
return testJobSet(ns).Suspend(true)
},
updates: []*update{
steps: []*step{
{
checkJobSetState: func(js *jobset.JobSet) {
ginkgo.By("checking all jobs are suspended")
Expand Down Expand Up @@ -977,7 +977,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
makeJobSet: func(ns *corev1.Namespace) *testing.JobSetWrapper {
return testJobSet(ns).Suspend(false)
},
updates: []*update{
steps: []*step{
{
checkJobSetState: func(js *jobset.JobSet) {
ginkgo.By("checking all jobs are not suspended")
Expand All @@ -1000,7 +1000,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
makeJobSet: func(ns *corev1.Namespace) *testing.JobSetWrapper {
return testJobSet(ns)
},
updates: []*update{
steps: []*step{
{
checkJobSetState: checkExpectedServices,
},
Expand All @@ -1018,7 +1018,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
}),
ginkgo.Entry("update replicatedJobsStatuses after all jobs succeed", &testCase{
makeJobSet: testJobSet,
updates: []*update{
steps: []*step{
{
jobUpdateFn: completeAllJobs,
checkJobSetCondition: testutil.JobSetCompleted,
Expand All @@ -1037,7 +1037,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
makeJobSet: func(ns *corev1.Namespace) *testing.JobSetWrapper {
return testJobSet(ns).Suspend(false)
},
updates: []*update{
steps: []*step{
{
checkJobSetState: func(js *jobset.JobSet) {
ginkgo.By("checking all jobs are not suspended")
Expand Down Expand Up @@ -1065,7 +1065,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
TargetReplicatedJobs: []string{}, // applies to all replicatedJobs
})
},
updates: []*update{
steps: []*step{
// Complete a job, and ensure JobSet completes based on 'any' success policy.
{
jobUpdateFn: func(jobList *batchv1.JobList) {
Expand All @@ -1092,7 +1092,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
}),
ginkgo.Entry("active jobs are deleted after jobset fails", &testCase{
makeJobSet: testJobSet,
updates: []*update{
steps: []*step{
// Fail a job to trigger jobset failure.
{
jobUpdateFn: func(jobList *batchv1.JobList) {
Expand Down Expand Up @@ -1120,7 +1120,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
makeJobSet: func(ns *corev1.Namespace) *testing.JobSetWrapper {
return testJobSet(ns).SetGenerateName("name-prefix").EnableDNSHostnames(true)
},
updates: []*update{
steps: []*step{
{
checkJobSetState: func(js *jobset.JobSet) {
gomega.Eventually(func() error {
Expand All @@ -1137,7 +1137,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
StartupPolicyOrder: jobset.InOrder,
})
},
updates: []*update{
steps: []*step{
{
checkJobSetState: func(js *jobset.JobSet) {
matchJobSetReplicatedStatus(js, []jobset.ReplicatedJobStatus{
Expand All @@ -1161,7 +1161,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
StartupPolicyOrder: jobset.AnyOrder,
})
},
updates: []*update{
steps: []*step{
{
checkJobSetState: func(js *jobset.JobSet) {
matchJobSetReplicatedStatus(js, []jobset.ReplicatedJobStatus{
Expand All @@ -1185,7 +1185,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
StartupPolicyOrder: jobset.AnyOrder,
})
},
updates: []*update{
steps: []*step{
{
checkJobSetState: func(js *jobset.JobSet) {
matchJobSetReplicatedStatus(js, []jobset.ReplicatedJobStatus{
Expand Down Expand Up @@ -1234,7 +1234,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
StartupPolicyOrder: jobset.InOrder,
})
},
updates: []*update{
steps: []*step{
// Ensure replicated job statuses report all child jobs are suspended.
{
checkJobSetState: func(js *jobset.JobSet) {
Expand Down Expand Up @@ -1324,7 +1324,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
})
},
skipCreationCheck: true,
updates: []*update{
steps: []*step{
{
// First update
// Replicated-Job-A should be created.
Expand Down Expand Up @@ -1414,7 +1414,7 @@ var _ = ginkgo.Describe("JobSet controller", func() {
})
},
skipCreationCheck: true,
updates: []*update{
steps: []*step{
{
checkJobCreation: func(js *jobset.JobSet) {
expectedStarts := 1
Expand Down

0 comments on commit 200a3a9

Please sign in to comment.