gitaly/server: Fix leaking Goroutine in server factory test
The tests for the Gitaly server factory that verify the order in which specific listeners are closed are using various different blocking RPC calls to see which one completes first. These blocking RPC calls are spawned in separate Goroutines, but the test does not synchronize with all of these Goroutines to actually complete before the test case exits. This causes a flake where one of the Goroutines sometimes observes the context cancellation instead of the intended error:
panic: Log in goroutine after TestGitalyServerFactory_closeOrder has completed:
Error Trace: /builds/gitlab-org/gitaly/internal/gitaly/server/grpc.go:41
/builds/gitlab-org/gitaly/internal/gitaly/server/grpc.go:69
/builds/gitlab-org/gitaly/internal/gitaly/server/server_factory_test.go:222
/builds/gitlab-org/gitaly/internal/gitaly/server/asm_amd64.s:1594
Error: Should be empty, but was (*status.Status)(Inverse(protocmp.Transform, protocmp.Message{
"@type": s"google.rpc.Status",
- "code": int32(13),
+ "code": int32(1),
- "message": string("blocking RPC"),
+ "message": string("context canceled"),
}))
Fix this bug by properly waiting for all Goroutines to exit before returning from the test.