This is an automated email from the ASF dual-hosted git repository. pbacsko pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/yunikorn-core.git
The following commit(s) were added to refs/heads/master by this push: new bc568161 [YUNIKORN-2635] test coverage improvement: same priority case in sorter (#871) bc568161 is described below commit bc568161d0afe8110d7dd339936363883cee144c Author: 0yukali0 <a08h0...@gmail.com> AuthorDate: Sun May 26 17:29:17 2024 +0200 [YUNIKORN-2635] test coverage improvement: same priority case in sorter (#871) Closes: #871 Signed-off-by: Peter Bacsko <pbac...@cloudera.com> --- pkg/scheduler/objects/sorters_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/pkg/scheduler/objects/sorters_test.go b/pkg/scheduler/objects/sorters_test.go index aaa3951a..6ebae850 100644 --- a/pkg/scheduler/objects/sorters_test.go +++ b/pkg/scheduler/objects/sorters_test.go @@ -107,6 +107,15 @@ func TestSortQueues(t *testing.T) { queues = []*Queue{q0, q1, q2, q3} sortQueue(queues, policies.FairSortPolicy, true) assert.Equal(t, queueNames(queues), queueNames([]*Queue{q3, q0, q1, q2}), "fair third - priority") + + // fairness ratios: q0:400/800=0.5, q1:200/400= 0.5, q2:100/200=0.5, q3:100/200=0.5 + q0.guaranteedResource = resources.NewResourceFromMap(map[string]resources.Quantity{"memory": 800, "vcore": 400}) + q0.allocatedResource = resources.NewResourceFromMap(map[string]resources.Quantity{"memory": 400, "vcore": 200}) + q1.guaranteedResource = resources.NewResourceFromMap(map[string]resources.Quantity{"memory": 400, "vcore": 300}) + q1.allocatedResource = resources.NewResourceFromMap(map[string]resources.Quantity{"memory": 200, "vcore": 150}) + queues = []*Queue{q0, q1, q2, q3} + sortQueue(queues, policies.FairSortPolicy, false) + assert.Equal(t, queueNames(queues), queueNames([]*Queue{q3, q0, q1, q2}), "fair - pending resource") } // queue guaranteed resource is not set (same as a zero resource) @@ -209,6 +218,18 @@ func TestSortAppsFifo(t *testing.T) { // fifo - apps should come back in order created 0, 1, 2, 3 list = sortApplications(input, policies.FifoSortPolicy, false, nil) assertAppList(t, list, []int{0, 1, 2, 3}, "fifo simple") + + input["app-1"].askMaxPriority = 3 + input["app-3"].askMaxPriority = 5 + input["app-2"].SubmissionTime = input["app-3"].SubmissionTime + input["app-1"].SubmissionTime = input["app-3"].SubmissionTime + list = sortApplications(input, policies.FifoSortPolicy, false, nil) + /* + * apps order: 0, 3, 1, 2 + * the result of app index is [0, 2, 3, 1] + * app0 with index 0, app1 with index 2, app2 with index 3 and app3 with index 1 + */ + assertAppList(t, list, []int{0, 2, 3, 1}, "fifo first, priority second") } func TestSortAppsPriorityFifo(t *testing.T) { @@ -276,6 +297,19 @@ func TestSortAppsFair(t *testing.T) { // apps should come back in order: 3, 0, 2, 1 list = sortApplications(input, policies.FairSortPolicy, false, resources.Multiply(res, 5)) assertAppList(t, list, []int{1, 3, 2, 0}, "app-1 & app-3 allocated") + + // update allocated resource for app-3 & app-1 where priority of app-3 is higher + input["app-1"].allocatedResource = resources.Multiply(res, 10) + input["app-1"].askMaxPriority = 2 + input["app-3"].allocatedResource = resources.Multiply(res, 10) + input["app-3"].askMaxPriority = 3 + list = sortApplications(input, policies.FairSortPolicy, false, resources.Multiply(res, 5)) + /* + * expected apps order: 0, 2, 3, 1 means + * So result of apps indexs is [0, 3, 1, 2] + * app0 in 0, app1 in 3, app2 in 1, app3 in 2: + */ + assertAppList(t, list, []int{0, 3, 1, 2}, "app-1 & app-3 allocated, app-3 high priority") } func TestSortAppsPriorityFair(t *testing.T) { --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@yunikorn.apache.org For additional commands, e-mail: issues-h...@yunikorn.apache.org