Skip to content

Commit c5b4ee2

Browse files
committed
replace ktesting with explicit calls
Signed-off-by: Etai Lev Ran <elevran@gmail.com>
1 parent ea0a0cb commit c5b4ee2

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

pkg/sidecar/proxy/connector_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"github.com/llm-d/llm-d-inference-scheduler/test/sidecar/mock"
3131
. "github.com/onsi/ginkgo/v2" // nolint:revive
3232
. "github.com/onsi/gomega" // nolint:revive
33-
"k8s.io/klog/v2/ktesting"
3433
)
3534

3635
type sidecarTestInfo struct {
@@ -180,7 +179,7 @@ var _ = Describe("Common Connector tests", func() {
180179
func sidecarConnectionTestSetup(connector string) *sidecarTestInfo {
181180
testInfo := sidecarTestInfo{}
182181

183-
_, testInfo.ctx = ktesting.NewTestContext(GinkgoT())
182+
testInfo.ctx = newTestContext()
184183
testInfo.ctx, testInfo.cancelFn = context.WithCancel(testInfo.ctx)
185184
testInfo.stoppedCh = make(chan struct{})
186185

pkg/sidecar/proxy/data_parallel_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
. "github.com/onsi/ginkgo/v2" // nolint:revive
1111
. "github.com/onsi/gomega" // nolint:revive
1212
"golang.org/x/sync/errgroup"
13-
"k8s.io/klog/v2/ktesting"
1413

1514
"github.com/llm-d/llm-d-inference-scheduler/pkg/common"
1615
sidecarmock "github.com/llm-d/llm-d-inference-scheduler/test/sidecar/mock"
@@ -24,7 +23,7 @@ const (
2423
var _ = Describe("Data Parallel support", func() {
2524
When("configured with --data-parallel-size > 1", func() {
2625
It("should create an extra proxy", func() {
27-
_, ctx := ktesting.NewTestContext(GinkgoT())
26+
ctx := newTestContext()
2827
ctx, cancel := context.WithCancel(ctx)
2928
grp, ctx := errgroup.WithContext(ctx)
3029

pkg/sidecar/proxy/proxy_test.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,34 @@ import (
2626
"strings"
2727
"time"
2828

29+
"sigs.k8s.io/controller-runtime/pkg/log"
30+
ctrllog "sigs.k8s.io/controller-runtime/pkg/log"
31+
"sigs.k8s.io/controller-runtime/pkg/log/zap"
32+
2933
"github.com/llm-d/llm-d-inference-scheduler/pkg/common"
3034
"github.com/llm-d/llm-d-inference-scheduler/test/sidecar/mock"
3135
. "github.com/onsi/ginkgo/v2" // nolint:revive
3236
. "github.com/onsi/gomega" // nolint:revive
33-
"k8s.io/klog/v2/ktesting"
3437
)
3538

39+
func newTestContext() context.Context {
40+
logger := zap.New(
41+
zap.WriteTo(GinkgoWriter),
42+
zap.UseDevMode(true),
43+
)
44+
ctrllog.SetLogger(logger)
45+
ctx := context.Background()
46+
log.IntoContext(ctx, logger) // not strictly needed since we called SetLogger to set default
47+
return ctx
48+
}
49+
3650
var _ = Describe("Reverse Proxy", func() {
3751
When("x-prefiller-url is not present", func() {
3852
DescribeTable("should forward requests to decode server",
3953

4054
func(path string, secureProxy bool) {
41-
_, ctx := ktesting.NewTestContext(GinkgoT())
4255

56+
ctx := newTestContext()
4357
var cert *tls.Certificate
4458
if secureProxy {
4559
tempCert, err := CreateSelfSignedTLSCertificate()
@@ -159,7 +173,7 @@ var _ = Describe("Reverse Proxy", func() {
159173
})
160174

161175
It("should successfully send request to 1. prefill 2. decode with the right fields (backward compatible behavior)", func() {
162-
_, ctx := ktesting.NewTestContext(GinkgoT())
176+
ctx := newTestContext()
163177
ctx, cancelFn := context.WithCancel(ctx)
164178
stoppedCh := make(chan struct{})
165179

@@ -233,7 +247,7 @@ var _ = Describe("Reverse Proxy", func() {
233247
})
234248

235249
It("should successfully send request to 1. prefill 2. decode with the right fields", func() {
236-
_, ctx := ktesting.NewTestContext(GinkgoT())
250+
ctx := newTestContext()
237251
ctx, cancelFn := context.WithCancel(ctx)
238252
stoppedCh := make(chan struct{})
239253

0 commit comments

Comments
 (0)