Skip to content

hooks: Fix flaky test on MacOS

Will Chandler (ex-GitLab) requested to merge wc/macos-hook-err into master

We have observed intermittent failures on TestServer_PackObjectsHook_separateContext on our MacOS runners. The error occurs ~10% of the time on MacOS, but has been completely unreproducible on Linux.

This appears to be a long-standing issue with FreeBSD, dating back to 2005, which MacOS has inherited. Unix domain sockets that are closed after a partial read may return ENOTCONN when read, instead of EPIPE as seen on Linux. This is exactly the scenario performed in this test.

Using the original reproduction script provided in the linked bug report, the ENOTCONN issue occurs ~10% of the time, matching Gitaly's failure rate.

Given that this functionality works as expected on Linux and the OS itself is what is non-deterministic, the simplest fix is to accept either EPIPE or ENOTCONN when on MacOS. We are forced to check for the expected error string instead of errors.Is(err, syscall.ENOTCONN) as the syscall information is lost when the error is returned over gRPC to the test program.

Closes #4806 (closed)

Edited by Will Chandler (ex-GitLab)

Merge request reports