Skip to content

Commit

Permalink
fix incorrect logic, add test for the specific field
Browse files Browse the repository at this point in the history
  • Loading branch information
wilfred-s committed Nov 22, 2024
1 parent 13c751a commit 1542dcb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/scheduler/objects/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions pkg/scheduler/objects/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1542dcb

Please sign in to comment.