Skip to content

Commit 1f7ff92

Browse files
committed
update port-forwarder
1 parent 5e19b3d commit 1f7ff92

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

test/integration/k8s_test.go

+10-12
Original file line numberDiff line numberDiff line change
@@ -166,26 +166,26 @@ func TestPodScaling(t *testing.T) {
166166
clusterCheckCtx, cancel := context.WithTimeout(ctx, 20*time.Minute)
167167
defer cancel()
168168

169-
pfOpts := PortForwardingOpts{
170-
Namespace: "default",
171-
LabelSelector: "type=goldpinger-pod",
172-
LocalPort: 9090,
173-
DestPort: 8080,
174-
}
169+
Namespace := "default"
170+
LabelSelector := "type=goldpinger-pod"
171+
LocalPort := 9090
172+
DestPort := 8080
175173

176174
pingCheckFn := func() error {
177-
pf, err := NewPortForwarder(restConfig, t, pfOpts)
175+
pf, err := NewPortForwarder(restConfig)
178176
if err != nil {
179177
t.Fatalf("could not build port forwarder: %v", err)
180178
}
181179

182180
portForwardCtx, cancel := context.WithTimeout(ctx, (retryAttempts+1)*retryDelaySec)
183181
defer cancel()
184182

183+
var handle PortForwardStreamHandle
185184
portForwardFn := func() error {
186185
t.Log("attempting port forward")
187186

188-
if err := pf.Forward(portForwardCtx); err != nil {
187+
handle, err = pf.ForwardWithLabelSelector(portForwardCtx, Namespace, LabelSelector, LocalPort, DestPort)
188+
if err != nil {
189189
return fmt.Errorf("could not start port forward: %w", err)
190190
}
191191

@@ -196,11 +196,9 @@ func TestPodScaling(t *testing.T) {
196196
t.Fatalf("could not start port forward within %v: %v", retryDelaySec.String(), err)
197197
}
198198

199-
go pf.KeepAlive(clusterCheckCtx)
200-
201-
defer pf.Stop()
199+
defer handle.Stop()
202200

203-
gpClient := goldpinger.Client{Host: pf.Address()}
201+
gpClient := goldpinger.Client{Host: handle.URL()}
204202

205203
clusterState, err := gpClient.CheckAll(clusterCheckCtx)
206204
if err != nil {

0 commit comments

Comments
 (0)