Skip to content

Commit f93cbe6

Browse files
committed
Add unit test coverage for pod APIs under datastore/pkg
1 parent e03802a commit f93cbe6

File tree

1 file changed

+5
-29
lines changed

1 file changed

+5
-29
lines changed

pkg/epp/datastore/datastore_test.go

+5-29
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ import (
3030
"k8s.io/apimachinery/pkg/runtime"
3131
"k8s.io/apimachinery/pkg/types"
3232
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
33-
"sigs.k8s.io/controller-runtime/pkg/client"
34-
"sigs.k8s.io/controller-runtime/pkg/client/config"
3533
"sigs.k8s.io/controller-runtime/pkg/client/fake"
3634
"sigs.k8s.io/gateway-api-inference-extension/api/v1alpha2"
3735
backendmetrics "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/backend/metrics"
@@ -359,10 +357,6 @@ func TestMetrics(t *testing.T) {
359357
}
360358

361359
func TestPods(t *testing.T) {
362-
poolSelector := map[string]string{"app": "vllm_v1"}
363-
pool := testutil.MakeInferencePool("pool").
364-
Namespace("default").
365-
Selector(poolSelector).ObjRef()
366360
updatedPod := &corev1.Pod{
367361
ObjectMeta: metav1.ObjectMeta{
368362
Name: "pod1",
@@ -371,10 +365,6 @@ func TestPods(t *testing.T) {
371365
NodeName: "node-1",
372366
},
373367
}
374-
resyncPoolSelector := map[string]string{"app": "llama3_8b"}
375-
resyncPool := testutil.MakeInferencePool("pool").
376-
Namespace("default").
377-
Selector(resyncPoolSelector).ObjRef()
378368
tests := []struct {
379369
name string
380370
op func(ctx context.Context, ds Datastore)
@@ -386,23 +376,23 @@ func TestPods(t *testing.T) {
386376
existingPods: []*corev1.Pod{},
387377
wantPods: []*corev1.Pod{pod1},
388378
op: func(ctx context.Context, ds Datastore) {
389-
ds.PodUpdateOrAddIfNotExist(pod1, pool)
379+
ds.PodUpdateOrAddIfNotExist(pod1)
390380
},
391381
},
392382
{
393383
name: "Add new pod, with existing pods, should add",
394384
existingPods: []*corev1.Pod{pod1},
395385
wantPods: []*corev1.Pod{pod1, pod2},
396386
op: func(ctx context.Context, ds Datastore) {
397-
ds.PodUpdateOrAddIfNotExist(pod2, pool)
387+
ds.PodUpdateOrAddIfNotExist(pod2)
398388
},
399389
},
400390
{
401391
name: "Update existing pod, new field, should update",
402392
existingPods: []*corev1.Pod{pod1},
403393
wantPods: []*corev1.Pod{updatedPod},
404394
op: func(ctx context.Context, ds Datastore) {
405-
ds.PodUpdateOrAddIfNotExist(updatedPod, pool)
395+
ds.PodUpdateOrAddIfNotExist(updatedPod)
406396
},
407397
},
408398
{
@@ -416,21 +406,7 @@ func TestPods(t *testing.T) {
416406
Namespace: "default",
417407
},
418408
}
419-
ds.PodUpdateOrAddIfNotExist(incoming, pool)
420-
},
421-
},
422-
{
423-
name: "Change pool selector, resync required, should update",
424-
existingPods: []*corev1.Pod{pod1, pod2},
425-
wantPods: []*corev1.Pod{pod1, pod2},
426-
op: func(ctx context.Context, ds Datastore) {
427-
scheme := runtime.NewScheme()
428-
cfg := config.GetConfigOrDie()
429-
cli, err := client.New(cfg, client.Options{Scheme: scheme})
430-
if err != nil {
431-
t.Fatalf("Unable to create ctrl runtime client")
432-
}
433-
ds.PodResyncAll(ctx, cli, resyncPool)
409+
ds.PodUpdateOrAddIfNotExist(incoming)
434410
},
435411
},
436412
{
@@ -455,7 +431,7 @@ func TestPods(t *testing.T) {
455431
pmf := backendmetrics.NewPodMetricsFactory(&backendmetrics.FakePodMetricsClient{}, time.Second)
456432
ds := NewDatastore(t.Context(), pmf)
457433
for _, pod := range test.existingPods {
458-
ds.PodUpdateOrAddIfNotExist(pod, pool)
434+
ds.PodUpdateOrAddIfNotExist(pod)
459435
}
460436

461437
test.op(ctx, ds)

0 commit comments

Comments
 (0)