@@ -323,7 +323,7 @@ func TestRemoveNodeWithPlaceholders(t *testing.T) {
323323 assert .Equal (t , 1 , partition .getPhAllocationCount (), "number of active placeholders" )
324324
325325 // fake an ask that is used
326- ask := newAllocationAskAll (allocKey , appID1 , taskGroup , appRes , 1 , false )
326+ ask := newAllocationAskAll (allocKey , appID1 , taskGroup , appRes , 1 , false , nil )
327327 err = app .AddAllocationAsk (ask )
328328 assert .NilError (t , err , "ask should be added to app" )
329329 _ , err = app .AllocateAsk (allocKey )
@@ -743,7 +743,7 @@ func TestRemoveNodeWithReplacement(t *testing.T) {
743743 assert .Equal (t , 2 , partition .GetTotalNodeCount (), "node list was not updated as expected" )
744744
745745 // fake an ask that is used
746- ask := newAllocationAskAll (allocKey , appID1 , taskGroup , appRes , 1 , false )
746+ ask := newAllocationAskAll (allocKey , appID1 , taskGroup , appRes , 1 , false , nil )
747747 err = app .AddAllocationAsk (ask )
748748 assert .NilError (t , err , "ask should be added to app" )
749749 _ , err = app .AllocateAsk (allocKey )
@@ -817,7 +817,7 @@ func TestRemoveNodeWithReal(t *testing.T) {
817817 assert .Equal (t , 2 , partition .GetTotalNodeCount (), "node list was not updated as expected" )
818818
819819 // fake an ask that is used
820- ask := newAllocationAskAll (allocKey , appID1 , taskGroup , appRes , 1 , false )
820+ ask := newAllocationAskAll (allocKey , appID1 , taskGroup , appRes , 1 , false , nil )
821821 err = app .AddAllocationAsk (ask )
822822 assert .NilError (t , err , "ask should be added to app" )
823823 _ , err = app .AllocateAsk (allocKey )
@@ -4800,3 +4800,75 @@ func TestForeignAllocation(t *testing.T) { //nolint:funlen
48004800 assert .Equal (t , 0 , len (partition .foreignAllocs ))
48014801 assert .Equal (t , 0 , len (node .GetYunikornAllocations ()))
48024802}
4803+
4804+ func TestAppSchedulingOrderFIFO (t * testing.T ) {
4805+ setupUGM ()
4806+ partition , err := newBasePartition ()
4807+ assert .NilError (t , err , "partition create failed" )
4808+ conf := configs.PartitionConfig {
4809+ Name : "test" ,
4810+ Queues : []configs.QueueConfig {
4811+ {
4812+ Name : "root" ,
4813+ Parent : true ,
4814+ SubmitACL : "*" ,
4815+ Queues : []configs.QueueConfig {
4816+ {
4817+ Name : "default" ,
4818+ Parent : false ,
4819+ Properties : map [string ]string {configs .ApplicationSortPolicy : policies .FifoSortPolicy .String ()},
4820+ },
4821+ },
4822+ },
4823+ },
4824+ PlacementRules : nil ,
4825+ Limits : nil ,
4826+ NodeSortPolicy : configs.NodeSortingPolicy {},
4827+ }
4828+ err = partition .updatePartitionDetails (conf )
4829+ assert .NilError (t , err , "unable to update partition config" )
4830+
4831+ nodeRes := resources .NewResourceFromMap (map [string ]resources.Quantity {"first" : 10 })
4832+ node := newNodeMaxResource (nodeID1 , nodeRes )
4833+ err = partition .AddNode (node )
4834+ assert .NilError (t , err )
4835+
4836+ app1 := newApplication (appID1 , "default" , defQueue )
4837+ err = partition .AddApplication (app1 )
4838+ assert .NilError (t , err , "could not add application" )
4839+ app2 := newApplication (appID2 , "default" , defQueue )
4840+ err = partition .AddApplication (app2 )
4841+ assert .NilError (t , err , "could not add application" )
4842+
4843+ // add two asks to app2 first
4844+ app2AskRes := resources .NewResourceFromMap (map [string ]resources.Quantity {"first" : 2 })
4845+
4846+ app2Ask1 := newAllocationAskAll (allocKey2 , appID2 , "" , app2AskRes , 0 , false , map [string ]string {
4847+ siCommon .CreationTime : "100" ,
4848+ })
4849+ err = app2 .AddAllocationAsk (app2Ask1 )
4850+ assert .NilError (t , err , "could not add ask" )
4851+ app2Ask2 := newAllocationAskAll (allocKey3 , appID2 , "" , app2AskRes , 0 , false , map [string ]string {
4852+ siCommon .CreationTime : "50" ,
4853+ })
4854+ err = app2 .AddAllocationAsk (app2Ask2 )
4855+ assert .NilError (t , err , "could not add ask" )
4856+
4857+ askRes1 := resources .NewResourceFromMap (map [string ]resources.Quantity {"first" : 1 })
4858+ ask1 := newAllocationAskAll (allocKey , appID1 , "" , askRes1 , 0 , false , map [string ]string {
4859+ siCommon .CreationTime : "1000" ,
4860+ })
4861+ err = app1 .AddAllocationAsk (ask1 )
4862+ assert .NilError (t , err , "could not add ask" )
4863+
4864+ // the two asks from app2 should be scheduled
4865+ alloc := partition .tryAllocate ()
4866+ assert .Assert (t , alloc != nil , "no allocation was made" )
4867+ assert .Equal (t , allocKey3 , alloc .Request .GetAllocationKey ())
4868+ alloc = partition .tryAllocate ()
4869+ assert .Assert (t , alloc != nil , "no allocation was made" )
4870+ assert .Equal (t , allocKey2 , alloc .Request .GetAllocationKey ())
4871+ alloc = partition .tryAllocate ()
4872+ assert .Assert (t , alloc != nil , "no allocation was made" )
4873+ assert .Equal (t , allocKey , alloc .Request .GetAllocationKey ())
4874+ }
0 commit comments