Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavlo Strokov <pstrokov@gitlab.com>2022-08-20 13:12:41 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2022-08-22 16:44:19 +0300
commit6f0f7ce3b2f22a96d683772199f488e11d115cbc (patch)
tree87f19a1aee80494427fff0b6090dfca29561fc34
parent1988994e3ada7b5dac3e6677586bbcbe49a9800b (diff)
server factory: Wait for termination of all goroutinesps-flaky-server-factory
It happens that goroutine started to Serve() doesn't terminate after test completion and that fails the test (all started goroutines must be terminated on test completion). Now the test waits for all started goroutines to be terminated. The result returned from the Server() method is also controlled now and checked for correctness. Closes: https://gitlab.com/gitlab-org/gitaly/-/issues/3916
-rw-r--r--internal/gitaly/server/server_factory_test.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/internal/gitaly/server/server_factory_test.go b/internal/gitaly/server/server_factory_test.go
index 6c964ca82..9a181089d 100644
--- a/internal/gitaly/server/server_factory_test.go
+++ b/internal/gitaly/server/server_factory_test.go
@@ -22,6 +22,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper/testcfg"
+ "golang.org/x/sync/errgroup"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
@@ -33,6 +34,8 @@ import (
func TestGitalyServerFactory(t *testing.T) {
ctx := testhelper.Context(t)
+ grp, ctx := errgroup.WithContext(ctx)
+ t.Cleanup(func() { assert.NoError(t, grp.Wait()) })
checkHealth := func(t *testing.T, sf *GitalyServerFactory, schema, addr string) healthpb.HealthClient {
t.Helper()
@@ -45,7 +48,7 @@ func TestGitalyServerFactory(t *testing.T) {
listener, err := net.Listen(starter.TCP, addr)
require.NoError(t, err)
- go srv.Serve(listener)
+ grp.Go(func() error { return srv.Serve(listener) })
certPool, err := x509.SystemCertPool()
require.NoError(t, err)
@@ -67,7 +70,7 @@ func TestGitalyServerFactory(t *testing.T) {
listener, err := net.Listen(schema, addr)
require.NoError(t, err)
- go srv.Serve(listener)
+ grp.Go(func() error { return srv.Serve(listener) })
endpoint, err := starter.ComposeEndpoint(schema, listener.Addr().String())
require.NoError(t, err)