Skip to content

Commit 27d60cb

Browse files
committed
Fix test and fmt
1 parent 98b9371 commit 27d60cb

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

Diff for: pkg/epp/controller/inferencemodel_reconciler_test.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,15 @@ func TestInferenceModelReconciler(t *testing.T) {
192192
WithIndex(&v1alpha2.InferenceModel{}, datastore.ModelNameIndexKey, indexInferenceModelsByModelName).
193193
Build()
194194
pmf := backendmetrics.NewPodMetricsFactory(&backendmetrics.FakePodMetricsClient{}, time.Second)
195-
datastore := datastore.NewFakeDatastore(t.Context(), pmf, nil, test.modelsInStore, pool)
195+
ds := datastore.NewDatastore(t.Context(), pmf)
196+
for _, m := range test.modelsInStore {
197+
ds.ModelSetIfOlder(m)
198+
}
199+
ds.PoolSet(pool)
196200
reconciler := &InferenceModelReconciler{
197201
Client: fakeClient,
198202
Record: record.NewFakeRecorder(10),
199-
Datastore: datastore,
203+
Datastore: ds,
200204
PoolNamespacedName: types.NamespacedName{Name: pool.Name, Namespace: pool.Namespace},
201205
}
202206
if test.incomingReq == nil {
@@ -213,11 +217,11 @@ func TestInferenceModelReconciler(t *testing.T) {
213217
t.Errorf("Unexpected result diff (+got/-want): %s", diff)
214218
}
215219

216-
if len(test.wantModels) != len(datastore.ModelGetAll()) {
217-
t.Errorf("Unexpected; want: %d, got:%d", len(test.wantModels), len(datastore.ModelGetAll()))
220+
if len(test.wantModels) != len(ds.ModelGetAll()) {
221+
t.Errorf("Unexpected; want: %d, got:%d", len(test.wantModels), len(ds.ModelGetAll()))
218222
}
219223

220-
if diff := diffStore(datastore, diffStoreParams{wantPool: pool, wantModels: test.wantModels}); diff != "" {
224+
if diff := diffStore(ds, diffStoreParams{wantPool: pool, wantModels: test.wantModels}); diff != "" {
221225
t.Errorf("Unexpected diff (+got/-want): %s", diff)
222226
}
223227

Diff for: pkg/epp/controller/pod_reconciler.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (c *PodReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
5959
return ctrl.Result{}, err
6060
}
6161

62-
c.updateDatastore(ctx, logger, pod, pool)
62+
c.updateDatastore(logger, pod, pool)
6363
return ctrl.Result{}, nil
6464
}
6565

@@ -69,7 +69,7 @@ func (c *PodReconciler) SetupWithManager(mgr ctrl.Manager) error {
6969
Complete(c)
7070
}
7171

72-
func (c *PodReconciler) updateDatastore(ctx context.Context, logger logr.Logger, pod *corev1.Pod, pool *v1alpha2.InferencePool) {
72+
func (c *PodReconciler) updateDatastore(logger logr.Logger, pod *corev1.Pod, pool *v1alpha2.InferencePool) {
7373
namespacedName := types.NamespacedName{Name: pod.Name, Namespace: pod.Namespace}
7474
if !pod.DeletionTimestamp.IsZero() || !c.Datastore.PoolLabelsMatch(pod.Labels) || !podIsReady(pod) {
7575
logger.V(logutil.DEBUG).Info("Pod removed or not added", "name", namespacedName)

Diff for: test/integration/epp/hermetic_test.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ func TestKubeInferenceModelRequest(t *testing.T) {
9595
req: utiltesting.GenerateRequest(logger, "test1", "my-model"),
9696
// pod-1 will be picked because it has relatively low queue size and low KV cache.
9797
pods: map[backendmetrics.Pod]*backendmetrics.Metrics{
98-
fakePod(0): &backendmetrics.Metrics{
98+
fakePod(0): {
9999
WaitingQueueSize: 3,
100100
KVCacheUsagePercent: 0.2,
101101
},
102-
fakePod(1): &backendmetrics.Metrics{
102+
fakePod(1): {
103103
WaitingQueueSize: 0,
104104
KVCacheUsagePercent: 0.1,
105105
},
106-
fakePod(2): &backendmetrics.Metrics{
106+
fakePod(2): {
107107
WaitingQueueSize: 10,
108108
KVCacheUsagePercent: 0.2,
109109
},
@@ -137,23 +137,23 @@ func TestKubeInferenceModelRequest(t *testing.T) {
137137
// pod-1 will be picked because it has relatively low queue size, with the requested
138138
// model being active, and has low KV cache.
139139
pods: map[backendmetrics.Pod]*backendmetrics.Metrics{
140-
fakePod(0): &backendmetrics.Metrics{
140+
fakePod(0): {
141141
WaitingQueueSize: 0,
142142
KVCacheUsagePercent: 0.2,
143143
ActiveModels: map[string]int{
144144
"foo": 1,
145145
"bar": 1,
146146
},
147147
},
148-
fakePod(1): &backendmetrics.Metrics{
148+
fakePod(1): {
149149
WaitingQueueSize: 0,
150150
KVCacheUsagePercent: 0.1,
151151
ActiveModels: map[string]int{
152152
"foo": 1,
153153
"sql-lora-1fdg2": 1,
154154
},
155155
},
156-
fakePod(2): &backendmetrics.Metrics{
156+
fakePod(2): {
157157
WaitingQueueSize: 10,
158158
KVCacheUsagePercent: 0.2,
159159
ActiveModels: map[string]int{
@@ -192,23 +192,23 @@ func TestKubeInferenceModelRequest(t *testing.T) {
192192
// as it's above the affinity for queue size. Also is critical, so we should
193193
// still honor request despite all queues > 5
194194
pods: map[backendmetrics.Pod]*backendmetrics.Metrics{
195-
fakePod(0): &backendmetrics.Metrics{
195+
fakePod(0): {
196196
WaitingQueueSize: 10,
197197
KVCacheUsagePercent: 0.2,
198198
ActiveModels: map[string]int{
199199
"foo": 1,
200200
"bar": 1,
201201
},
202202
},
203-
fakePod(1): &backendmetrics.Metrics{
203+
fakePod(1): {
204204
WaitingQueueSize: 200,
205205
KVCacheUsagePercent: 0.1,
206206
ActiveModels: map[string]int{
207207
"foo": 1,
208208
"sql-lora-1fdg2": 1,
209209
},
210210
},
211-
fakePod(2): &backendmetrics.Metrics{
211+
fakePod(2): {
212212
WaitingQueueSize: 6,
213213
KVCacheUsagePercent: 0.2,
214214
ActiveModels: map[string]int{
@@ -245,7 +245,7 @@ func TestKubeInferenceModelRequest(t *testing.T) {
245245
// no pods will be picked as all models are either above kv threshold,
246246
// queue threshold, or both.
247247
pods: map[backendmetrics.Pod]*backendmetrics.Metrics{
248-
fakePod(0): &backendmetrics.Metrics{
248+
fakePod(0): {
249249
WaitingQueueSize: 6,
250250
KVCacheUsagePercent: 0.2,
251251
ActiveModels: map[string]int{
@@ -254,15 +254,15 @@ func TestKubeInferenceModelRequest(t *testing.T) {
254254
"sql-lora-1fdg3": 1,
255255
},
256256
},
257-
fakePod(1): &backendmetrics.Metrics{
257+
fakePod(1): {
258258
WaitingQueueSize: 0,
259259
KVCacheUsagePercent: 0.85,
260260
ActiveModels: map[string]int{
261261
"foo": 1,
262262
"sql-lora-1fdg3": 1,
263263
},
264264
},
265-
fakePod(2): &backendmetrics.Metrics{
265+
fakePod(2): {
266266
WaitingQueueSize: 10,
267267
KVCacheUsagePercent: 0.9,
268268
ActiveModels: map[string]int{
@@ -287,7 +287,7 @@ func TestKubeInferenceModelRequest(t *testing.T) {
287287
req: utiltesting.GenerateRequest(logger, "test5", "sql-lora-sheddable"),
288288
// pod 0 will be picked as all other models are above threshold
289289
pods: map[backendmetrics.Pod]*backendmetrics.Metrics{
290-
fakePod(0): &backendmetrics.Metrics{
290+
fakePod(0): {
291291
WaitingQueueSize: 4,
292292
KVCacheUsagePercent: 0.2,
293293
ActiveModels: map[string]int{
@@ -296,15 +296,15 @@ func TestKubeInferenceModelRequest(t *testing.T) {
296296
"sql-lora-1fdg3": 1,
297297
},
298298
},
299-
fakePod(1): &backendmetrics.Metrics{
299+
fakePod(1): {
300300
WaitingQueueSize: 0,
301301
KVCacheUsagePercent: 0.85,
302302
ActiveModels: map[string]int{
303303
"foo": 1,
304304
"sql-lora-1fdg3": 1,
305305
},
306306
},
307-
fakePod(2): &backendmetrics.Metrics{
307+
fakePod(2): {
308308
WaitingQueueSize: 10,
309309
KVCacheUsagePercent: 0.9,
310310
ActiveModels: map[string]int{

0 commit comments

Comments
 (0)