@@ -31,13 +31,13 @@ import (
31
31
func TestSchedule (t * testing.T ) {
32
32
tests := []struct {
33
33
name string
34
- input []* backendmetrics.FakePodMetrics
34
+ input []backendmetrics.PodMetrics
35
35
req * types.LLMRequest
36
36
wantRes * types.SchedulingResult
37
37
err bool
38
38
}{
39
39
{
40
- name : "no pods in datastore and req header is set" ,
40
+ name : "no candidate pods and req header is set" ,
41
41
req : & types.LLMRequest {
42
42
Headers : map [string ]string {"test-epp-endpoint-selection" : "random-endpoint" },
43
43
RequestId : uuid .NewString (),
@@ -47,8 +47,8 @@ func TestSchedule(t *testing.T) {
47
47
},
48
48
{
49
49
name : "req header not set" ,
50
- input : []* backendmetrics.FakePodMetrics {
51
- {Pod : & backend.Pod {Address : "random-endpoint" }},
50
+ input : []backendmetrics.PodMetrics {
51
+ & backendmetrics. FakePodMetrics {Pod : & backend.Pod {Address : "random-endpoint" }},
52
52
},
53
53
req : & types.LLMRequest {
54
54
Headers : map [string ]string {}, // Deliberately set an empty header.
@@ -58,9 +58,9 @@ func TestSchedule(t *testing.T) {
58
58
err : true ,
59
59
},
60
60
{
61
- name : "no pods address in datastore matches req header address" ,
62
- input : []* backendmetrics.FakePodMetrics {
63
- {Pod : & backend.Pod {Address : "nonmatched-endpoint" }},
61
+ name : "no pods address from the candidate pods matches req header address" ,
62
+ input : []backendmetrics.PodMetrics {
63
+ & backendmetrics. FakePodMetrics {Pod : & backend.Pod {Address : "nonmatched-endpoint" }},
64
64
},
65
65
req : & types.LLMRequest {
66
66
Headers : map [string ]string {"test-epp-endpoint-selection" : "matched-endpoint" },
@@ -70,10 +70,10 @@ func TestSchedule(t *testing.T) {
70
70
err : true ,
71
71
},
72
72
{
73
- name : "one pod address in datastore matches req header address" ,
74
- input : []* backendmetrics.FakePodMetrics {
75
- {Pod : & backend.Pod {Address : "nonmatched-endpoint" }},
76
- {Pod : & backend.Pod {Address : "matched-endpoint" }},
73
+ name : "one pod address from the candidate pods matches req header address" ,
74
+ input : []backendmetrics.PodMetrics {
75
+ & backendmetrics. FakePodMetrics {Pod : & backend.Pod {Address : "nonmatched-endpoint" }},
76
+ & backendmetrics. FakePodMetrics {Pod : & backend.Pod {Address : "matched-endpoint" }},
77
77
},
78
78
req : & types.LLMRequest {
79
79
Headers : map [string ]string {"test-epp-endpoint-selection" : "matched-endpoint" },
@@ -99,8 +99,8 @@ func TestSchedule(t *testing.T) {
99
99
100
100
for _ , test := range tests {
101
101
t .Run (test .name , func (t * testing.T ) {
102
- scheduler := NewReqHeaderBasedScheduler (& fakeDataStore { pods : test . input } )
103
- got , err := scheduler .Schedule (context .Background (), test .req )
102
+ scheduler := NewReqHeaderBasedScheduler ()
103
+ got , err := scheduler .Schedule (context .Background (), test .req , types . ToSchedulerPodMetrics ( test . input ) )
104
104
if test .err != (err != nil ) {
105
105
t .Errorf ("Unexpected error, got %v, want %v" , err , test .err )
106
106
}
@@ -111,15 +111,3 @@ func TestSchedule(t *testing.T) {
111
111
})
112
112
}
113
113
}
114
-
115
- type fakeDataStore struct {
116
- pods []* backendmetrics.FakePodMetrics
117
- }
118
-
119
- func (fds * fakeDataStore ) PodGetAll () []backendmetrics.PodMetrics {
120
- pm := make ([]backendmetrics.PodMetrics , 0 , len (fds .pods ))
121
- for _ , pod := range fds .pods {
122
- pm = append (pm , pod )
123
- }
124
- return pm
125
- }
0 commit comments