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:
authorJohn Cai <jcai@gitlab.com>2020-03-10 16:51:51 +0300
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2020-03-10 16:51:51 +0300
commit1aecc5095d6ccc02d247614c8a9c2c4aaa5dfbee (patch)
tree87bbf69812b03eeb90dc99b2f375bacd9bf70417
parentc15501dab93e99647c28f295ed3441712a30f510 (diff)
Dependency inject internal gitaly socket into repository server struct
-rw-r--r--internal/praefect/helper_test.go13
-rw-r--r--internal/praefect/replicator_test.go2
-rw-r--r--internal/service/register.go2
-rw-r--r--internal/service/repository/replicate.go3
-rw-r--r--internal/service/repository/replicate_test.go2
-rw-r--r--internal/service/repository/server.go9
-rw-r--r--internal/service/repository/testhelper_test.go2
7 files changed, 19 insertions, 14 deletions
diff --git a/internal/praefect/helper_test.go b/internal/praefect/helper_test.go
index d236cefff..b87e404db 100644
--- a/internal/praefect/helper_test.go
+++ b/internal/praefect/helper_test.go
@@ -235,15 +235,17 @@ func runInternalGitalyServer(t *testing.T, token string) (*grpc.Server, string,
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
listener, err := net.Listen("unix", serverSocketPath)
- if err != nil {
- t.Fatal(err)
- }
+ require.NoError(t, err)
+
+ internalSocket := testhelper.GetTemporaryGitalySocketFileName()
+ internalListener, err := net.Listen("unix", internalSocket)
+ require.NoError(t, err)
rubyServer := &rubyserver.Server{}
require.NoError(t, rubyServer.Start())
gitalypb.RegisterServerServiceServer(server, gitalyserver.NewServer())
- gitalypb.RegisterRepositoryServiceServer(server, repository.NewServer(rubyServer))
+ gitalypb.RegisterRepositoryServiceServer(server, repository.NewServer(rubyServer, internalSocket))
healthpb.RegisterHealthServer(server, health.NewServer())
errQ := make(chan error)
@@ -251,6 +253,9 @@ func runInternalGitalyServer(t *testing.T, token string) (*grpc.Server, string,
go func() {
errQ <- server.Serve(listener)
}()
+ go func() {
+ errQ <- server.Serve(internalListener)
+ }()
cleanup := func() {
rubyServer.Stop()
diff --git a/internal/praefect/replicator_test.go b/internal/praefect/replicator_test.go
index 72a1c43ea..ca124a7e0 100644
--- a/internal/praefect/replicator_test.go
+++ b/internal/praefect/replicator_test.go
@@ -488,7 +488,7 @@ func newReplicationService(tb testing.TB) (*grpc.Server, string) {
svr := testhelper.NewTestGrpcServer(tb, nil, nil)
- gitalypb.RegisterRepositoryServiceServer(svr, repository.NewServer(&rubyserver.Server{}))
+ gitalypb.RegisterRepositoryServiceServer(svr, repository.NewServer(&rubyserver.Server{}, gitaly_config.GitalyInternalSocketPath()))
gitalypb.RegisterObjectPoolServiceServer(svr, objectpoolservice.NewServer())
gitalypb.RegisterRemoteServiceServer(svr, remote.NewServer(&rubyserver.Server{}))
reflection.Register(svr)
diff --git a/internal/service/register.go b/internal/service/register.go
index 2db6901d7..992ebee45 100644
--- a/internal/service/register.go
+++ b/internal/service/register.go
@@ -36,7 +36,7 @@ func RegisterAll(grpcServer *grpc.Server, rubyServer *rubyserver.Server) {
gitalypb.RegisterNamespaceServiceServer(grpcServer, namespace.NewServer())
gitalypb.RegisterOperationServiceServer(grpcServer, operations.NewServer(rubyServer))
gitalypb.RegisterRefServiceServer(grpcServer, ref.NewServer())
- gitalypb.RegisterRepositoryServiceServer(grpcServer, repository.NewServer(rubyServer))
+ gitalypb.RegisterRepositoryServiceServer(grpcServer, repository.NewServer(rubyServer, config.GitalyInternalSocketPath()))
gitalypb.RegisterSSHServiceServer(grpcServer, ssh.NewServer())
gitalypb.RegisterSmartHTTPServiceServer(grpcServer, smarthttp.NewServer())
gitalypb.RegisterWikiServiceServer(grpcServer, wiki.NewServer(rubyServer))
diff --git a/internal/service/repository/replicate.go b/internal/service/repository/replicate.go
index 6fcfbb6b7..35080fafc 100644
--- a/internal/service/repository/replicate.go
+++ b/internal/service/repository/replicate.go
@@ -13,7 +13,6 @@ import (
gitalyauth "gitlab.com/gitlab-org/gitaly/auth"
"gitlab.com/gitlab-org/gitaly/client"
"gitlab.com/gitlab-org/gitaly/internal/command"
- "gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/helper"
"gitlab.com/gitlab-org/gitaly/internal/safe"
"gitlab.com/gitlab-org/gitaly/internal/tempdir"
@@ -226,7 +225,7 @@ func (s *server) syncInfoAttributes(ctx context.Context, in *gitalypb.ReplicateR
// newRemoteClient creates a new RemoteClient that talks to the same gitaly server
func (s *server) newRemoteClient() (gitalypb.RemoteServiceClient, error) {
- cc, err := s.getOrCreateConnection(fmt.Sprintf("unix:%s", config.GitalyInternalSocketPath()), "")
+ cc, err := s.getOrCreateConnection(fmt.Sprintf("unix:%s", s.internalGitalySocket), "")
if err != nil {
return nil, err
}
diff --git a/internal/service/repository/replicate_test.go b/internal/service/repository/replicate_test.go
index 7c8524cd8..3e8b5a6f7 100644
--- a/internal/service/repository/replicate_test.go
+++ b/internal/service/repository/replicate_test.go
@@ -325,7 +325,7 @@ func runServerWithBadFetchInternalRemote(t *testing.T) (*grpc.Server, string) {
internalListener, err := net.Listen("unix", config.GitalyInternalSocketPath())
require.NoError(t, err)
- gitalypb.RegisterRepositoryServiceServer(server, repository.NewServer(repository.RubyServer))
+ gitalypb.RegisterRepositoryServiceServer(server, repository.NewServer(repository.RubyServer, config.GitalyInternalSocketPath()))
gitalypb.RegisterRemoteServiceServer(server, &mockRemoteServer{})
reflection.Register(server)
diff --git a/internal/service/repository/server.go b/internal/service/repository/server.go
index 2b4bb737a..563b9c2a1 100644
--- a/internal/service/repository/server.go
+++ b/internal/service/repository/server.go
@@ -13,13 +13,14 @@ import (
type server struct {
ruby *rubyserver.Server
gitalypb.UnimplementedRepositoryServiceServer
- connsByAddress map[string]*grpc.ClientConn
- connsMtx sync.RWMutex
+ connsByAddress map[string]*grpc.ClientConn
+ connsMtx sync.RWMutex
+ internalGitalySocket string
}
// NewServer creates a new instance of a gRPC repo server
-func NewServer(rs *rubyserver.Server) gitalypb.RepositoryServiceServer {
- return &server{ruby: rs, connsByAddress: make(map[string]*grpc.ClientConn)}
+func NewServer(rs *rubyserver.Server, internalGitalySocket string) gitalypb.RepositoryServiceServer {
+ return &server{ruby: rs, connsByAddress: make(map[string]*grpc.ClientConn), internalGitalySocket: internalGitalySocket}
}
func (*server) FetchHTTPRemote(context.Context, *gitalypb.FetchHTTPRemoteRequest) (*gitalypb.FetchHTTPRemoteResponse, error) {
diff --git a/internal/service/repository/testhelper_test.go b/internal/service/repository/testhelper_test.go
index 37c5e6d89..d377ceac2 100644
--- a/internal/service/repository/testhelper_test.go
+++ b/internal/service/repository/testhelper_test.go
@@ -84,7 +84,7 @@ func runRepoServer(t *testing.T) (*grpc.Server, string) {
t.Fatal(err)
}
- gitalypb.RegisterRepositoryServiceServer(server, NewServer(RubyServer))
+ gitalypb.RegisterRepositoryServiceServer(server, NewServer(RubyServer, config.GitalyInternalSocketPath()))
reflection.Register(server)
go server.Serve(listener)