Skip to content

Commit

Permalink
[YUNIKORN-1867] add priority offset test
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Yang <yangpoan@gmail.com>
  • Loading branch information
FrankYang0529 committed Jul 17, 2023
1 parent 5e65cc7 commit dcd789a
Showing 1 changed file with 109 additions and 0 deletions.
109 changes: 109 additions & 0 deletions test/e2e/priority_scheduling/priority_scheduling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,115 @@ var _ = ginkgo.Describe("Dynamic_Queue_Priority", func() {
})
})

var _ = ginkgo.Describe("Priority_Offset_Queue", func() {
var ns string
var err error
var oldConfigMap = new(v1.ConfigMap)
var annotation string
var sleepPodConf, lowPodConf, normalPodConf, highPodConf k8s.TestPodConfig

ginkgo.BeforeEach(func() {
var namespace *v1.Namespace

ns = "test-" + common.RandSeq(10)

By("Setting custom YuniKorn configuration")
annotation = "ann-" + common.RandSeq(10)
yunikorn.UpdateCustomConfigMapWrapper(oldConfigMap, "fifo", annotation, func(sc *configs.SchedulerConfig) error {
// remove placement rules so we can control queue
sc.Partitions[0].PlacementRules = nil

if err = common.AddQueue(sc, "default", "root", configs.QueueConfig{
Name: "fence",
Parent: true,
Resources: configs.Resources{Max: map[string]string{siCommon.CPU: "100m", siCommon.Memory: "100M"}},
Properties: map[string]string{configs.PriorityPolicy: "fence"},
}); err != nil {
return err
}
if err = common.AddQueue(sc, "default", "root.fence", configs.QueueConfig{
Name: "highpriority",
Properties: map[string]string{configs.PriorityOffset: "100"},
}); err != nil {
return err
}
if err = common.AddQueue(sc, "default", "root.fence", configs.QueueConfig{
Name: "normalpriority",
Properties: map[string]string{configs.PriorityOffset: "0"},
}); err != nil {
return err
}
if err = common.AddQueue(sc, "default", "root.fence", configs.QueueConfig{
Name: "lowpriority",
Properties: map[string]string{configs.PriorityOffset: "-100"},
}); err != nil {
return err
}

return nil
})

By(fmt.Sprintf("Creating test namespace %s", ns))
namespace, err = kubeClient.CreateNamespace(ns, map[string]string{})
Ω(err).ShouldNot(HaveOccurred())
Ω(namespace.Status.Phase).Should(Equal(v1.NamespaceActive))

sleepPodConf = k8s.TestPodConfig{
Name: "test-sleep-" + common.RandSeq(5),
Labels: map[string]string{
constants.LabelQueueName: "root.fence.highpriority",
constants.LabelApplicationID: "app-sleep-" + common.RandSeq(5)},
Namespace: ns,
Resources: rr,
}

lowPodConf = k8s.TestPodConfig{
Name: "test-low-priority-" + common.RandSeq(5),
Labels: map[string]string{
constants.LabelQueueName: "root.fence.lowpriority",
constants.LabelApplicationID: "app-low-" + common.RandSeq(5)},
Namespace: ns,
Resources: rr,
}

normalPodConf = k8s.TestPodConfig{
Name: "test-normal-priority-" + common.RandSeq(5),
Labels: map[string]string{
constants.LabelQueueName: "root.fence.normalpriority",
constants.LabelApplicationID: "app-normal-" + common.RandSeq(5)},
Resources: rr,
Namespace: ns,
}

highPodConf = k8s.TestPodConfig{
Name: "test-high-priority-" + common.RandSeq(5),
Labels: map[string]string{
constants.LabelQueueName: "root.fence.highpriority",
constants.LabelApplicationID: "app-high-" + common.RandSeq(5)},
Namespace: ns,
Resources: rr,
}
})

ginkgo.It("Verify_Priority_Offset_Queue_App_Scheduling_Order", func() {
validatePodSchedulingOrder(ns, sleepPodConf, lowPodConf, normalPodConf, highPodConf)
})

ginkgo.AfterEach(func() {
testDescription := ginkgo.CurrentSpecReport()
if testDescription.Failed() {
tests.LogTestClusterInfoWrapper(testDescription.FailureMessage(), []string{ns})
tests.LogYunikornContainer(testDescription.FailureMessage())
}
By(fmt.Sprintf("Tearing down namespace %s", ns))
err = kubeClient.TearDownNamespace(ns)
Ω(err).ShouldNot(HaveOccurred())

By("Restoring YuniKorn configuration")
yunikorn.RestoreConfigMapWrapper(oldConfigMap, annotation)
})
})

func validatePodSchedulingOrder(ns string, sleepPodConf, lowPodConf, normalPodConf, highPodConf k8s.TestPodConfig) {
var err error
var sleepPod *v1.Pod
Expand Down

0 comments on commit dcd789a

Please sign in to comment.