Skip to content

Commit bebed8d

Browse files
committed
Test updates due to PodInfo rename
Signed-off-by: Shmuel Kallner <kallner@il.ibm.com>
1 parent a3968a8 commit bebed8d

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
@@ -29,7 +29,7 @@ import (
2929
)
3030

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

pkg/epp/controller/inferencepool_reconciler_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func TestInferencePoolReconciler(t *testing.T) {
123123
t.Errorf("Unexpected InferencePool reconcile error: %v", err)
124124
}
125125
endpointPool1 := pool.InferencePoolToEndpointPool(pool1)
126-
if diff := diffStore(ds, diffStoreParams{wantPool: endpointPool1, wantPods: []string{"pod1-rank-0", "pod2-rank-0"}}); diff != "" {
126+
if diff := diffStore(ds, diffStoreParams{wantPool: endpointPool1, wantEndpoints: []string{"pod1-rank-0", "pod2-rank-0"}}); diff != "" {
127127
t.Errorf("Unexpected diff (+got/-want): %s", diff)
128128
}
129129

@@ -141,7 +141,7 @@ func TestInferencePoolReconciler(t *testing.T) {
141141
t.Errorf("Unexpected InferencePool reconcile error: %v", err)
142142
}
143143
newEndpointPool1 := pool.InferencePoolToEndpointPool(newPool1)
144-
if diff := diffStore(ds, diffStoreParams{wantPool: newEndpointPool1, wantPods: []string{"pod5-rank-0"}}); diff != "" {
144+
if diff := diffStore(ds, diffStoreParams{wantPool: newEndpointPool1, wantEndpoints: []string{"pod5-rank-0"}}); diff != "" {
145145
t.Errorf("Unexpected diff (+got/-want): %s", diff)
146146
}
147147

@@ -157,7 +157,7 @@ func TestInferencePoolReconciler(t *testing.T) {
157157
t.Errorf("Unexpected InferencePool reconcile error: %v", err)
158158
}
159159
newEndpointPool1 = pool.InferencePoolToEndpointPool(newPool1)
160-
if diff := diffStore(ds, diffStoreParams{wantPool: newEndpointPool1, wantPods: []string{"pod5-rank-0"}}); diff != "" {
160+
if diff := diffStore(ds, diffStoreParams{wantPool: newEndpointPool1, wantEndpoints: []string{"pod5-rank-0"}}); diff != "" {
161161
t.Errorf("Unexpected diff (+got/-want): %s", diff)
162162
}
163163

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

179179
type diffStoreParams struct {
180180
wantPool *datalayer.EndpointPool
181-
wantPods []string
181+
wantEndpoints []string
182182
wantObjectives []*v1alpha2.InferenceObjective
183183
}
184184

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

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

203203
// Default wantModels if not set because ModelGetAll returns an empty slice when empty.
@@ -343,8 +343,8 @@ func xDiffStore(datastore datastore.Datastore, params xDiffStoreParams) string {
343343
params.wantPods = []string{}
344344
}
345345
gotPods := []string{}
346-
for _, pm := range datastore.PodList(backendmetrics.AllPodsPredicate) {
347-
gotPods = append(gotPods, pm.GetPod().NamespacedName.Name)
346+
for _, em := range datastore.PodList(backendmetrics.AllPodsPredicate) {
347+
gotPods = append(gotPods, em.GetMetadata().NamespacedName.Name)
348348
}
349349
if diff := cmp.Diff(params.wantPods, gotPods, cmpopts.SortSlices(func(a, b string) bool { return a < b })); diff != "" {
350350
return "pods:" + diff

pkg/epp/controller/pod_reconciler_test.go

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

215215
var gotPods []*corev1.Pod
216-
for _, pm := range store.PodList(backendmetrics.AllPodsPredicate) {
217-
pod := &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Name: pm.GetPod().PodName, Namespace: pm.GetPod().NamespacedName.Namespace}, Status: corev1.PodStatus{PodIP: pm.GetPod().GetIPAddress()}}
216+
for _, em := range store.PodList(backendmetrics.AllPodsPredicate) {
217+
pod := &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Name: em.GetMetadata().PodName, Namespace: em.GetMetadata().NamespacedName.Namespace}, Status: corev1.PodStatus{PodIP: em.GetMetadata().GetIPAddress()}}
218218
gotPods = append(gotPods, pod)
219219
}
220220
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
@@ -54,14 +54,14 @@ func (d *DummySource) Collect(ctx context.Context, ep Endpoint) error {
5454
}
5555

5656
func defaultEndpoint() Endpoint {
57-
pod := &PodInfo{
57+
meta := &EndpointMetadata{
5858
NamespacedName: types.NamespacedName{
5959
Name: "pod-name",
6060
Namespace: "default",
6161
},
6262
Address: "1.2.3.4:5678",
6363
}
64-
ms := NewEndpoint(pod, nil)
64+
ms := NewEndpoint(meta, nil)
6565
return ms
6666
}
6767

pkg/epp/datastore/datastore_test.go

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

421421
func TestPodInfo(t *testing.T) {
422422
tests := []struct {
423-
name string
424-
op func(ctx context.Context, ds Datastore)
425-
pool *v1.InferencePool
426-
existingPods []*corev1.Pod
427-
wantPodInfos []*datalayer.PodInfo
423+
name string
424+
op func(ctx context.Context, ds Datastore)
425+
pool *v1.InferencePool
426+
existingPods []*corev1.Pod
427+
wantEndpointMetas []*datalayer.EndpointMetadata
428428
}{
429429
{
430430
name: "Add new pod, no existing pods, should add",
431431
existingPods: []*corev1.Pod{},
432-
wantPodInfos: []*datalayer.PodInfo{
432+
wantEndpointMetas: []*datalayer.EndpointMetadata{
433433
{
434434
NamespacedName: types.NamespacedName{
435435
Name: pod1.Name + "-rank-0",
@@ -451,7 +451,7 @@ func TestPodInfo(t *testing.T) {
451451
{
452452
name: "Add new pod, no existing pods, should add, multiple target ports",
453453
existingPods: []*corev1.Pod{},
454-
wantPodInfos: []*datalayer.PodInfo{
454+
wantEndpointMetas: []*datalayer.EndpointMetadata{
455455
{
456456
NamespacedName: types.NamespacedName{
457457
Name: pod1.Name + "-rank-0",
@@ -485,7 +485,7 @@ func TestPodInfo(t *testing.T) {
485485
{
486486
name: "Add new pod, with existing pods, should add, multiple target ports",
487487
existingPods: []*corev1.Pod{pod1},
488-
wantPodInfos: []*datalayer.PodInfo{
488+
wantEndpointMetas: []*datalayer.EndpointMetadata{
489489
{
490490
NamespacedName: types.NamespacedName{
491491
Name: pod1.Name + "-rank-0",
@@ -543,7 +543,7 @@ func TestPodInfo(t *testing.T) {
543543
{
544544
name: "Delete the pod, multiple target ports",
545545
existingPods: []*corev1.Pod{pod1, pod2},
546-
wantPodInfos: []*datalayer.PodInfo{
546+
wantEndpointMetas: []*datalayer.EndpointMetadata{
547547
{
548548
NamespacedName: types.NamespacedName{
549549
Name: pod1.Name + "-rank-0",
@@ -590,11 +590,11 @@ func TestPodInfo(t *testing.T) {
590590
}
591591

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

pkg/epp/requestcontrol/director_test.go

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

786786
diff := cmp.Diff(test.output, got, cmpopts.SortSlices(func(a, b backendmetrics.PodMetrics) bool {
787-
return a.GetPod().NamespacedName.String() < b.GetPod().NamespacedName.String()
787+
return a.GetMetadata().NamespacedName.String() < b.GetMetadata().NamespacedName.String()
788788
}))
789789
if diff != "" {
790790
t.Errorf("Unexpected output (-want +got): %v", diff)

0 commit comments

Comments
 (0)