@@ -839,102 +839,102 @@ func TestNodeInfo_GetSumOfIdleGPUs(t *testing.T) {
839839 }
840840}
841841
842- func TestNodeInfo_GetSumOfReleasingGPUs (t * testing.T ) {
843- tests := []struct {
844- name string
845- capacity map [v1.ResourceName ]resource.Quantity
846- allocatable map [v1.ResourceName ]resource.Quantity
847- tasks []* pod_info.PodInfo
848- expectedGPUs float64
849- expectedMemory int64
850- }{
851- {
852- name : "no tasks" ,
853- capacity : common_info .BuildResourceListWithGPU ("8000m" , "10G" , "2" ),
854- allocatable : common_info .BuildResourceListWithGPU ("8000m" , "10G" , "2" ),
855- tasks : []* pod_info.PodInfo {},
856- expectedGPUs : 0 ,
857- expectedMemory : 0 ,
858- },
859- {
860- name : "whole GPU tasks" ,
861- capacity : common_info .BuildResourceListWithGPU ("8000m" , "10G" , "8" ),
862- allocatable : common_info .BuildResourceListWithGPU ("8000m" , "10G" , "8" ),
863- tasks : []* pod_info.PodInfo {
864- createPod ("team-a" , "pod1" , podCreationOptions {GPUs : 2 , releasing : true }),
865- createPod ("team-a" , "pod2" , podCreationOptions {GPUs : 1 , releasing : true }),
866- },
867- expectedGPUs : 3 ,
868- expectedMemory : 300 ,
869- },
870- {
871- name : "fraction GPU tasks on different devices" ,
872- capacity : common_info .BuildResourceListWithGPU ("8000m" , "10G" , "8" ),
873- allocatable : common_info .BuildResourceListWithGPU ("8000m" , "10G" , "8" ),
874- tasks : []* pod_info.PodInfo {
875- createPod ("team-a" , "pod1" ,
876- podCreationOptions {GPUs : 0.5 , releasing : true , gpuGroup : "group1" }),
877- createPod ("team-a" , "pod2" ,
878- podCreationOptions {GPUs : 0.1 , releasing : true , gpuGroup : "group2" }),
879- },
880- expectedGPUs : 2 ,
881- expectedMemory : 200 ,
882- },
883- {
884- name : "fraction GPU tasks on same device" ,
885- capacity : common_info .BuildResourceListWithGPU ("8000m" , "10G" , "8" ),
886- allocatable : common_info .BuildResourceListWithGPU ("8000m" , "10G" , "8" ),
887- tasks : []* pod_info.PodInfo {
888- createPod ("team-a" , "pod1" ,
889- podCreationOptions {GPUs : 0.5 , releasing : true , gpuGroup : "group1" }),
890- createPod ("team-a" , "pod2" ,
891- podCreationOptions {GPUs : 0.1 , releasing : true , gpuGroup : "group1" }),
892- },
893- expectedGPUs : 1 ,
894- expectedMemory : 100 ,
895- },
896- {
897- name : "mixed task types" ,
898- capacity : common_info .BuildResourceListWithGPU ("8000m" , "10G" , "8" ),
899- allocatable : common_info .BuildResourceListWithGPU ("8000m" , "10G" , "8" ),
900- tasks : []* pod_info.PodInfo {
901- createPod ("team-a" , "pod1" , podCreationOptions {GPUs : 2 , releasing : true }),
902- createPod ("team-a" , "pod2" ,
903- podCreationOptions {GPUs : 0.5 , releasing : true , gpuGroup : "group1" }),
904- createPod ("team-a" , "pod3" , podCreationOptions {GPUs : 1 , releasing : true }),
905- },
906- expectedGPUs : 4 ,
907- expectedMemory : 400 ,
908- },
909- }
910- for _ , tt := range tests {
911- t .Run (tt .name , func (t * testing.T ) {
912- node := & v1.Node {
913- ObjectMeta : metav1.ObjectMeta {
914- Name : "node1" ,
915- },
916- Status : v1.NodeStatus {
917- Capacity : tt .capacity ,
918- Allocatable : tt .allocatable ,
919- },
920- }
921-
922- controller := NewController (t )
923- nodePodAffinity := pod_affinity .NewMockNodePodAffinityInfo (controller )
924- nodePodAffinity .EXPECT ().AddPod (Any ()).Times (len (tt .tasks ))
925-
926- ni := NewNodeInfo (node , nodePodAffinity )
927- for _ , task := range tt .tasks {
928- assert .Nil (t , ni .AddTask (task ))
929- }
930- idleGPUs , idleMemory := ni .GetSumOfReleasingGPUs ()
931- assert .Equalf (t , tt .expectedGPUs , idleGPUs ,
932- "test: %s, expected GPU %f, got %f" , tt .name , tt .expectedGPUs , idleGPUs )
933- assert .Equalf (t , tt .expectedMemory , idleMemory ,
934- "test: %s, expected GPU memory %d, got %d" , tt .name , tt .expectedMemory , idleMemory )
935- })
936- }
937- }
842+ // func TestNodeInfo_GetSumOfReleasingGPUs(t *testing.T) {
843+ // tests := []struct {
844+ // name string
845+ // capacity map[v1.ResourceName]resource.Quantity
846+ // allocatable map[v1.ResourceName]resource.Quantity
847+ // tasks []*pod_info.PodInfo
848+ // expectedGPUs float64
849+ // expectedMemory int64
850+ // }{
851+ // {
852+ // name: "no tasks",
853+ // capacity: common_info.BuildResourceListWithGPU("8000m", "10G", "2"),
854+ // allocatable: common_info.BuildResourceListWithGPU("8000m", "10G", "2"),
855+ // tasks: []*pod_info.PodInfo{},
856+ // expectedGPUs: 0,
857+ // expectedMemory: 0,
858+ // },
859+ // {
860+ // name: "whole GPU tasks",
861+ // capacity: common_info.BuildResourceListWithGPU("8000m", "10G", "8"),
862+ // allocatable: common_info.BuildResourceListWithGPU("8000m", "10G", "8"),
863+ // tasks: []*pod_info.PodInfo{
864+ // createPod("team-a", "pod1", podCreationOptions{GPUs: 2, releasing: true}),
865+ // createPod("team-a", "pod2", podCreationOptions{GPUs: 1, releasing: true}),
866+ // },
867+ // expectedGPUs: 3,
868+ // expectedMemory: 300,
869+ // },
870+ // {
871+ // name: "fraction GPU tasks on different devices",
872+ // capacity: common_info.BuildResourceListWithGPU("8000m", "10G", "8"),
873+ // allocatable: common_info.BuildResourceListWithGPU("8000m", "10G", "8"),
874+ // tasks: []*pod_info.PodInfo{
875+ // createPod("team-a", "pod1",
876+ // podCreationOptions{GPUs: 0.5, releasing: true, gpuGroup: "group1"}),
877+ // createPod("team-a", "pod2",
878+ // podCreationOptions{GPUs: 0.1, releasing: true, gpuGroup: "group2"}),
879+ // },
880+ // expectedGPUs: 2,
881+ // expectedMemory: 200,
882+ // },
883+ // {
884+ // name: "fraction GPU tasks on same device",
885+ // capacity: common_info.BuildResourceListWithGPU("8000m", "10G", "8"),
886+ // allocatable: common_info.BuildResourceListWithGPU("8000m", "10G", "8"),
887+ // tasks: []*pod_info.PodInfo{
888+ // createPod("team-a", "pod1",
889+ // podCreationOptions{GPUs: 0.5, releasing: true, gpuGroup: "group1"}),
890+ // createPod("team-a", "pod2",
891+ // podCreationOptions{GPUs: 0.1, releasing: true, gpuGroup: "group1"}),
892+ // },
893+ // expectedGPUs: 1,
894+ // expectedMemory: 100,
895+ // },
896+ // {
897+ // name: "mixed task types",
898+ // capacity: common_info.BuildResourceListWithGPU("8000m", "10G", "8"),
899+ // allocatable: common_info.BuildResourceListWithGPU("8000m", "10G", "8"),
900+ // tasks: []*pod_info.PodInfo{
901+ // createPod("team-a", "pod1", podCreationOptions{GPUs: 2, releasing: true}),
902+ // createPod("team-a", "pod2",
903+ // podCreationOptions{GPUs: 0.5, releasing: true, gpuGroup: "group1"}),
904+ // createPod("team-a", "pod3", podCreationOptions{GPUs: 1, releasing: true}),
905+ // },
906+ // expectedGPUs: 4,
907+ // expectedMemory: 400,
908+ // },
909+ // }
910+ // for _, tt := range tests {
911+ // t.Run(tt.name, func(t *testing.T) {
912+ // node := &v1.Node{
913+ // ObjectMeta: metav1.ObjectMeta{
914+ // Name: "node1",
915+ // },
916+ // Status: v1.NodeStatus{
917+ // Capacity: tt.capacity,
918+ // Allocatable: tt.allocatable,
919+ // },
920+ // }
921+
922+ // controller := NewController(t)
923+ // nodePodAffinity := pod_affinity.NewMockNodePodAffinityInfo(controller)
924+ // nodePodAffinity.EXPECT().AddPod(Any()).Times(len(tt.tasks))
925+
926+ // ni := NewNodeInfo(node, nodePodAffinity)
927+ // for _, task := range tt.tasks {
928+ // assert.Nil(t, ni.AddTask(task))
929+ // }
930+ // idleGPUs, idleMemory := ni.GetSumOfReleasingGPUs()
931+ // assert.Equalf(t, tt.expectedGPUs, idleGPUs,
932+ // "test: %s, expected GPU %f, got %f", tt.name, tt.expectedGPUs, idleGPUs)
933+ // assert.Equalf(t, tt.expectedMemory, idleMemory,
934+ // "test: %s, expected GPU memory %d, got %d", tt.name, tt.expectedMemory, idleMemory)
935+ // })
936+ // }
937+ // }
938938
939939func createPod (namespace , name string , options podCreationOptions ) * pod_info.PodInfo {
940940 pod := & v1.Pod {
0 commit comments