volcano.sh/volcano@v1.9.0/test/e2e/stress/job.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 stress 18 19 import ( 20 "fmt" 21 "sync" 22 23 "github.com/onsi/ginkgo/v2" 24 "github.com/onsi/gomega" 25 26 e2eutil "volcano.sh/volcano/test/e2e/util" 27 ) 28 29 var _ = ginkgo.Describe("[Stress] Job Test", func() { 30 var ctx *e2eutil.TestContext 31 32 ginkgo.BeforeEach(func() { 33 ctx = e2eutil.InitTestContext(e2eutil.Options{}) 34 }) 35 36 ginkgo.AfterEach(func() { 37 e2eutil.CleanupTestContext(ctx) 38 }) 39 40 ginkgo.Context("[Sequential] with specific number of stress", func() { 41 var wg sync.WaitGroup 42 43 ginkgo.It("should create multiple jobs successfully", func() { 44 for i := 0; i < e2eutil.NumStress; i++ { 45 index := i 46 wg.Add(1) 47 go func() { 48 defer ginkgo.GinkgoRecover() 49 defer wg.Done() 50 51 job := &e2eutil.JobSpec{ 52 Name: fmt.Sprintf("job-%d", index), 53 Tasks: []e2eutil.TaskSpec{ 54 { 55 Img: e2eutil.DefaultNginxImage, 56 Req: e2eutil.HalfCPU, 57 Min: 1, 58 Rep: 1, 59 }, 60 }, 61 } 62 referenceJob := e2eutil.CreateJob(ctx, job) 63 err := e2eutil.WaitTasksReady(ctx, referenceJob, 1) 64 gomega.Expect(err).NotTo(gomega.HaveOccurred()) 65 }() 66 } 67 wg.Wait() 68 }) 69 }) 70 })