volcano.sh/volcano@v1.9.0/test/e2e/jobp/min_success.go (about) 1 /* 2 Copyright 2021 The Volcano Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package jobp 18 19 import ( 20 . "github.com/onsi/ginkgo/v2" 21 . "github.com/onsi/gomega" 22 vcbatch "volcano.sh/apis/pkg/apis/batch/v1alpha1" 23 24 e2eutil "volcano.sh/volcano/test/e2e/util" 25 ) 26 27 var _ = Describe("Check min success", func() { 28 It("Min Success", func() { 29 ctx := e2eutil.InitTestContext(e2eutil.Options{}) 30 defer e2eutil.CleanupTestContext(ctx) 31 32 jobName := "min-success-job" 33 By("create job") 34 var minSuccess int32 = 2 35 job := e2eutil.CreateJob(ctx, &e2eutil.JobSpec{ 36 Name: jobName, 37 MinSuccess: &minSuccess, 38 Tasks: []e2eutil.TaskSpec{ 39 { 40 Name: "short", 41 Img: e2eutil.DefaultBusyBoxImage, 42 Min: 1, 43 Rep: 3, 44 Command: "sleep 3", 45 }, 46 { 47 Name: "log", 48 Img: e2eutil.DefaultBusyBoxImage, 49 Min: 1, 50 Rep: 2, 51 Command: "sleep 100000", 52 }, 53 }, 54 }) 55 56 // job phase: pending -> running 57 err := e2eutil.WaitJobReady(ctx, job) 58 Expect(err).NotTo(HaveOccurred()) 59 60 // wait short tasks completed 61 err = e2eutil.WaitTasksCompleted(ctx, job, minSuccess) 62 Expect(err).NotTo(HaveOccurred()) 63 64 // wait job completed 65 err = e2eutil.WaitJobStates(ctx, job, []vcbatch.JobPhase{vcbatch.Completed}, e2eutil.OneMinute) 66 Expect(err).NotTo(HaveOccurred()) 67 }) 68 })