Skip to content

Commit c7648f5

Browse files
committed
Deflake port-forward e2e test
We should read and verify the data before actually closing the connection to avoid connection based-races within the test. Signed-off-by: Sascha Grunert <[email protected]>
1 parent 7094849 commit c7648f5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/e2e/kubectl/portforward.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,6 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework)
322322
ginkgo.By("Sending the expected data to the local port")
323323
fmt.Fprint(conn, "abc")
324324

325-
ginkgo.By("Closing the write half of the client's connection")
326-
if err = conn.CloseWrite(); err != nil {
327-
framework.Failf("Couldn't close the write half of the client's connection: %v", err)
328-
}
329-
330325
ginkgo.By("Reading data from the local port")
331326
fromServer, err := ioutil.ReadAll(conn)
332327
if err != nil {
@@ -343,6 +338,11 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework)
343338
framework.Failf("Expected %q from server, got %q", e, a)
344339
}
345340

341+
ginkgo.By("Closing the write half of the client's connection")
342+
if err = conn.CloseWrite(); err != nil {
343+
framework.Failf("Couldn't close the write half of the client's connection: %v", err)
344+
}
345+
346346
ginkgo.By("Waiting for the target pod to stop running")
347347
if err := WaitForTerminatedContainer(f, pod, "portforwardtester"); err != nil {
348348
framework.Failf("Container did not terminate: %v", err)

0 commit comments

Comments
 (0)