smarthttp: Fix test race where response buffer may not be filled
We have observed a racy test in production where fetching a hidden ref
via PostUploadPack
isn't failing in the way we expect it to. While the
error code is there and the RPC call itself has failed, the response
buffer we see is completely empty.
This race can easily be caused by our testing infrastructure though: we
use makePostUploadPackWithSidechannelRequest()
to set up a sidechannel
and then copy the sidechannel data via a separate Goroutine. In case we
see an error though while handling the sidechannel (which is the case:
we expect to fail fetching the hidden ref), we don't synchronize with
the Goroutine copying the response.
Fix this race by properly synchronizing the Goroutine via a wait group.
See e.g. https://gitlab.com/gitlab-org/gitaly/-/jobs/2263914720 for the race.