Skip to content

Commit b998640

Browse files
authored
Merge pull request #53 from kfswain/cleanup
Fixing hermetic_test, small formatting changes
2 parents 2d6b63a + 90d5516 commit b998640

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

pkg/ext-proc/backend/provider_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ func TestProvider(t *testing.T) {
8282
MaxActiveModels: 0,
8383
ActiveModels: map[string]int{},
8484
},
85-
}},
85+
},
86+
},
8687
},
8788
}
8889

pkg/ext-proc/test/hermetic_test.go

+12-6
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,14 @@ func TestHandleRequestBody(t *testing.T) {
7878
RawValue: []byte("address-1"),
7979
},
8080
},
81+
{
82+
Header: &configPb.HeaderValue{
83+
Key: "Content-Length",
84+
RawValue: []byte("70"),
85+
},
86+
},
8187
},
88+
wantBody: []byte("{\"max_tokens\":100,\"model\":\"my-model\",\"prompt\":\"hello\",\"temperature\":0}"),
8289
},
8390
}
8491

@@ -93,12 +100,11 @@ func TestHandleRequestBody(t *testing.T) {
93100
HeaderMutation: &extProcPb.HeaderMutation{
94101
SetHeaders: test.wantHeaders,
95102
},
96-
// TODO: Also check body once it's added.
97-
// BodyMutation: &extProcPb.BodyMutation{
98-
// Mutation: &extProcPb.BodyMutation_Body{
99-
// Body: test.wantBody,
100-
// },
101-
// },
103+
BodyMutation: &extProcPb.BodyMutation{
104+
Mutation: &extProcPb.BodyMutation_Body{
105+
Body: test.wantBody,
106+
},
107+
},
102108
},
103109
},
104110
},

pkg/ext-proc/test/utils.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func StartExtProc(port int, refreshPodsInterval, refreshMetricsInterval time.Dur
2626
pms[pod.Pod] = pod
2727
}
2828
pmc := &backend.FakePodMetricsClient{Res: pms}
29-
pp := backend.NewProvider(pmc, &backend.K8sDatastore{Pods: &sync.Map{}})
29+
pp := backend.NewProvider(pmc, &backend.K8sDatastore{Pods: populatePodDatastore(pods)})
3030
if err := pp.Init(refreshPodsInterval, refreshMetricsInterval); err != nil {
3131
klog.Fatalf("failed to initialize: %v", err)
3232
}
@@ -78,3 +78,12 @@ func FakePod(index int) backend.Pod {
7878
}
7979
return pod
8080
}
81+
82+
func populatePodDatastore(pods []*backend.PodMetrics) *sync.Map {
83+
returnVal := &sync.Map{}
84+
85+
for _, pod := range pods {
86+
returnVal.Store(pod.Pod, true)
87+
}
88+
return returnVal
89+
}

0 commit comments

Comments
 (0)