@@ -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
@@ -107,26 +108,29 @@ func TestDirector_HandleRequest(t *testing.T) {
107
108
},
108
109
}
109
110
110
- // Pod setup
111
- testPod := & corev1.Pod {
112
- ObjectMeta : metav1.ObjectMeta {
113
- Name : "pod1" ,
114
- Namespace : "default" ,
115
- Labels : map [string ]string {"app" : "inference" },
116
- },
117
- Status : corev1.PodStatus {
118
- PodIP : "192.168.1.100" ,
119
- Phase : corev1 .PodRunning ,
120
- Conditions : []corev1.PodCondition {{Type : corev1 .PodReady , Status : corev1 .ConditionTrue }},
121
- },
122
- }
123
111
scheme := runtime .NewScheme ()
124
112
_ = clientgoscheme .AddToScheme (scheme )
125
113
fakeClient := fake .NewClientBuilder ().WithScheme (scheme ).Build ()
126
114
if err := ds .PoolSet (ctx , fakeClient , pool ); err != nil {
127
115
t .Fatalf ("Error while setting inference pool: %v" , err )
128
116
}
129
- ds .PodUpdateOrAddIfNotExist (testPod )
117
+
118
+ for i := range 5 {
119
+ // Pod setup
120
+ testPod := & corev1.Pod {
121
+ ObjectMeta : metav1.ObjectMeta {
122
+ Name : fmt .Sprintf ("pod%v" , i + 1 ),
123
+ Namespace : "default" ,
124
+ Labels : map [string ]string {"app" : "inference" },
125
+ },
126
+ Status : corev1.PodStatus {
127
+ PodIP : fmt .Sprintf ("192.168.%v.100" , i + 1 ),
128
+ Phase : corev1 .PodRunning ,
129
+ Conditions : []corev1.PodCondition {{Type : corev1 .PodReady , Status : corev1 .ConditionTrue }},
130
+ },
131
+ }
132
+ ds .PodUpdateOrAddIfNotExist (testPod )
133
+ }
130
134
131
135
defaultSuccessfulScheduleResults := & schedulingtypes.SchedulingResult {
132
136
ProfileResults : map [string ]* schedulingtypes.ProfileRunResult {
@@ -140,6 +144,22 @@ func TestDirector_HandleRequest(t *testing.T) {
140
144
},
141
145
},
142
146
},
147
+ & schedulingtypes.ScoredPod {
148
+ Pod : & schedulingtypes.PodMetrics {
149
+ Pod : & backend.Pod {
150
+ Address : "192.168.2.100" ,
151
+ NamespacedName : k8stypes.NamespacedName {Name : "pod2" , Namespace : "default" },
152
+ },
153
+ },
154
+ },
155
+ & schedulingtypes.ScoredPod {
156
+ Pod : & schedulingtypes.PodMetrics {
157
+ Pod : & backend.Pod {
158
+ Address : "192.168.4.100" ,
159
+ NamespacedName : k8stypes.NamespacedName {Name : "pod4" , Namespace : "default" },
160
+ },
161
+ },
162
+ },
143
163
},
144
164
},
145
165
},
@@ -172,7 +192,7 @@ func TestDirector_HandleRequest(t *testing.T) {
172
192
NamespacedName : types.NamespacedName {Namespace : "default" , Name : "pod1" },
173
193
Address : "192.168.1.100" ,
174
194
},
175
- TargetEndpoint : "192.168.1.100:8000" ,
195
+ TargetEndpoint : "192.168.1.100:8000,192.168.2.100:8000,192.168.4.100:8000 " ,
176
196
},
177
197
wantMutatedBodyModel : model ,
178
198
},
@@ -197,7 +217,7 @@ func TestDirector_HandleRequest(t *testing.T) {
197
217
NamespacedName : types.NamespacedName {Namespace : "default" , Name : "pod1" },
198
218
Address : "192.168.1.100" ,
199
219
},
200
- TargetEndpoint : "192.168.1.100:8000" ,
220
+ TargetEndpoint : "192.168.1.100:8000,192.168.2.100:8000,192.168.4.100:8000 " ,
201
221
},
202
222
wantMutatedBodyModel : model ,
203
223
},
@@ -226,7 +246,7 @@ func TestDirector_HandleRequest(t *testing.T) {
226
246
NamespacedName : types.NamespacedName {Namespace : "default" , Name : "pod1" },
227
247
Address : "192.168.1.100" ,
228
248
},
229
- TargetEndpoint : "192.168.1.100:8000" ,
249
+ TargetEndpoint : "192.168.1.100:8000,192.168.2.100:8000,192.168.4.100:8000 " ,
230
250
},
231
251
wantMutatedBodyModel : model ,
232
252
},
@@ -247,7 +267,7 @@ func TestDirector_HandleRequest(t *testing.T) {
247
267
NamespacedName : types.NamespacedName {Namespace : "default" , Name : "pod1" },
248
268
Address : "192.168.1.100" ,
249
269
},
250
- TargetEndpoint : "192.168.1.100:8000" ,
270
+ TargetEndpoint : "192.168.1.100:8000,192.168.2.100:8000,192.168.4.100:8000 " ,
251
271
},
252
272
wantMutatedBodyModel : modelSheddable ,
253
273
},
@@ -268,7 +288,7 @@ func TestDirector_HandleRequest(t *testing.T) {
268
288
NamespacedName : types.NamespacedName {Namespace : "default" , Name : "pod1" },
269
289
Address : "192.168.1.100" ,
270
290
},
271
- TargetEndpoint : "192.168.1.100:8000" ,
291
+ TargetEndpoint : "192.168.1.100:8000,192.168.2.100:8000,192.168.4.100:8000 " ,
272
292
},
273
293
wantMutatedBodyModel : "resolved-target-model-A" ,
274
294
},
@@ -284,7 +304,7 @@ func TestDirector_HandleRequest(t *testing.T) {
284
304
NamespacedName : types.NamespacedName {Namespace : "default" , Name : "pod1" },
285
305
Address : "192.168.1.100" ,
286
306
},
287
- TargetEndpoint : "192.168.1.100:8000" ,
307
+ TargetEndpoint : "192.168.1.100:8000,192.168.2.100:8000,192.168.4.100:8000 " ,
288
308
},
289
309
wantMutatedBodyModel : "food-review-1" ,
290
310
reqBodyMap : map [string ]any {
0 commit comments