From 1542dcb1b94c9f7fa2d48127411f45a1b97a566b Mon Sep 17 00:00:00 2001 From: Wilfred Spiegelenburg Date: Fri, 22 Nov 2024 13:19:28 +1100 Subject: [PATCH] fix incorrect logic, add test for the specific field --- pkg/scheduler/objects/queue.go | 2 +- pkg/scheduler/objects/queue_test.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/scheduler/objects/queue.go b/pkg/scheduler/objects/queue.go index b379d5d6b..4ddec1c12 100644 --- a/pkg/scheduler/objects/queue.go +++ b/pkg/scheduler/objects/queue.go @@ -696,7 +696,7 @@ func (sq *Queue) GetPartitionQueueDAOInfo(include bool) dao.PartitionQueueDAOInf queueInfo.AbsUsedCapacity = resources.CalculateAbsUsedCapacity(sq.maxResource, sq.allocatedResource).DAOMap() queueInfo.SortingPolicy = sq.sortType.String() queueInfo.PrioritySorting = sq.prioritySortEnabled - queueInfo.PreemptionEnabled = sq.preemptionPolicy == policies.DisabledPreemptionPolicy + queueInfo.PreemptionEnabled = sq.preemptionPolicy != policies.DisabledPreemptionPolicy queueInfo.IsPreemptionFence = sq.preemptionPolicy == policies.FencePreemptionPolicy queueInfo.PreemptionDelay = sq.preemptionDelay.String() queueInfo.IsPriorityFence = sq.priorityPolicy == policies.FencePriorityPolicy diff --git a/pkg/scheduler/objects/queue_test.go b/pkg/scheduler/objects/queue_test.go index 04ad01886..3ad286b9f 100644 --- a/pkg/scheduler/objects/queue_test.go +++ b/pkg/scheduler/objects/queue_test.go @@ -1705,9 +1705,23 @@ func TestGetPartitionQueueDAOInfo(t *testing.T) { assert.Equal(t, leafDAO.QueueName, "root.leaf-queue") assert.Equal(t, len(leafDAO.Children), 0, "leaf has no children") assert.Equal(t, len(leafDAO.ChildNames), 0, "leaf has no children (names)") + assert.Equal(t, leafDAO.PreemptionEnabled, true, "preemption should be enabled") assert.Equal(t, leafDAO.IsPreemptionFence, true, "fence should have been set") assert.Equal(t, leafDAO.PreemptionDelay, "1h0m0s", "incorrect delay returned") assert.Equal(t, leafDAO.SortingPolicy, "fair", "incorrect policy returned") + + // special prop checks + leaf.properties = map[string]string{ + configs.ApplicationSortPolicy: policies.FifoSortPolicy.String(), + configs.PreemptionDelay: "10s", + configs.PreemptionPolicy: policies.DisabledPreemptionPolicy.String(), + } + leaf.UpdateQueueProperties() + leafDAO = leaf.GetPartitionQueueDAOInfo(false) + assert.Equal(t, leafDAO.PreemptionEnabled, false, "preemption should not be enabled") + assert.Equal(t, leafDAO.IsPreemptionFence, false, "queue should not be a fence") + assert.Equal(t, leafDAO.PreemptionDelay, "10s", "incorrect delay returned") + assert.Equal(t, leafDAO.SortingPolicy, "fifo", "incorrect policy returned") } func getAllocatingAcceptedApps() map[string]bool {