volcano.sh/volcano@v1.9.0/test/e2e/stress/podgroup.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  	schedulingv1beta1 "volcano.sh/apis/pkg/apis/scheduling/v1beta1"
    27  	e2eutil "volcano.sh/volcano/test/e2e/util"
    28  )
    29  
    30  var _ = ginkgo.Describe("[Stress] Pod Group Test", func() {
    31  	var ctx *e2eutil.TestContext
    32  
    33  	ginkgo.BeforeEach(func() {
    34  		ctx = e2eutil.InitTestContext(e2eutil.Options{})
    35  	})
    36  
    37  	ginkgo.AfterEach(func() {
    38  		e2eutil.CleanupTestContext(ctx)
    39  	})
    40  
    41  	ginkgo.Context("[Sequential] with specific number of stress", func() {
    42  		var wg sync.WaitGroup
    43  
    44  		ginkgo.It("should create multiple pod groups successfully", func() {
    45  			for i := 0; i < e2eutil.NumStress; i++ {
    46  				index := i
    47  				wg.Add(1)
    48  				go func() {
    49  					defer ginkgo.GinkgoRecover()
    50  					defer wg.Done()
    51  
    52  					podGroupName := fmt.Sprintf("pod-group-%d", index)
    53  					podGroup := e2eutil.CreatePodGroup(ctx, podGroupName, "default")
    54  
    55  					err := e2eutil.WaitPodGroupPhase(ctx, podGroup, schedulingv1beta1.PodGroupRunning)
    56  					gomega.Expect(err).NotTo(gomega.HaveOccurred())
    57  				}()
    58  			}
    59  			wg.Wait()
    60  		})
    61  
    62  		ginkgo.It("should delete multiple pod groups successfully", func() {
    63  			for i := 0; i < e2eutil.NumStress; i++ {
    64  				index := i
    65  				wg.Add(1)
    66  				go func() {
    67  					defer ginkgo.GinkgoRecover()
    68  					defer wg.Done()
    69  
    70  					e2eutil.DeletePodGroup(ctx, fmt.Sprintf("pod-group-%d", index), "default")
    71  				}()
    72  			}
    73  			wg.Wait()
    74  		})
    75  	})
    76  })