Skip to content

Commit 65ba469

Browse files
adityadtu5manirajv06
authored andcommitted
[YUNIKORN-3204] Quota Preemption E2E testing(#1009)
Closes: #1009 Signed-off-by: Manikandan R <manirajv06@gmail.com>
1 parent d4babeb commit 65ba469

23 files changed

Lines changed: 1706 additions & 1 deletion

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ require (
2727
github.com/google/uuid v1.6.0
2828
github.com/looplab/fsm v1.0.3
2929
github.com/onsi/ginkgo/v2 v2.27.2
30-
github.com/onsi/gomega v1.38.2
30+
github.com/onsi/gomega v1.40.0
3131
github.com/prometheus/client_golang v1.23.2
3232
github.com/sasha-s/go-deadlock v0.3.9
3333
go.uber.org/zap v1.27.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ github.com/onsi/ginkgo/v2 v2.27.2 h1:LzwLj0b89qtIy6SSASkzlNvX6WktqurSHwkk2ipF/Ns
153153
github.com/onsi/ginkgo/v2 v2.27.2/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo=
154154
github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A=
155155
github.com/onsi/gomega v1.38.2/go.mod h1:W2MJcYxRGV63b418Ai34Ud0hEdTVXq9NW9+Sx6uXf3k=
156+
github.com/onsi/gomega v1.40.0 h1:Vtol0e1MghCD2ZVIilPDIg44XSL9l2QAn8ZNaljWcJc=
157+
github.com/onsi/gomega v1.40.0/go.mod h1:M/Uqpu/8qTjtzCLUA2zJHX9Iilrau25x1PdoSRbWh5A=
156158
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
157159
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
158160
github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI=

test/e2e/framework/helpers/k8s/k8s_utils.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,18 @@ func GetPodObj(yamlPath string) (*v1.Pod, error) {
795795
return pod, nil
796796
}
797797

798+
func GetDeploymentObj(yamlPath string) (*appsv1.Deployment, error) {
799+
o, err := common.Yaml2Obj(yamlPath)
800+
if err != nil {
801+
return nil, err
802+
}
803+
deployment, ok := o.(*appsv1.Deployment)
804+
if !ok {
805+
return nil, fmt.Errorf("failed to convert object to Deployment")
806+
}
807+
return deployment, nil
808+
}
809+
798810
func (k *KubeCtl) CreateDeployment(deployment *appsv1.Deployment, namespace string) (*appsv1.Deployment, error) {
799811
return k.clientSet.AppsV1().Deployments(namespace).Create(context.TODO(), deployment, metav1.CreateOptions{})
800812
}
@@ -1113,6 +1125,24 @@ func (k *KubeCtl) WaitForPodBySelectorRunning(namespace string, selector string,
11131125
return nil
11141126
}
11151127

1128+
func (k *KubeCtl) WaitForNPodsBySelectorRunning(namespace string, selector string, expectedCount int, timeout time.Duration) error {
1129+
return wait.PollUntilContextTimeout(context.TODO(), time.Millisecond*100, timeout, false, func(ctx context.Context) (bool, error) {
1130+
podList, err := k.ListPods(namespace, selector)
1131+
if err != nil {
1132+
return false, err
1133+
}
1134+
if len(podList.Items) != expectedCount {
1135+
return false, nil
1136+
}
1137+
for _, pod := range podList.Items {
1138+
if pod.Status.Phase != v1.PodRunning {
1139+
return false, nil
1140+
}
1141+
}
1142+
return true, nil
1143+
})
1144+
}
1145+
11161146
// Wait for all pods in 'namespace' with given 'selector' to enter succeeded state.
11171147
// Returns an error if no pods are found or not all discovered pods enter succeeded state.
11181148
func (k *KubeCtl) WaitForPodBySelectorSucceeded(namespace string, selector string, timeout time.Duration) error {
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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

Comments
 (0)