@@ -709,6 +709,201 @@ func TestStaleGangEviction(t *testing.T) {
709709 },
710710 },
711711 },
712+ {
713+ name : "Gang with a succeeded pod - no evict" ,
714+ topology : test_utils.TestTopologyBasic {
715+ Jobs : []* jobs_fake.TestJobBasic {
716+ {
717+ Name : "job-1" ,
718+ QueueName : "q-1" ,
719+ RootSubGroupSet : jobs_fake .DefaultSubGroup (3 ),
720+ Tasks : []* tasks_fake.TestTaskBasic {
721+ {
722+ Name : "job-1-0" ,
723+ State : pod_status .Succeeded ,
724+ },
725+ {
726+ Name : "job-1-1" ,
727+ State : pod_status .Running ,
728+ NodeName : "node-1" ,
729+ },
730+ {
731+ Name : "job-1-2" ,
732+ State : pod_status .Running ,
733+ NodeName : "node-1" ,
734+ },
735+ },
736+ StaleDuration : pointer .Duration (61 * time .Second ),
737+ },
738+ },
739+ Nodes : map [string ]nodes_fake.TestNodeBasic {
740+ "node-1" : {},
741+ },
742+ Queues : []test_utils.TestQueueBasic {
743+ {
744+ Name : "q-1" ,
745+ ParentQueue : "d-1" ,
746+ },
747+ },
748+ Departments : []test_utils.TestDepartmentBasic {
749+ {
750+ Name : "d-1" ,
751+ },
752+ },
753+ TaskExpectedResults : map [string ]test_utils.TestExpectedResultBasic {
754+ "job-1-0" : {
755+ Status : pod_status .Succeeded ,
756+ },
757+ "job-1-1" : {
758+ NodeName : "node-1" ,
759+ Status : pod_status .Running ,
760+ },
761+ "job-1-2" : {
762+ NodeName : "node-1" ,
763+ Status : pod_status .Running ,
764+ },
765+ },
766+ Mocks : & test_utils.TestMock {
767+ CacheRequirements : & test_utils.CacheMocking {
768+ NumberOfCacheBinds : 0 ,
769+ NumberOfCacheEvictions : 0 ,
770+ NumberOfPipelineActions : 0 ,
771+ },
772+ },
773+ },
774+ },
775+ {
776+ name : "Gang with only one pod left running - no evict" ,
777+ topology : test_utils.TestTopologyBasic {
778+ Jobs : []* jobs_fake.TestJobBasic {
779+ {
780+ Name : "job-1" ,
781+ QueueName : "q-1" ,
782+ RootSubGroupSet : jobs_fake .DefaultSubGroup (3 ),
783+ Tasks : []* tasks_fake.TestTaskBasic {
784+ {
785+ Name : "job-1-0" ,
786+ State : pod_status .Succeeded ,
787+ },
788+ {
789+ Name : "job-1-1" ,
790+ State : pod_status .Succeeded ,
791+ },
792+ {
793+ Name : "job-1-2" ,
794+ State : pod_status .Running ,
795+ NodeName : "node-1" ,
796+ },
797+ },
798+ StaleDuration : pointer .Duration (61 * time .Second ),
799+ },
800+ },
801+ Nodes : map [string ]nodes_fake.TestNodeBasic {
802+ "node-1" : {},
803+ },
804+ Queues : []test_utils.TestQueueBasic {
805+ {
806+ Name : "q-1" ,
807+ ParentQueue : "d-1" ,
808+ },
809+ },
810+ Departments : []test_utils.TestDepartmentBasic {
811+ {
812+ Name : "d-1" ,
813+ },
814+ },
815+ TaskExpectedResults : map [string ]test_utils.TestExpectedResultBasic {
816+ "job-1-0" : {
817+ Status : pod_status .Succeeded ,
818+ },
819+ "job-1-1" : {
820+ Status : pod_status .Succeeded ,
821+ },
822+ "job-1-2" : {
823+ NodeName : "node-1" ,
824+ Status : pod_status .Running ,
825+ },
826+ },
827+ Mocks : & test_utils.TestMock {
828+ CacheRequirements : & test_utils.CacheMocking {
829+ NumberOfCacheBinds : 0 ,
830+ NumberOfCacheEvictions : 0 ,
831+ NumberOfPipelineActions : 0 ,
832+ },
833+ },
834+ },
835+ },
836+ {
837+ name : "Gang with a succeeded pod in one sub group - no evict" ,
838+ topology : test_utils.TestTopologyBasic {
839+ Jobs : []* jobs_fake.TestJobBasic {
840+ {
841+ Name : "job-1" ,
842+ QueueName : "q-1" ,
843+ RootSubGroupSet : func () * subgroup_info.SubGroupSet {
844+ root := subgroup_info .NewSubGroupSet (subgroup_info .RootSubGroupSetName , nil )
845+ root .AddPodSet (subgroup_info .NewPodSet ("sub-group-0" , 2 , nil ))
846+ root .AddPodSet (subgroup_info .NewPodSet ("sub-group-1" , 1 , nil ))
847+ return root
848+ }(),
849+ Tasks : []* tasks_fake.TestTaskBasic {
850+ {
851+ Name : "job-1-0" ,
852+ SubGroupName : "sub-group-0" ,
853+ State : pod_status .Succeeded ,
854+ },
855+ {
856+ Name : "job-1-1" ,
857+ SubGroupName : "sub-group-0" ,
858+ State : pod_status .Running ,
859+ NodeName : "node-1" ,
860+ },
861+ {
862+ Name : "job-1-2" ,
863+ SubGroupName : "sub-group-1" ,
864+ State : pod_status .Running ,
865+ NodeName : "node-1" ,
866+ },
867+ },
868+ StaleDuration : pointer .Duration (61 * time .Second ),
869+ },
870+ },
871+ Nodes : map [string ]nodes_fake.TestNodeBasic {
872+ "node-1" : {},
873+ },
874+ Queues : []test_utils.TestQueueBasic {
875+ {
876+ Name : "q-1" ,
877+ ParentQueue : "d-1" ,
878+ },
879+ },
880+ Departments : []test_utils.TestDepartmentBasic {
881+ {
882+ Name : "d-1" ,
883+ },
884+ },
885+ TaskExpectedResults : map [string ]test_utils.TestExpectedResultBasic {
886+ "job-1-0" : {
887+ Status : pod_status .Succeeded ,
888+ },
889+ "job-1-1" : {
890+ NodeName : "node-1" ,
891+ Status : pod_status .Running ,
892+ },
893+ "job-1-2" : {
894+ NodeName : "node-1" ,
895+ Status : pod_status .Running ,
896+ },
897+ },
898+ Mocks : & test_utils.TestMock {
899+ CacheRequirements : & test_utils.CacheMocking {
900+ NumberOfCacheBinds : 0 ,
901+ NumberOfCacheEvictions : 0 ,
902+ NumberOfPipelineActions : 0 ,
903+ },
904+ },
905+ },
906+ },
712907 } {
713908 t .Run (test .name , func (t * testing.T ) {
714909 t .Logf ("Running test number: %v, test name: %v," , i , test .name )
0 commit comments