From 5b1bdf949019b805b11bb66492d7a8ef3c7e6f7b Mon Sep 17 00:00:00 2001 From: Ygal Blum Date: Wed, 11 Jan 2023 18:21:15 +0200 Subject: [PATCH] E2E Test: Play Kube set deadline to connection to avoid hangs Signed-off-by: Ygal Blum --- test/e2e/play_kube_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 336e3b47ef..92ffb3f15f 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -1689,12 +1689,15 @@ func testHTTPServer(port string, shouldErr bool, expectedResponse string) { Expect(string(body)).Should(Equal(expectedResponse)) } -func testEchoServer(connection io.ReadWriter) { +func testEchoServer(connection net.Conn) { stringToSend := "hello world" var err error var bytesSent int + interval := 250 * time.Millisecond - for i := 0; i < 6; i++ { + for i := 0; i < 5; i++ { + err = connection.SetDeadline(time.Now().Add(time.Second)) + Expect(err).To(BeNil()) bytesSent, err = fmt.Fprint(connection, stringToSend) if err == nil { break @@ -1708,7 +1711,9 @@ func testEchoServer(connection io.ReadWriter) { stringReceived := make([]byte, bytesSent) var bytesRead int interval = 250 * time.Millisecond - for i := 0; i < 6; i++ { + for i := 0; i < 5; i++ { + err = connection.SetDeadline(time.Now().Add(time.Second)) + Expect(err).To(BeNil()) bytesRead, err = bufio.NewReader(connection).Read(stringReceived) if err == nil { break