@@ -166,26 +166,26 @@ func TestPodScaling(t *testing.T) {
166
166
clusterCheckCtx , cancel := context .WithTimeout (ctx , 20 * time .Minute )
167
167
defer cancel ()
168
168
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
175
173
176
174
pingCheckFn := func () error {
177
- pf , err := NewPortForwarder (restConfig , t , pfOpts )
175
+ pf , err := NewPortForwarder (restConfig )
178
176
if err != nil {
179
177
t .Fatalf ("could not build port forwarder: %v" , err )
180
178
}
181
179
182
180
portForwardCtx , cancel := context .WithTimeout (ctx , (retryAttempts + 1 )* retryDelaySec )
183
181
defer cancel ()
184
182
183
+ var handle PortForwardStreamHandle
185
184
portForwardFn := func () error {
186
185
t .Log ("attempting port forward" )
187
186
188
- if err := pf .Forward (portForwardCtx ); err != nil {
187
+ handle , err = pf .ForwardWithLabelSelector (portForwardCtx , Namespace , LabelSelector , LocalPort , DestPort )
188
+ if err != nil {
189
189
return fmt .Errorf ("could not start port forward: %w" , err )
190
190
}
191
191
@@ -196,11 +196,9 @@ func TestPodScaling(t *testing.T) {
196
196
t .Fatalf ("could not start port forward within %v: %v" , retryDelaySec .String (), err )
197
197
}
198
198
199
- go pf .KeepAlive (clusterCheckCtx )
200
-
201
- defer pf .Stop ()
199
+ defer handle .Stop ()
202
200
203
- gpClient := goldpinger.Client {Host : pf . Address ()}
201
+ gpClient := goldpinger.Client {Host : handle . URL ()}
204
202
205
203
clusterState , err := gpClient .CheckAll (clusterCheckCtx )
206
204
if err != nil {
0 commit comments