@@ -19,6 +19,7 @@ package requestcontrol
19
19
import (
20
20
"context"
21
21
"errors"
22
+ "fmt"
22
23
"testing"
23
24
"time"
24
25
@@ -109,26 +110,29 @@ func TestDirector_HandleRequest(t *testing.T) {
109
110
},
110
111
}
111
112
112
- // Pod setup
113
- testPod := & corev1.Pod {
114
- ObjectMeta : metav1.ObjectMeta {
115
- Name : "pod1" ,
116
- Namespace : "default" ,
117
- Labels : map [string ]string {"app" : "inference" },
118
- },
119
- Status : corev1.PodStatus {
120
- PodIP : "192.168.1.100" ,
121
- Phase : corev1 .PodRunning ,
122
- Conditions : []corev1.PodCondition {{Type : corev1 .PodReady , Status : corev1 .ConditionTrue }},
123
- },
124
- }
125
113
scheme := runtime .NewScheme ()
126
114
_ = clientgoscheme .AddToScheme (scheme )
127
115
fakeClient := fake .NewClientBuilder ().WithScheme (scheme ).Build ()
128
116
if err := ds .PoolSet (ctx , fakeClient , pool ); err != nil {
129
117
t .Fatalf ("Error while setting inference pool: %v" , err )
130
118
}
131
- ds .PodUpdateOrAddIfNotExist (testPod )
119
+
120
+ for i := range 5 {
121
+ // Pod setup
122
+ testPod := & corev1.Pod {
123
+ ObjectMeta : metav1.ObjectMeta {
124
+ Name : fmt .Sprintf ("pod%v" , i + 1 ),
125
+ Namespace : "default" ,
126
+ Labels : map [string ]string {"app" : "inference" },
127
+ },
128
+ Status : corev1.PodStatus {
129
+ PodIP : fmt .Sprintf ("192.168.%v.100" , i + 1 ),
130
+ Phase : corev1 .PodRunning ,
131
+ Conditions : []corev1.PodCondition {{Type : corev1 .PodReady , Status : corev1 .ConditionTrue }},
132
+ },
133
+ }
134
+ ds .PodUpdateOrAddIfNotExist (testPod )
135
+ }
132
136
133
137
defaultSuccessfulScheduleResults := & schedulingtypes.SchedulingResult {
134
138
ProfileResults : map [string ]* schedulingtypes.ProfileRunResult {
@@ -142,6 +146,22 @@ func TestDirector_HandleRequest(t *testing.T) {
142
146
},
143
147
},
144
148
},
149
+ & schedulingtypes.ScoredPod {
150
+ Pod : & schedulingtypes.PodMetrics {
151
+ Pod : & backend.Pod {
152
+ Address : "192.168.2.100" ,
153
+ NamespacedName : k8stypes.NamespacedName {Name : "pod2" , Namespace : "default" },
154
+ },
155
+ },
156
+ },
157
+ & schedulingtypes.ScoredPod {
158
+ Pod : & schedulingtypes.PodMetrics {
159
+ Pod : & backend.Pod {
160
+ Address : "192.168.4.100" ,
161
+ NamespacedName : k8stypes.NamespacedName {Name : "pod4" , Namespace : "default" },
162
+ },
163
+ },
164
+ },
145
165
},
146
166
},
147
167
},
@@ -174,7 +194,7 @@ func TestDirector_HandleRequest(t *testing.T) {
174
194
NamespacedName : types.NamespacedName {Namespace : "default" , Name : "pod1" },
175
195
Address : "192.168.1.100" ,
176
196
},
177
- TargetEndpoint : "192.168.1.100:8000" ,
197
+ TargetEndpoint : "192.168.1.100:8000,192.168.2.100:8000,192.168.4.100:8000 " ,
178
198
},
179
199
wantMutatedBodyModel : model ,
180
200
},
@@ -199,7 +219,7 @@ func TestDirector_HandleRequest(t *testing.T) {
199
219
NamespacedName : types.NamespacedName {Namespace : "default" , Name : "pod1" },
200
220
Address : "192.168.1.100" ,
201
221
},
202
- TargetEndpoint : "192.168.1.100:8000" ,
222
+ TargetEndpoint : "192.168.1.100:8000,192.168.2.100:8000,192.168.4.100:8000 " ,
203
223
},
204
224
wantMutatedBodyModel : model ,
205
225
},
@@ -228,7 +248,7 @@ func TestDirector_HandleRequest(t *testing.T) {
228
248
NamespacedName : types.NamespacedName {Namespace : "default" , Name : "pod1" },
229
249
Address : "192.168.1.100" ,
230
250
},
231
- TargetEndpoint : "192.168.1.100:8000" ,
251
+ TargetEndpoint : "192.168.1.100:8000,192.168.2.100:8000,192.168.4.100:8000 " ,
232
252
},
233
253
wantMutatedBodyModel : model ,
234
254
},
@@ -249,7 +269,7 @@ func TestDirector_HandleRequest(t *testing.T) {
249
269
NamespacedName : types.NamespacedName {Namespace : "default" , Name : "pod1" },
250
270
Address : "192.168.1.100" ,
251
271
},
252
- TargetEndpoint : "192.168.1.100:8000" ,
272
+ TargetEndpoint : "192.168.1.100:8000,192.168.2.100:8000,192.168.4.100:8000 " ,
253
273
},
254
274
wantMutatedBodyModel : modelSheddable ,
255
275
},
@@ -270,7 +290,7 @@ func TestDirector_HandleRequest(t *testing.T) {
270
290
NamespacedName : types.NamespacedName {Namespace : "default" , Name : "pod1" },
271
291
Address : "192.168.1.100" ,
272
292
},
273
- TargetEndpoint : "192.168.1.100:8000" ,
293
+ TargetEndpoint : "192.168.1.100:8000,192.168.2.100:8000,192.168.4.100:8000 " ,
274
294
},
275
295
wantMutatedBodyModel : "resolved-target-model-A" ,
276
296
},
@@ -286,7 +306,7 @@ func TestDirector_HandleRequest(t *testing.T) {
286
306
NamespacedName : types.NamespacedName {Namespace : "default" , Name : "pod1" },
287
307
Address : "192.168.1.100" ,
288
308
},
289
- TargetEndpoint : "192.168.1.100:8000" ,
309
+ TargetEndpoint : "192.168.1.100:8000,192.168.2.100:8000,192.168.4.100:8000 " ,
290
310
},
291
311
wantMutatedBodyModel : "food-review-1" ,
292
312
reqBodyMap : map [string ]any {
0 commit comments