diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-08-11 13:34:05 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-09-23 10:02:55 +0300 |
commit | de1d44320173415fcdba41a2b768b08bd6f3aa93 (patch) | |
tree | 73d69f72300b8bede5f7ab6ecda2725f4eb5610a /internal/gitaly/server/auth_test.go | |
parent | 6a5cb67aae77eb8167161bb3b027defdc96caf8f (diff) |
grpc: Fix missing error checks for `Serve()` function
The `grpc.Server.Serve()` function will return an error when the gRPC
server has either failed unexpectedly or in case it wasn't properly shut
down. We don't check this error in many places though, which both causes
the errcheck linter to complain and hides issues we have with some of
our test setups.
Fix the missing error checks via a new `testhelper.MustServe()` helper
function that does the error checking for us. This surfaces some test
errors for tests that forget to shut down the server or that manually
close the listener, which should be handled by gRPC itself. All of those
errors are fixed while at it.
Drop the corresponding linting exceptions.
Diffstat (limited to 'internal/gitaly/server/auth_test.go')
-rw-r--r-- | internal/gitaly/server/auth_test.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/internal/gitaly/server/auth_test.go b/internal/gitaly/server/auth_test.go index 7cd8d9efa..a997282cb 100644 --- a/internal/gitaly/server/auth_test.go +++ b/internal/gitaly/server/auth_test.go @@ -225,7 +225,7 @@ func runServer(t *testing.T, cfg config.Cfg) string { listener, err := net.Listen("unix", serverSocketPath) require.NoError(t, err) t.Cleanup(srv.Stop) - go srv.Serve(listener) + go testhelper.MustServe(t, srv, listener) return "unix://" + serverSocketPath } @@ -256,7 +256,7 @@ func runSecureServer(t *testing.T, cfg config.Cfg) string { listener, hostPort := testhelper.GetLocalhostListener(t) t.Cleanup(srv.Stop) - go srv.Serve(listener) + go testhelper.MustServe(t, srv, listener) return hostPort } |