diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-10-08 13:43:07 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-10-08 17:10:02 +0300 |
commit | a45fdc156a66216a0bd892efb82e896652b0c178 (patch) | |
tree | dcf6f1496ff90c0c92d90e7363d7666aa2b9e204 | |
parent | fc0e04c1f01d19056b07948c8b845f992fa65922 (diff) |
testserver: Use "client" package to dial health server
We're using the grpc package directly to dial to the health server when
waiting for it to become healthy. This dialer doesn't know to set up
various things for us: it doesn't understand the "tcp://" and "tls://"
schemas, it won't handle setup of transport credentials and doesn't set
up interceptors. This has worked fine until now because we only used it
to check the Praefect server's health, but it will fail as soon as we
want to also check the Gitaly server's health.
Use our own "client" package to dial the health service such that we can
extend support for `waitHealthy()` to Gitaly servers.
-rw-r--r-- | internal/testhelper/testserver/gitaly.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/internal/testhelper/testserver/gitaly.go b/internal/testhelper/testserver/gitaly.go index 197a2a1aa..4ba091c19 100644 --- a/internal/testhelper/testserver/gitaly.go +++ b/internal/testhelper/testserver/gitaly.go @@ -186,7 +186,7 @@ func StartGitalyServer(t testing.TB, cfg config.Cfg, rubyServer *rubyserver.Serv // waitHealthy waits until the server hosted at address becomes healthy. Times out after a fixed // amount of time. func waitHealthy(t testing.TB, cfg config.Cfg, addr string) { - grpcOpts := []grpc.DialOption{grpc.WithInsecure()} + var grpcOpts []grpc.DialOption if cfg.Auth.Token != "" { grpcOpts = append(grpcOpts, grpc.WithPerRPCCredentials(gitalyauth.RPCCredentialsV2(cfg.Auth.Token))) } @@ -194,7 +194,7 @@ func waitHealthy(t testing.TB, cfg config.Cfg, addr string) { ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) defer cancel() - conn, err := grpc.DialContext(ctx, addr, grpcOpts...) + conn, err := client.DialContext(ctx, addr, grpcOpts) require.NoError(t, err) defer testhelper.MustClose(t, conn) |