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>2020-11-23 14:49:00 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2020-11-26 10:14:26 +0300
commit878c8264888eae464aaa51ec33ce60b16d2dbb61 (patch)
tree049f1e409af90fd04af74f11f202b0b9f73e1877 /internal/gitaly/service/repository/fetch_test.go
parent07cad30a5ea4cb294cb81039539f103f8218b546 (diff)
repository: Set up hook service
The repository tests currently don't execute any hooks. This is about to change when we globally enable execution of the reference-transaction hook, but as we don't have the hook service correctly set up this would cause tests to fail for this service. Fix the issue by setting up the hook service on Gitaly's internal socket and installing the gitaly-hooks binary. Ideally, we'd just set up the internal socket once and for all in `runRepoServer()`. But for reasons I wasn't able to figure out, this would cause test failures with Praefect due to the internal listening socket not being closed somewhere.
Diffstat (limited to 'internal/gitaly/service/repository/fetch_test.go')
-rw-r--r--internal/gitaly/service/repository/fetch_test.go18
1 files changed, 16 insertions, 2 deletions
diff --git a/internal/gitaly/service/repository/fetch_test.go b/internal/gitaly/service/repository/fetch_test.go
index 425ddf195..c25a9c21b 100644
--- a/internal/gitaly/service/repository/fetch_test.go
+++ b/internal/gitaly/service/repository/fetch_test.go
@@ -9,7 +9,9 @@ import (
"gitlab.com/gitlab-org/gitaly/client"
gitLog "gitlab.com/gitlab-org/gitaly/internal/git/log"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/hook"
serverPkg "gitlab.com/gitlab-org/gitaly/internal/gitaly/server"
+ hookservice "gitlab.com/gitlab-org/gitaly/internal/gitaly/service/hook"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/repository"
"gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/internal/storage"
@@ -386,7 +388,9 @@ func newTestRepo(t *testing.T, locator storage.Locator, relativePath string) (*g
func runFullServer(t *testing.T) (string, func()) {
conns := client.NewPool()
- server := serverPkg.NewInsecure(repository.RubyServer, nil, config.Config, conns)
+ hookManager := hook.NewManager(hook.GitlabAPIStub, config.Config)
+
+ server := serverPkg.NewInsecure(repository.RubyServer, hookManager, config.Config, conns)
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
@@ -408,16 +412,26 @@ func runFullServer(t *testing.T) (string, func()) {
func runFullSecureServer(t *testing.T) (*grpc.Server, string, testhelper.Cleanup) {
conns := client.NewPool()
- server := serverPkg.NewSecure(repository.RubyServer, nil, config.Config, conns)
+ hookManager := hook.NewManager(hook.GitlabAPIStub, config.Config)
+
+ server := serverPkg.NewSecure(repository.RubyServer, hookManager, config.Config, conns)
listener, addr := testhelper.GetLocalhostListener(t)
errQ := make(chan error)
+ // This creates a secondary GRPC server which isn't "secure". Reusing
+ // the one created above won't work as its internal socket would be
+ // protected by the same TLS certificate.
+ internalServer := testhelper.NewServer(t, nil, nil, testhelper.WithInternalSocket(config.Config))
+ gitalypb.RegisterHookServiceServer(internalServer.GrpcServer(), hookservice.NewServer(config.Config, hookManager))
+ require.NoError(t, internalServer.Start())
+
go func() { errQ <- server.Serve(listener) }()
cleanup := func() {
conns.Close()
server.Stop()
+ internalServer.Stop()
require.NoError(t, <-errQ)
}