volcano.sh/volcano@v1.9.0/test/e2e/stress/queue.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  	"context"
    21  	"fmt"
    22  	"sync"
    23  
    24  	"github.com/onsi/ginkgo/v2"
    25  	"github.com/onsi/gomega"
    26  
    27  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    28  
    29  	schedulingv1beta1 "volcano.sh/apis/pkg/apis/scheduling/v1beta1"
    30  	e2eutil "volcano.sh/volcano/test/e2e/util"
    31  )
    32  
    33  var _ = ginkgo.Describe("[Stress] Queue Test", func() {
    34  	var ctx *e2eutil.TestContext
    35  
    36  	ginkgo.BeforeEach(func() {
    37  		ctx = e2eutil.InitTestContext(e2eutil.Options{})
    38  	})
    39  
    40  	ginkgo.AfterEach(func() {
    41  		e2eutil.CleanupTestContext(ctx)
    42  	})
    43  
    44  	ginkgo.Context("[Sequential] with specific number of stress", func() {
    45  		var wg sync.WaitGroup
    46  
    47  		ginkgo.It("should create multiple queues successfully", func() {
    48  			for i := 0; i < e2eutil.NumStress; i++ {
    49  				index := i
    50  				wg.Add(1)
    51  				go func() {
    52  					defer ginkgo.GinkgoRecover()
    53  					defer wg.Done()
    54  
    55  					queueName := fmt.Sprintf("queue-%d", index)
    56  					e2eutil.CreateQueue(ctx, queueName, nil)
    57  					err := e2eutil.WaitQueueStatus(func() (bool, error) {
    58  						queue, err := ctx.Vcclient.SchedulingV1beta1().Queues().Get(context.TODO(), queueName, metav1.GetOptions{})
    59  						gomega.Expect(err).NotTo(gomega.HaveOccurred())
    60  						return queue.Status.State == schedulingv1beta1.QueueStateOpen, nil
    61  					})
    62  					gomega.Expect(err).NotTo(gomega.HaveOccurred())
    63  				}()
    64  			}
    65  			wg.Wait()
    66  		})
    67  
    68  		ginkgo.It("should delete multiple queues successfully", func() {
    69  			for i := 0; i < e2eutil.NumStress; i++ {
    70  				index := i
    71  				wg.Add(1)
    72  				go func() {
    73  					defer ginkgo.GinkgoRecover()
    74  					defer wg.Done()
    75  
    76  					e2eutil.DeleteQueue(ctx, fmt.Sprintf("queue-%d", index))
    77  				}()
    78  			}
    79  			wg.Wait()
    80  		})
    81  	})
    82  })