Skip to content

Commit

Permalink
[YUNIKORN-1126] Added E2E Tests for Best Effort Pod
Browse files Browse the repository at this point in the history
  • Loading branch information
rrajesh-cloudera committed Sep 3, 2024
1 parent f8e9c11 commit 8c9db7c
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 6 deletions.
50 changes: 50 additions & 0 deletions test/e2e/basic_scheduling/basic_scheduling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,56 @@ var _ = ginkgo.Describe("", func() {
Ω(resMap["vcore"]).To(gomega.Equal(core))
})

ginkgo.It("Verify_BestEffort_QOS_Pod_Scheduling", func() {
ginkgo.By("Create a pod with QOS class set to BestEffort")
bestEffortPodConfig := k8s.SleepPodConfig{Name: "besteffortpod", NS: dev, QOSClass: v1.PodQOSBestEffort}
initPod, podErr := k8s.InitSleepPod(bestEffortPodConfig)
gomega.Ω(podErr).NotTo(gomega.HaveOccurred())
bestEffortPod, err := kClient.CreatePod(initPod, dev)
gomega.Ω(err).NotTo(gomega.HaveOccurred())

ginkgo.By("Wait for the pod to move to running state")
err = kClient.WaitForPodRunning(dev, bestEffortPodConfig.Name, 30*time.Second)
gomega.Ω(err).NotTo(gomega.HaveOccurred())

ginkgo.By("Verify that the pod is scheduled and running")
appsInfo, err = restClient.GetAppInfo("default", "root."+dev, bestEffortPod.ObjectMeta.Labels["applicationId"])
gomega.Ω(err).NotTo(gomega.HaveOccurred())
gomega.Ω(appsInfo).NotTo(gomega.BeNil())
gomega.Ω(appsInfo.State).To(gomega.Equal("Running"))

ginkgo.By("Verify that the pod's QOS class is BestEffort")
gomega.Ω(bestEffortPod.Status.QOSClass).To(gomega.Equal(v1.PodQOSBestEffort))

ginkgo.By("Verify that the pod's scheduler name is yunikorn")
gomega.Ω("yunikorn").To(gomega.Equal(bestEffortPod.Spec.SchedulerName))
})

ginkgo.It("Verify_NonBestEffort_QOS_Pod_Scheduling", func() {
ginkgo.By("Create a pod with QOS class set to Burstable")
burstablePodConfig := k8s.SleepPodConfig{Name: "burstablepod", NS: dev, QOSClass: v1.PodQOSBurstable}
initPod, podErr := k8s.InitSleepPod(burstablePodConfig)
gomega.Ω(podErr).NotTo(gomega.HaveOccurred())
burstablePod, err := kClient.CreatePod(initPod, dev)
gomega.Ω(err).NotTo(gomega.HaveOccurred())

ginkgo.By("Wait for the pod to move to running state")
err = kClient.WaitForPodRunning(dev, burstablePodConfig.Name, 30*time.Second)
gomega.Ω(err).NotTo(gomega.HaveOccurred())

ginkgo.By("Verify that the pod is scheduled and running")
appsInfo, err = restClient.GetAppInfo("default", "root."+dev, burstablePod.ObjectMeta.Labels["applicationId"])
gomega.Ω(err).NotTo(gomega.HaveOccurred())
gomega.Ω(appsInfo).NotTo(gomega.BeNil())
gomega.Ω(appsInfo.State).To(gomega.Equal("Running"))

ginkgo.By("Verify that the pod's QOS class is not BestEffort")
gomega.Ω(burstablePod.Status.QOSClass).NotTo(gomega.Equal(v1.PodQOSBestEffort))

ginkgo.By("Verify that the pod's scheduler name is yunikorn")
gomega.Ω("yunikorn").To(gomega.Equal(burstablePod.Spec.SchedulerName))
})

ginkgo.AfterEach(func() {
tests.DumpClusterInfoIfSpecFailed(suiteName, []string{dev})
// call the healthCheck api to check scheduler health
Expand Down
18 changes: 12 additions & 6 deletions test/e2e/framework/helpers/k8s/pod_conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type SleepPodConfig struct {
RequiredNode string
Optedout AllowPreemptOpted
Labels map[string]string
QOSClass v1.PodQOSClass
}

type AllowPreemptOpted int
Expand Down Expand Up @@ -126,12 +127,17 @@ func InitSleepPod(conf SleepPodConfig) (*v1.Pod, error) {
Command: []string{"sleep", strconv.Itoa(conf.Time)},
Annotations: annotation,
Labels: labels,
Resources: &v1.ResourceRequirements{
Requests: v1.ResourceList{
"cpu": resource.MustParse(strconv.FormatInt(conf.CPU, 10) + "m"),
"memory": resource.MustParse(strconv.FormatInt(conf.Mem, 10) + "M"),
},
},
Resources: func() *v1.ResourceRequirements {
if conf.QOSClass != v1.PodQOSBestEffort {
return &v1.ResourceRequirements{
Requests: v1.ResourceList{
"cpu": resource.MustParse(strconv.FormatInt(conf.CPU, 10) + "m"),
"memory": resource.MustParse(strconv.FormatInt(conf.Mem, 10) + "M"),
},
}
}
return nil
}(),
Affinity: affinity,
OwnerReferences: owners,
}
Expand Down

0 comments on commit 8c9db7c

Please sign in to comment.