|
| 1 | +/* |
| 2 | +Licensed to the Apache Software Foundation (ASF) under one |
| 3 | +or more contributor license agreements. See the NOTICE file |
| 4 | +distributed with this work for additional information |
| 5 | +regarding copyright ownership. The ASF licenses this file |
| 6 | +to you under the Apache License, Version 2.0 (the |
| 7 | +"License"); you may not use this file except in compliance |
| 8 | +with the License. You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | +Unless required by applicable law or agreed to in writing, software |
| 13 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +See the License for the specific language governing permissions and |
| 16 | +limitations under the License. |
| 17 | +*/ |
| 18 | +package quota_preemption_test |
| 19 | + |
| 20 | +import ( |
| 21 | + "path/filepath" |
| 22 | + "runtime" |
| 23 | + "testing" |
| 24 | + |
| 25 | + "github.com/onsi/ginkgo/v2" |
| 26 | + "github.com/onsi/ginkgo/v2/reporters" |
| 27 | + "github.com/onsi/gomega" |
| 28 | + |
| 29 | + "github.com/apache/yunikorn-k8shim/test/e2e/framework/configmanager" |
| 30 | + "github.com/apache/yunikorn-k8shim/test/e2e/framework/helpers/common" |
| 31 | + "github.com/apache/yunikorn-k8shim/test/e2e/framework/helpers/k8s" |
| 32 | + "github.com/apache/yunikorn-k8shim/test/e2e/framework/helpers/yunikorn" |
| 33 | +) |
| 34 | + |
| 35 | +func init() { |
| 36 | + configmanager.YuniKornTestConfig.ParseFlags() |
| 37 | +} |
| 38 | + |
| 39 | +func TestQuotaPreemption(t *testing.T) { |
| 40 | + ginkgo.ReportAfterSuite("TestQuotaPreemption", func(report ginkgo.Report) { |
| 41 | + err := reporters.GenerateJUnitReportWithConfig( |
| 42 | + report, |
| 43 | + filepath.Join(configmanager.YuniKornTestConfig.LogDir, "TEST-quotapreemption_junit.xml"), |
| 44 | + reporters.JunitReportConfig{OmitSpecLabels: true}, |
| 45 | + ) |
| 46 | + Ω(err).NotTo(HaveOccurred()) |
| 47 | + }) |
| 48 | + gomega.RegisterFailHandler(ginkgo.Fail) |
| 49 | + ginkgo.RunSpecs(t, "TestQuotaPreemption", ginkgo.Label("TestQuotaPreemption")) |
| 50 | +} |
| 51 | + |
| 52 | +var Ω = gomega.Ω |
| 53 | +var HaveOccurred = gomega.HaveOccurred |
| 54 | + |
| 55 | +var _ = ginkgo.BeforeSuite(func() { |
| 56 | + _, filename, _, _ := runtime.Caller(0) |
| 57 | + suiteName = common.GetSuiteName(filename) |
| 58 | + // Initializing kubectl client |
| 59 | + kClient = k8s.KubeCtl{} |
| 60 | + Ω(kClient.SetClient()).To(gomega.Succeed()) |
| 61 | + // Initializing rest client |
| 62 | + restClient = yunikorn.RClient{} |
| 63 | + Ω(restClient).NotTo(gomega.BeNil()) |
| 64 | + |
| 65 | + yunikorn.EnsureYuniKornConfigsPresent() |
| 66 | + |
| 67 | + ginkgo.By("Port-forward the scheduler pod") |
| 68 | + var err = kClient.PortForwardYkSchedulerPod() |
| 69 | + Ω(err).NotTo(gomega.HaveOccurred()) |
| 70 | +}) |
| 71 | + |
| 72 | +var _ = ginkgo.AfterSuite(func() { |
| 73 | + ginkgo.By("Check Yunikorn's health") |
| 74 | + checks, err := yunikorn.GetFailedHealthChecks() |
| 75 | + Ω(err).NotTo(gomega.HaveOccurred()) |
| 76 | + Ω(checks).To(gomega.Equal(""), checks) |
| 77 | +}) |
0 commit comments