From c7648f598403e7a19d5d8e7973888f37dadecd0b Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Wed, 13 May 2020 08:53:28 +0200 Subject: [PATCH] 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 --- test/e2e/kubectl/portforward.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/e2e/kubectl/portforward.go b/test/e2e/kubectl/portforward.go index 934c60c3513..1e5b9048c76 100644 --- a/test/e2e/kubectl/portforward.go +++ b/test/e2e/kubectl/portforward.go @@ -322,11 +322,6 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework) ginkgo.By("Sending the expected data to the local port") fmt.Fprint(conn, "abc") - ginkgo.By("Closing the write half of the client's connection") - if err = conn.CloseWrite(); err != nil { - framework.Failf("Couldn't close the write half of the client's connection: %v", err) - } - ginkgo.By("Reading data from the local port") fromServer, err := ioutil.ReadAll(conn) if err != nil { @@ -343,6 +338,11 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework) framework.Failf("Expected %q from server, got %q", e, a) } + ginkgo.By("Closing the write half of the client's connection") + if err = conn.CloseWrite(); err != nil { + framework.Failf("Couldn't close the write half of the client's connection: %v", err) + } + ginkgo.By("Waiting for the target pod to stop running") if err := WaitForTerminatedContainer(f, pod, "portforwardtester"); err != nil { framework.Failf("Container did not terminate: %v", err)