Skip to content

Commit a425e3b

Browse files
committed
Test updates due to PodInfo rename
Signed-off-by: Shmuel Kallner <[email protected]>
1 parent 45f9dfd commit a425e3b

File tree

7 files changed

+36
-36
lines changed

7 files changed

+36
-36
lines changed

pkg/epp/backend/metrics/fake.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ type FakePodMetrics struct {
3838
}
3939

4040
func (fpm *FakePodMetrics) String() string {
41-
return fmt.Sprintf("Pod: %v; Metrics: %v", fpm.GetPod(), fpm.GetMetrics())
41+
return fmt.Sprintf("Pod: %v; Metrics: %v", fpm.GetMetadata(), fpm.GetMetrics())
4242
}
4343

44-
func (fpm *FakePodMetrics) GetPod() *backend.Pod {
44+
func (fpm *FakePodMetrics) GetMetadata() *backend.Pod {
4545
return fpm.Pod
4646
}
4747

4848
func (fpm *FakePodMetrics) GetMetrics() *MetricsState {
4949
return fpm.Metrics
5050
}
5151

52-
func (fpm *FakePodMetrics) UpdatePod(pod *datalayer.PodInfo) {
52+
func (fpm *FakePodMetrics) UpdateMetadata(pod *datalayer.EndpointMetadata) {
5353
fpm.Pod = pod
5454
}
5555
func (fpm *FakePodMetrics) GetAttributes() *datalayer.Attributes {

pkg/epp/backend/metrics/pod_metrics_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
)
3131

3232
var (
33-
pod1Info = &datalayer.PodInfo{
33+
pod1Info = &datalayer.EndpointMetadata{
3434
NamespacedName: types.NamespacedName{
3535
Name: "pod1-rank-0",
3636
Namespace: "default",

pkg/epp/controller/inferencepool_reconciler_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func TestInferencePoolReconciler(t *testing.T) {
121121
if _, err := inferencePoolReconciler.Reconcile(ctx, req); err != nil {
122122
t.Errorf("Unexpected InferencePool reconcile error: %v", err)
123123
}
124-
if diff := diffStore(ds, diffStoreParams{wantPool: pool1, wantPods: []string{"pod1-rank-0", "pod2-rank-0"}}); diff != "" {
124+
if diff := diffStore(ds, diffStoreParams{wantPool: pool1, wantEndpoints: []string{"pod1-rank-0", "pod2-rank-0"}}); diff != "" {
125125
t.Errorf("Unexpected diff (+got/-want): %s", diff)
126126
}
127127

@@ -139,7 +139,7 @@ func TestInferencePoolReconciler(t *testing.T) {
139139
if _, err := inferencePoolReconciler.Reconcile(ctx, req); err != nil {
140140
t.Errorf("Unexpected InferencePool reconcile error: %v", err)
141141
}
142-
if diff := diffStore(ds, diffStoreParams{wantPool: newPool1, wantPods: []string{"pod5-rank-0"}}); diff != "" {
142+
if diff := diffStore(ds, diffStoreParams{wantPool: newPool1, wantEndpoints: []string{"pod5-rank-0"}}); diff != "" {
143143
t.Errorf("Unexpected diff (+got/-want): %s", diff)
144144
}
145145

@@ -154,7 +154,7 @@ func TestInferencePoolReconciler(t *testing.T) {
154154
if _, err := inferencePoolReconciler.Reconcile(ctx, req); err != nil {
155155
t.Errorf("Unexpected InferencePool reconcile error: %v", err)
156156
}
157-
if diff := diffStore(ds, diffStoreParams{wantPool: newPool1, wantPods: []string{"pod5-rank-0"}}); diff != "" {
157+
if diff := diffStore(ds, diffStoreParams{wantPool: newPool1, wantEndpoints: []string{"pod5-rank-0"}}); diff != "" {
158158
t.Errorf("Unexpected diff (+got/-want): %s", diff)
159159
}
160160

@@ -168,14 +168,14 @@ func TestInferencePoolReconciler(t *testing.T) {
168168
if _, err := inferencePoolReconciler.Reconcile(ctx, req); err != nil {
169169
t.Errorf("Unexpected InferencePool reconcile error: %v", err)
170170
}
171-
if diff := diffStore(ds, diffStoreParams{wantPods: []string{}}); diff != "" {
171+
if diff := diffStore(ds, diffStoreParams{wantEndpoints: []string{}}); diff != "" {
172172
t.Errorf("Unexpected diff (+got/-want): %s", diff)
173173
}
174174
}
175175

176176
type diffStoreParams struct {
177177
wantPool *v1.InferencePool
178-
wantPods []string
178+
wantEndpoints []string
179179
wantObjectives []*v1alpha2.InferenceObjective
180180
}
181181

@@ -188,15 +188,15 @@ func diffStore(datastore datastore.Datastore, params diffStoreParams) string {
188188
}
189189

190190
// Default wantPods if not set because PodGetAll returns an empty slice when empty.
191-
if params.wantPods == nil {
192-
params.wantPods = []string{}
191+
if params.wantEndpoints == nil {
192+
params.wantEndpoints = []string{}
193193
}
194-
gotPods := []string{}
195-
for _, pm := range datastore.PodList(backendmetrics.AllPodsPredicate) {
196-
gotPods = append(gotPods, pm.GetPod().NamespacedName.Name)
194+
gotEndpoints := []string{}
195+
for _, em := range datastore.PodList(backendmetrics.AllPodsPredicate) {
196+
gotEndpoints = append(gotEndpoints, em.GetMetadata().NamespacedName.Name)
197197
}
198-
if diff := cmp.Diff(params.wantPods, gotPods, cmpopts.SortSlices(func(a, b string) bool { return a < b })); diff != "" {
199-
return "pods:" + diff
198+
if diff := cmp.Diff(params.wantEndpoints, gotEndpoints, cmpopts.SortSlices(func(a, b string) bool { return a < b })); diff != "" {
199+
return "endpoints:" + diff
200200
}
201201

202202
// Default wantModels if not set because ModelGetAll returns an empty slice when empty.
@@ -348,8 +348,8 @@ func xDiffStore(t *testing.T, datastore datastore.Datastore, params xDiffStorePa
348348
params.wantPods = []string{}
349349
}
350350
gotPods := []string{}
351-
for _, pm := range datastore.PodList(backendmetrics.AllPodsPredicate) {
352-
gotPods = append(gotPods, pm.GetPod().NamespacedName.Name)
351+
for _, em := range datastore.PodList(backendmetrics.AllPodsPredicate) {
352+
gotPods = append(gotPods, em.GetMetadata().NamespacedName.Name)
353353
}
354354
if diff := cmp.Diff(params.wantPods, gotPods, cmpopts.SortSlices(func(a, b string) bool { return a < b })); diff != "" {
355355
return "pods:" + diff

pkg/epp/controller/pod_reconciler_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ func TestPodReconciler(t *testing.T) {
212212
}
213213

214214
var gotPods []*corev1.Pod
215-
for _, pm := range store.PodList(backendmetrics.AllPodsPredicate) {
216-
pod := &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Name: pm.GetPod().PodName, Namespace: pm.GetPod().NamespacedName.Namespace}, Status: corev1.PodStatus{PodIP: pm.GetPod().GetIPAddress()}}
215+
for _, em := range store.PodList(backendmetrics.AllPodsPredicate) {
216+
pod := &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Name: em.GetMetadata().PodName, Namespace: em.GetMetadata().NamespacedName.Namespace}, Status: corev1.PodStatus{PodIP: em.GetMetadata().GetIPAddress()}}
217217
gotPods = append(gotPods, pod)
218218
}
219219
if !cmp.Equal(gotPods, test.wantPods, cmpopts.SortSlices(func(a, b *corev1.Pod) bool { return a.Name < b.Name })) {

pkg/epp/datalayer/collector_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ func (d *DummySource) Collect(ctx context.Context, ep Endpoint) error {
4444
}
4545

4646
func defaultEndpoint() Endpoint {
47-
pod := &PodInfo{
47+
meta := &EndpointMetadata{
4848
NamespacedName: types.NamespacedName{
4949
Name: "pod-name",
5050
Namespace: "default",
5151
},
5252
Address: "1.2.3.4:5678",
5353
}
54-
ms := NewEndpoint(pod, nil)
54+
ms := NewEndpoint(meta, nil)
5555
return ms
5656
}
5757

pkg/epp/datastore/datastore_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ func TestPods(t *testing.T) {
407407
test.op(ctx, ds)
408408
var gotPods []*corev1.Pod
409409
for _, pm := range ds.PodList(backendmetrics.AllPodsPredicate) {
410-
pod := &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Name: pm.GetPod().PodName, Namespace: pm.GetPod().NamespacedName.Namespace}, Status: corev1.PodStatus{PodIP: pm.GetPod().GetIPAddress()}}
410+
pod := &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Name: pm.GetMetadata().PodName, Namespace: pm.GetMetadata().NamespacedName.Namespace}, Status: corev1.PodStatus{PodIP: pm.GetMetadata().GetIPAddress()}}
411411
gotPods = append(gotPods, pod)
412412
}
413413
if !cmp.Equal(gotPods, test.wantPods, cmpopts.SortSlices(func(a, b *corev1.Pod) bool { return a.Name < b.Name })) {
@@ -419,16 +419,16 @@ func TestPods(t *testing.T) {
419419

420420
func TestPodInfo(t *testing.T) {
421421
tests := []struct {
422-
name string
423-
op func(ctx context.Context, ds Datastore)
424-
pool *v1.InferencePool
425-
existingPods []*corev1.Pod
426-
wantPodInfos []*datalayer.PodInfo
422+
name string
423+
op func(ctx context.Context, ds Datastore)
424+
pool *v1.InferencePool
425+
existingPods []*corev1.Pod
426+
wantEndpointMetas []*datalayer.EndpointMetadata
427427
}{
428428
{
429429
name: "Add new pod, no existing pods, should add",
430430
existingPods: []*corev1.Pod{},
431-
wantPodInfos: []*datalayer.PodInfo{
431+
wantEndpointMetas: []*datalayer.EndpointMetadata{
432432
{
433433
NamespacedName: types.NamespacedName{
434434
Name: pod1.Name + "-rank-0",
@@ -450,7 +450,7 @@ func TestPodInfo(t *testing.T) {
450450
{
451451
name: "Add new pod, no existing pods, should add, multiple target ports",
452452
existingPods: []*corev1.Pod{},
453-
wantPodInfos: []*datalayer.PodInfo{
453+
wantEndpointMetas: []*datalayer.EndpointMetadata{
454454
{
455455
NamespacedName: types.NamespacedName{
456456
Name: pod1.Name + "-rank-0",
@@ -484,7 +484,7 @@ func TestPodInfo(t *testing.T) {
484484
{
485485
name: "Add new pod, with existing pods, should add, multiple target ports",
486486
existingPods: []*corev1.Pod{pod1},
487-
wantPodInfos: []*datalayer.PodInfo{
487+
wantEndpointMetas: []*datalayer.EndpointMetadata{
488488
{
489489
NamespacedName: types.NamespacedName{
490490
Name: pod1.Name + "-rank-0",
@@ -542,7 +542,7 @@ func TestPodInfo(t *testing.T) {
542542
{
543543
name: "Delete the pod, multiple target ports",
544544
existingPods: []*corev1.Pod{pod1, pod2},
545-
wantPodInfos: []*datalayer.PodInfo{
545+
wantEndpointMetas: []*datalayer.EndpointMetadata{
546546
{
547547
NamespacedName: types.NamespacedName{
548548
Name: pod1.Name + "-rank-0",
@@ -589,11 +589,11 @@ func TestPodInfo(t *testing.T) {
589589
}
590590

591591
test.op(ctx, ds)
592-
var gotPodInfos []*datalayer.PodInfo
592+
var gotEndpointMetas []*datalayer.EndpointMetadata
593593
for _, pm := range ds.PodList(backendmetrics.AllPodsPredicate) {
594-
gotPodInfos = append(gotPodInfos, pm.GetPod())
594+
gotEndpointMetas = append(gotEndpointMetas, pm.GetMetadata())
595595
}
596-
if diff := cmp.Diff(test.wantPodInfos, gotPodInfos, cmpopts.SortSlices(func(a, b *datalayer.PodInfo) bool { return a.NamespacedName.Name < b.NamespacedName.Name })); diff != "" {
596+
if diff := cmp.Diff(test.wantEndpointMetas, gotEndpointMetas, cmpopts.SortSlices(func(a, b *datalayer.EndpointMetadata) bool { return a.NamespacedName.Name < b.NamespacedName.Name })); diff != "" {
597597
t.Errorf("ConvertTo() mismatch (-want +got):\n%s", diff)
598598
}
599599
})

pkg/epp/requestcontrol/director_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ func TestGetCandidatePodsForScheduling(t *testing.T) {
698698
got := director.getCandidatePodsForScheduling(context.Background(), test.metadata)
699699

700700
diff := cmp.Diff(test.output, got, cmpopts.SortSlices(func(a, b backendmetrics.PodMetrics) bool {
701-
return a.GetPod().NamespacedName.String() < b.GetPod().NamespacedName.String()
701+
return a.GetMetadata().NamespacedName.String() < b.GetMetadata().NamespacedName.String()
702702
}))
703703
if diff != "" {
704704
t.Errorf("Unexpected output (-want +got): %v", diff)

0 commit comments

Comments
 (0)