Skip to content

Commit a4a1221

Browse files
authored
Attempt to fix flaky handover test (#3822)
## Changes Use fewer messages, increase waiting for writes timeouts, and add don't-buffer-output flag to the `cat` command for the test server. ## Why Failed handover test run: https://github.com/databricks/cli/actions/runs/18774560101/job/53566106289
1 parent 14e8e43 commit a4a1221

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

experimental/ssh/internal/proxy/client_server_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ func createTestServer(t *testing.T, maxClients int, shutdownDelay time.Duration)
2525
connections := NewConnectionsManager(maxClients, shutdownDelay)
2626
proxyServer := NewProxyServer(ctx, connections, func(ctx context.Context) *exec.Cmd {
2727
// 'cat' command reads each line from stdin and sends it to stdout, so we can test end-to-end proxying.
28-
return exec.CommandContext(ctx, "cat")
28+
// '-u' option is used to disable output buffering.
29+
return exec.CommandContext(ctx, "cat", "-u")
2930
})
3031
return httptest.NewServer(proxyServer)
3132
}

experimental/ssh/internal/proxy/proxy_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ type testBuffer struct {
2525
}
2626

2727
const (
28-
MESSAGE_CHUNKS = 5
29-
MESSAGES_PER_CHUNK = 1024
28+
MESSAGE_CHUNKS = 4
29+
MESSAGES_PER_CHUNK = 512
3030
TOTAL_MESSAGE_COUNT = MESSAGE_CHUNKS * MESSAGES_PER_CHUNK
3131
)
3232

@@ -61,7 +61,7 @@ func (tb *testBuffer) AssertWrite(expected []byte) error {
6161
case data := <-tb.OnWrite:
6262
assert.Equal(tb.t, expected, data)
6363
return nil
64-
case <-time.After(2 * time.Second):
64+
case <-time.After(3 * time.Second):
6565
return errors.New("timeout waiting for write, was expecting: " + string(expected))
6666
}
6767
}
@@ -79,7 +79,7 @@ func (tb *testBuffer) WaitForWrite(expected []byte) error {
7979
if tb.Contains(expected) {
8080
return nil
8181
}
82-
case <-time.After(2 * time.Second):
82+
case <-time.After(3 * time.Second):
8383
return errors.New("timeout waiting for write")
8484
}
8585
}

0 commit comments

Comments
 (0)