Skip to content

Commit

Permalink
Merge pull request #17083 from ygalblum/kube-port-test-set-deadline
Browse files Browse the repository at this point in the history
E2E Test: Play Kube set deadline to connection to avoid hangs
  • Loading branch information
openshift-merge-robot authored Jan 11, 2023
2 parents f70233a + 5b1bdf9 commit 8a0d25f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/e2e/play_kube_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 8a0d25f

Please sign in to comment.