diff --git a/test/e2e/basic_scheduling/basic_scheduling_test.go b/test/e2e/basic_scheduling/basic_scheduling_test.go index a95e091ab..bcc7f5c6d 100644 --- a/test/e2e/basic_scheduling/basic_scheduling_test.go +++ b/test/e2e/basic_scheduling/basic_scheduling_test.go @@ -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 diff --git a/test/e2e/framework/helpers/k8s/pod_conf.go b/test/e2e/framework/helpers/k8s/pod_conf.go index 7ea68ccc0..6f54060df 100644 --- a/test/e2e/framework/helpers/k8s/pod_conf.go +++ b/test/e2e/framework/helpers/k8s/pod_conf.go @@ -41,6 +41,7 @@ type SleepPodConfig struct { RequiredNode string Optedout AllowPreemptOpted Labels map[string]string + QOSClass v1.PodQOSClass } type AllowPreemptOpted int @@ -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, }