ryankert01 commented on code in PR #1008:
URL: https://github.com/apache/yunikorn-core/pull/1008#discussion_r1897084766
##########
pkg/scheduler/objects/application_test.go:
##########
@@ -3596,3 +3596,48 @@ func TestTryPlaceHolderAllocateDifferentNodes(t
*testing.T) {
// placeholder data remains unchanged until RM confirms the replacement
assertPlaceholderData(t, app, tg1, 1, 0, 0, res)
}
+
+func TestTryNodesNoReserve(t *testing.T) {
+ app := newApplication(appID0, "default", "root.default")
+
+ queue, err := createRootQueue(map[string]string{"first": "5"})
+ assert.NilError(t, err, "queue create failed")
+ app.queue = queue
+
+ res :=
resources.NewResourceFromMap(map[string]resources.Quantity{"first": 5})
+ ask := newAllocationAsk(aKey, appID0, res)
+ err = app.AddAllocationAsk(ask)
+ assert.NilError(t, err, "ask should have been added to app")
+
+ // reserve the allocation on node1
+ node1 := newNode(nodeID1, map[string]resources.Quantity{"first": 5})
+ err = app.Reserve(node1, ask)
+ assert.NilError(t, err, "reservation failed")
+
+ // case 1: node is the reserved node
+ iterator := getNodeIteratorFn(node1)
+ result := app.tryNodesNoReserve(ask, iterator(), node1.NodeID)
+ assert.Assert(t, result == nil, "result should be nil since node1 is
the reserved node")
+
+ // case 2: node is unschedulable
+ node2 := newNode(nodeID2, map[string]resources.Quantity{"first": 5})
+ node2.schedulable = false
+ iterator = getNodeIteratorFn(node2)
+ result = app.tryNodesNoReserve(ask, iterator(), node1.NodeID)
+ 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})
Review Comment:
maybe we should stay consistent by using variable as node name?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]