Skip to content

Commit 0cbffd9

Browse files
committed
refactor: add test case for OnSessionOpen in ReflectJobOrder plugin
Signed-off-by: Saurabh Kumar Singh <[email protected]>
1 parent 4e847fa commit 0cbffd9

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

pkg/scheduler/plugins/factory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/plugins/gpupack"
2727
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/plugins/gpusharingorder"
2828
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/plugins/gpuspread"
29-
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/plugins/reflectjoborder"
3029
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/plugins/kubeflow"
3130
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/plugins/minruntime"
3231
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/plugins/nodeavailability"
@@ -37,6 +36,7 @@ import (
3736
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/plugins/priority"
3837
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/plugins/proportion"
3938
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/plugins/ray"
39+
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/plugins/reflectjoborder"
4040
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/plugins/resourcetype"
4141
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/plugins/snapshot"
4242
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/plugins/subgrouporder"

pkg/scheduler/plugins/reflectjoborder/reflect_job_order_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,29 @@ import (
1111
"testing"
1212

1313
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/api/common_info"
14+
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/api/podgroup_info"
15+
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/conf"
16+
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/framework"
1417
)
1518

19+
func TestJobOrderPlugin_OnSessionOpen(t *testing.T) {
20+
ssn := &framework.Session{
21+
PodGroupInfos: map[common_info.PodGroupID]*podgroup_info.PodGroupInfo{
22+
"pg1": {UID: "pg1", Priority: 5, Queue: "q1"},
23+
"pg2": {UID: "pg2", Priority: 2, Queue: "q2"},
24+
},
25+
Config: &conf.SchedulerConfiguration{
26+
QueueDepthPerAction: map[string]int{"Allocate": 10},
27+
},
28+
}
29+
plugin := &JobOrderPlugin{}
30+
plugin.OnSessionOpen(ssn)
31+
32+
if plugin.ReflectJobOrder == nil {
33+
t.Fatalf("ReflectJobOrder should be initialized")
34+
}
35+
}
36+
1637
// Test serveJobs returns correct JSON and status when ReflectJobOrder is set
1738
func TestServeJobs_ReflectJobOrderReady(t *testing.T) {
1839
plugin := &JobOrderPlugin{

0 commit comments

Comments
 (0)