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:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2023-03-14 14:25:08 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-03-16 18:38:13 +0300
commit3f4a38d3be459453c9ce8edbe8944cee5acbb04b (patch)
tree0724094a0182f01f8edc51ece2eb95982e081919
parentfabe1695e5247ea69b2578a8b6b1436fc9ec764f (diff)
gittest: Support TCP and TLS connections when dialing server
The gittest package needs to connect to the gRPC server when either creating repositories via the Repository service or when retrieving the replica path of a repository. Both of these usecases are implemented via `dialService()`, which right now only supports connecting to a server that is listening on its socket path. This restricts the usefulness of this option for tests which use a different server configuration. Improve the logic to also support dialing of servers that listen on either the TCP or the TLS socket. While at it, mark the function as a test helper.
-rw-r--r--internal/git/gittest/repo.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/internal/git/gittest/repo.go b/internal/git/gittest/repo.go
index 208d189f8..3c7a91468 100644
--- a/internal/git/gittest/repo.go
+++ b/internal/git/gittest/repo.go
@@ -20,6 +20,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v15/internal/helper/perm"
"gitlab.com/gitlab-org/gitaly/v15/internal/helper/text"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
@@ -98,12 +99,26 @@ type CreateRepositoryConfig struct {
}
func dialService(tb testing.TB, ctx context.Context, cfg config.Cfg) *grpc.ClientConn {
+ tb.Helper()
+
dialOptions := []grpc.DialOption{internalclient.UnaryInterceptor(), internalclient.StreamInterceptor()}
if cfg.Auth.Token != "" {
dialOptions = append(dialOptions, grpc.WithPerRPCCredentials(gitalyauth.RPCCredentialsV2(cfg.Auth.Token)))
}
- conn, err := client.DialContext(ctx, cfg.SocketPath, dialOptions)
+ var addr string
+ switch {
+ case cfg.SocketPath != "" && cfg.SocketPath != testcfg.UnconfiguredSocketPath:
+ addr = cfg.SocketPath
+ case cfg.ListenAddr != "":
+ addr = cfg.ListenAddr
+ case cfg.TLSListenAddr != "":
+ addr = cfg.TLSListenAddr
+ default:
+ require.FailNow(tb, "cannot dial service without configured address")
+ }
+
+ conn, err := client.DialContext(ctx, addr, dialOptions)
require.NoError(tb, err)
return conn
}