volcano.sh/volcano@v1.9.0/test/e2e/jobseq/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 jobseq
    18  
    19  import (
    20  	"context"
    21  	. "github.com/onsi/ginkgo/v2"
    22  	. "github.com/onsi/gomega"
    23  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    24  
    25  	busv1alpha1 "volcano.sh/apis/pkg/apis/bus/v1alpha1"
    26  	schedulingv1beta1 "volcano.sh/apis/pkg/apis/scheduling/v1beta1"
    27  	"volcano.sh/volcano/pkg/cli/util"
    28  
    29  	e2eutil "volcano.sh/volcano/test/e2e/util"
    30  )
    31  
    32  var _ = Describe("Queue E2E Test", func() {
    33  	It("Queue Command Close And Open With State Check", func() {
    34  		q1 := "queue-command-close"
    35  		defaultQueue := "default"
    36  		ctx := e2eutil.InitTestContext(e2eutil.Options{
    37  			Queues: []string{q1},
    38  		})
    39  		defer e2eutil.CleanupTestContext(ctx)
    40  
    41  		By("Close queue command check")
    42  		err := util.CreateQueueCommand(ctx.Vcclient, defaultQueue, q1, busv1alpha1.CloseQueueAction)
    43  		if err != nil {
    44  			Expect(err).NotTo(HaveOccurred(), "Error send close queue command")
    45  		}
    46  
    47  		err = e2eutil.WaitQueueStatus(func() (bool, error) {
    48  			queue, err := ctx.Vcclient.SchedulingV1beta1().Queues().Get(context.TODO(), q1, metav1.GetOptions{})
    49  			Expect(err).NotTo(HaveOccurred(), "Get queue %s failed", q1)
    50  			return queue.Status.State == schedulingv1beta1.QueueStateClosed, nil
    51  		})
    52  		Expect(err).NotTo(HaveOccurred(), "Wait for closed queue %s failed", q1)
    53  
    54  		By("Open queue command check")
    55  		err = util.CreateQueueCommand(ctx.Vcclient, defaultQueue, q1, busv1alpha1.OpenQueueAction)
    56  		if err != nil {
    57  			Expect(err).NotTo(HaveOccurred(), "Error send open queue command")
    58  		}
    59  
    60  		err = e2eutil.WaitQueueStatus(func() (bool, error) {
    61  			queue, err := ctx.Vcclient.SchedulingV1beta1().Queues().Get(context.TODO(), q1, metav1.GetOptions{})
    62  			Expect(err).NotTo(HaveOccurred(), "Get queue %s failed", q1)
    63  			return queue.Status.State == schedulingv1beta1.QueueStateOpen, nil
    64  		})
    65  		Expect(err).NotTo(HaveOccurred(), "Wait for reopen queue %s failed", q1)
    66  
    67  	})
    68  })