@@ -31,13 +31,13 @@ import (
3131func TestSchedule (t * testing.T ) {
3232 tests := []struct {
3333 name string
34- input []* backendmetrics.FakePodMetrics
34+ input []backendmetrics.PodMetrics
3535 req * types.LLMRequest
3636 wantRes * types.SchedulingResult
3737 err bool
3838 }{
3939 {
40- name : "no pods in datastore and req header is set" ,
40+ name : "no candidate pods and req header is set" ,
4141 req : & types.LLMRequest {
4242 Headers : map [string ]string {"test-epp-endpoint-selection" : "random-endpoint" },
4343 RequestId : uuid .NewString (),
@@ -47,8 +47,8 @@ func TestSchedule(t *testing.T) {
4747 },
4848 {
4949 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" }},
5252 },
5353 req : & types.LLMRequest {
5454 Headers : map [string ]string {}, // Deliberately set an empty header.
@@ -58,9 +58,9 @@ func TestSchedule(t *testing.T) {
5858 err : true ,
5959 },
6060 {
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" }},
6464 },
6565 req : & types.LLMRequest {
6666 Headers : map [string ]string {"test-epp-endpoint-selection" : "matched-endpoint" },
@@ -70,10 +70,10 @@ func TestSchedule(t *testing.T) {
7070 err : true ,
7171 },
7272 {
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" }},
7777 },
7878 req : & types.LLMRequest {
7979 Headers : map [string ]string {"test-epp-endpoint-selection" : "matched-endpoint" },
@@ -99,8 +99,8 @@ func TestSchedule(t *testing.T) {
9999
100100 for _ , test := range tests {
101101 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 ) )
104104 if test .err != (err != nil ) {
105105 t .Errorf ("Unexpected error, got %v, want %v" , err , test .err )
106106 }
@@ -111,15 +111,3 @@ func TestSchedule(t *testing.T) {
111111 })
112112 }
113113}
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