Skip to content

streamcache: Improve test for pipe backpressure

One of our streamcache tests verifies that the backpressure blocks the writer until readers consume its output. This test is flaky though as we wait for 10ms to have read the first two bytes, but some of our testing machines are seemingly slow enough to not catch up in time:

=== FAIL: internal/streamcache TestPipe_backpressure (1.00s)
    pipe_test.go:139:
                Error Trace:	/Users/gitlab/builds/gitlab-org/gitaly/internal/streamcache/pipe_test.go:139
                Error:      	Not equal:
                                expected: 2
                                actual  : 1
                Test:       	TestPipe_backpressure
                Messages:   	writer should be blocked after 2 bytes

While it would be great to fix this test so that we don't need any timeouts in the first place, I have no idea how to achieve this as we are essentially waiting for something to not happen. So instead, let's just extend the timeout to wait for the event to happen for a full minute and then check we're not making further progress afterwards for another 10 milliseconds.

Merge request reports