Skip to content

Commit

Permalink
[YUNIKORN-2998] add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael committed Dec 25, 2024
1 parent 1c7cc57 commit 859a760
Show file tree
Hide file tree
Showing 4 changed files with 1,772 additions and 4 deletions.
1 change: 1 addition & 0 deletions coverage.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mode: set
17 changes: 13 additions & 4 deletions pkg/scheduler/objects/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3627,17 +3627,26 @@ func TestTryNodesNoReserve(t *testing.T) {
assert.Assert(t, result == nil, "result should be nil since node2 is unschedulable")

// case 3: node does not have enough resources
node3 := newNode("node-3", map[string]resources.Quantity{"first": 1})
node3 := newNode(nodeID3, map[string]resources.Quantity{"first": 1})
iterator = getNodeIteratorFn(node3)
result = app.tryNodesNoReserve(ask, iterator(), node1.NodeID)
assert.Assert(t, result == nil, "result should be nil since node3 does not have enough resources")

// case 4: success
node4 := newNode("node-4", map[string]resources.Quantity{"first": 5})
// case 4: node fails predicate
mockPlugin := mockCommon.NewPredicatePlugin(false, map[string]int{nodeID4: 1})
plugins.RegisterSchedulerPlugin(mockPlugin)
defer plugins.UnregisterSchedulerPlugins()
node4 := newNode(nodeID4, map[string]resources.Quantity{"first": 5})
iterator = getNodeIteratorFn(node4)
result = app.tryNodesNoReserve(ask, iterator(), node1.NodeID)
assert.Assert(t, result == nil, "result should be nil since node4 fails predicate")

// case 5: success
node5 := newNode(nodeID5, map[string]resources.Quantity{"first": 5})
iterator = getNodeIteratorFn(node5)
result = app.tryNodesNoReserve(ask, iterator(), node1.NodeID)
assert.Assert(t, result != nil, "result should not be nil")
assert.Equal(t, node4.NodeID, result.NodeID, "result should be on node4")
assert.Equal(t, node5.NodeID, result.NodeID, "result should be on node5")
assert.Equal(t, result.ResultType, AllocatedReserved, "result type should be AllocatedReserved")
assert.Equal(t, result.ReservedNodeID, node1.NodeID, "reserved node should be node1")
}
Loading

0 comments on commit 859a760

Please sign in to comment.