Skip to content

Commit 772ac4d

Browse files
rlakhtakiakfswainnirrozenbaumhowardjohnliu-cong
authored
Add unit tests for pod APIs under pkg/datastore (#712)
* Add unit test coverage for pod APIs under datastore/pkg * Add unit test coverage for pod APIs under datastore/pkg * Add unit test coverage for pod APIs under datastore/pkg * Add unit test coverage for pod APIs under datastore/pkg * EPP Architecture proposal (#683) * initial changes * Adding to proposal to give a quick barebones definition to refactor * feedback changes * more feedback addressing * removed unused Fake struct (#723) Signed-off-by: Nir Rozenbaum <[email protected]> * epp: return correct response for trailers (#726) This looks like a copy paste error. * Refactor scheduler to run plugins (#677) * Refactor scheduler to run plugins * Add scheduler plugin latency metric * Address comments * Address comments * Complete the InferencePool documentation (#673) * Initial guide for inference pool * Add extensionReference to the InferencePool spec * Fix list formatting * Remove unused labels * Autogenerate the spec * Update site-src/api-types/inferencepool.md Co-authored-by: Rob Scott <[email protected]> * Update site-src/api-types/inferencepool.md Co-authored-by: Rob Scott <[email protected]> * Update site-src/api-types/inferencepool.md Co-authored-by: Rob Scott <[email protected]> * Update site-src/api-types/inferencepool.md Co-authored-by: Rob Scott <[email protected]> * Update site-src/api-types/inferencepool.md Co-authored-by: Rob Scott <[email protected]> * Update site-src/api-types/inferencepool.md Co-authored-by: Rob Scott <[email protected]> * Rename llm-pool names in rollout example * Add use cases for replacing an inference pool * Rewording the background section * Create replacing-inference-pool.md * Replace instructions with a link for how to replace an inference pool * Update replacing-inference-pool.md * Update mkdocs.yml * Update replacing-inference-pool.md * Update inferencemodel_types.go * Update inferencepool.md * Update site-src/guides/replacing-inference-pool.md Co-authored-by: Rob Scott <[email protected]> --------- Co-authored-by: Rob Scott <[email protected]> * reduce log level in metrics logger not to trash the log (#708) * reduce log level in metrics logger not to trash the log Signed-off-by: Nir Rozenbaum <[email protected]> * rename flush metrics to refresh metrics Signed-off-by: Nir Rozenbaum <[email protected]> * revert log level Signed-off-by: Nir Rozenbaum <[email protected]> --------- Signed-off-by: Nir Rozenbaum <[email protected]> * few updates in datastore (#713) * few updates in datastore Signed-off-by: Nir Rozenbaum <[email protected]> * PoolSet documentation Signed-off-by: Nir Rozenbaum <[email protected]> * error phrasing Signed-off-by: Nir Rozenbaum <[email protected]> * removed unused pool arg from PodUpdateOrAddIfNotExist Signed-off-by: Nir Rozenbaum <[email protected]> * linter Signed-off-by: Nir Rozenbaum <[email protected]> --------- Signed-off-by: Nir Rozenbaum <[email protected]> * scheduler refactoring (#730) Signed-off-by: Nir Rozenbaum <[email protected]> * filter irrelevant pod in pod_reconciler (#696) * EPP: Update GetRandomPod() to return nil if no pods exist (#731) Signed-off-by: Daneyon Hansen <[email protected]> * Move filter and scorer plugins registration to a separate file (#729) * Move filters and scorers registration to filter/scorer specific files * Default scheduler config contains empty list of scorers Signed-off-by: Maya Barnea <[email protected]> * Default plugin is not a scorer any more Signed-off-by: Maya Barnea <[email protected]> * fix scheduler test + lint comments Signed-off-by: Maya Barnea <[email protected]> --------- Signed-off-by: Maya Barnea <[email protected]> * Update issue templates (#738) * Update issue templates * Updates artifacts for v0.3.0-rc.1 release Signed-off-by: Kellen Swain <[email protected]> * Updates bbr chart for v0.3.0-rc.1 release Signed-off-by: Kellen Swain <[email protected]> * Updates artifacts for v0.3.0 release Signed-off-by: Kellen Swain <[email protected]> * Adding blank issue template so that all issues start with label --------- Signed-off-by: Kellen Swain <[email protected]> * Add unit test coverage for pod APIs under datastore/pkg * few updates in datastore (#713) * few updates in datastore Signed-off-by: Nir Rozenbaum <[email protected]> * PoolSet documentation Signed-off-by: Nir Rozenbaum <[email protected]> * error phrasing Signed-off-by: Nir Rozenbaum <[email protected]> * removed unused pool arg from PodUpdateOrAddIfNotExist Signed-off-by: Nir Rozenbaum <[email protected]> * linter Signed-off-by: Nir Rozenbaum <[email protected]> --------- Signed-off-by: Nir Rozenbaum <[email protected]> * few updates in datastore (#713) * few updates in datastore Signed-off-by: Nir Rozenbaum <[email protected]> * PoolSet documentation Signed-off-by: Nir Rozenbaum <[email protected]> * error phrasing Signed-off-by: Nir Rozenbaum <[email protected]> * removed unused pool arg from PodUpdateOrAddIfNotExist Signed-off-by: Nir Rozenbaum <[email protected]> * linter Signed-off-by: Nir Rozenbaum <[email protected]> --------- Signed-off-by: Nir Rozenbaum <[email protected]> * Add unit test coverage for pod APIs under datastore/pkg --------- Signed-off-by: Nir Rozenbaum <[email protected]> Signed-off-by: Daneyon Hansen <[email protected]> Signed-off-by: Maya Barnea <[email protected]> Signed-off-by: Kellen Swain <[email protected]> Co-authored-by: Kellen Swain <[email protected]> Co-authored-by: Nir Rozenbaum <[email protected]> Co-authored-by: John Howard <[email protected]> Co-authored-by: Cong Liu <[email protected]> Co-authored-by: Nicole Xin <[email protected]> Co-authored-by: Rob Scott <[email protected]> Co-authored-by: nayihz <[email protected]> Co-authored-by: Daneyon Hansen <[email protected]> Co-authored-by: Maya Barnea <[email protected]>
1 parent b66a61c commit 772ac4d

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

pkg/epp/datastore/datastore_test.go

+91
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,94 @@ func TestMetrics(t *testing.T) {
355355
})
356356
}
357357
}
358+
359+
func TestPods(t *testing.T) {
360+
updatedPod := &corev1.Pod{
361+
ObjectMeta: metav1.ObjectMeta{
362+
Name: "pod1",
363+
},
364+
Spec: corev1.PodSpec{
365+
NodeName: "node-1",
366+
},
367+
}
368+
tests := []struct {
369+
name string
370+
op func(ctx context.Context, ds Datastore)
371+
existingPods []*corev1.Pod
372+
wantPods []*corev1.Pod
373+
}{
374+
{
375+
name: "Add new pod, no existing pods, should add",
376+
existingPods: []*corev1.Pod{},
377+
wantPods: []*corev1.Pod{pod1},
378+
op: func(ctx context.Context, ds Datastore) {
379+
ds.PodUpdateOrAddIfNotExist(pod1)
380+
},
381+
},
382+
{
383+
name: "Add new pod, with existing pods, should add",
384+
existingPods: []*corev1.Pod{pod1},
385+
wantPods: []*corev1.Pod{pod1, pod2},
386+
op: func(ctx context.Context, ds Datastore) {
387+
ds.PodUpdateOrAddIfNotExist(pod2)
388+
},
389+
},
390+
{
391+
name: "Update existing pod, new field, should update",
392+
existingPods: []*corev1.Pod{pod1},
393+
wantPods: []*corev1.Pod{updatedPod},
394+
op: func(ctx context.Context, ds Datastore) {
395+
ds.PodUpdateOrAddIfNotExist(updatedPod)
396+
},
397+
},
398+
{
399+
name: "Update existing pod, no new fields, should not update",
400+
existingPods: []*corev1.Pod{pod1},
401+
wantPods: []*corev1.Pod{pod1},
402+
op: func(ctx context.Context, ds Datastore) {
403+
incoming := &corev1.Pod{
404+
ObjectMeta: metav1.ObjectMeta{
405+
Name: "pod1",
406+
Namespace: "default",
407+
},
408+
}
409+
ds.PodUpdateOrAddIfNotExist(incoming)
410+
},
411+
},
412+
{
413+
name: "Delete the pod",
414+
wantPods: []*corev1.Pod{pod1},
415+
op: func(ctx context.Context, ds Datastore) {
416+
ds.PodDelete(pod2NamespacedName)
417+
},
418+
},
419+
{
420+
name: "Delete the pod that doesn't exist",
421+
existingPods: []*corev1.Pod{pod1},
422+
wantPods: []*corev1.Pod{pod1},
423+
op: func(ctx context.Context, ds Datastore) {
424+
ds.PodDelete(pod2NamespacedName)
425+
},
426+
},
427+
}
428+
for _, test := range tests {
429+
t.Run(test.name, func(t *testing.T) {
430+
ctx := context.Background()
431+
pmf := backendmetrics.NewPodMetricsFactory(&backendmetrics.FakePodMetricsClient{}, time.Second)
432+
ds := NewDatastore(t.Context(), pmf)
433+
for _, pod := range test.existingPods {
434+
ds.PodUpdateOrAddIfNotExist(pod)
435+
}
436+
437+
test.op(ctx, ds)
438+
var gotPods []*corev1.Pod
439+
for _, pm := range ds.PodGetAll() {
440+
pod := &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Name: pm.GetPod().NamespacedName.Name, Namespace: pm.GetPod().NamespacedName.Namespace}, Status: corev1.PodStatus{PodIP: pm.GetPod().Address}}
441+
gotPods = append(gotPods, pod)
442+
}
443+
if !cmp.Equal(gotPods, test.wantPods, cmpopts.SortSlices(func(a, b *corev1.Pod) bool { return a.Name < b.Name })) {
444+
t.Logf("got (%v) != want (%v);", gotPods, test.wantPods)
445+
}
446+
})
447+
}
448+
}

0 commit comments

Comments
 (0)