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
AgeCommit message (Collapse)Author
2022-08-11services: Don't needlessly skip repo creation via APIPatrick Steinhardt
While it makes sense for tests to skip repository creation via the `CreateRepository()` RPC when they are not testing in a context where they have a gRPC server available, there should in the general case not be a reason to skip this in our service-related tests. There still is a bunch of tests that do this though. Adjust the tests to not skip the RPC calls to create the repository and refactor some that didn't make the server address available via the Gitaly configuration. Note that we need to some touch up some tests which erroneously created the repository multiple times, which would now fail with Praefect.
2022-08-11gittest: Convert callers of CloneRepo to use CreateRepositoryPatrick Steinhardt
Convert all callers of CloneRepo to use CreateRepository.
2022-07-18test: Disable all test with tag sha256Toon Claes
We're about to add the ability to test with SHA256 hashes. We assume none of the tests work with this object format. With this change we add the build constraint to not run any test when the tag 'gitaly_test_sha256' is set.
2022-05-20Update go package name from v14 to v15John Cai
This commit changes the major version in the package name from v14 to v15 Updating go.mod & go.sum with new module name v15 Update Makefile to bump major version to v15 Update the gitaly package name in the Makefile. Also update gitaly-git2go-v14 -> gitaly-git2go-v15. We need to keep gitaly-git2go-v14 for a release however, for zero downtime upgrades. This pulls directly from a sha that is v14. Update package name from v14->v15 for auth, client, cmd, internal packages This commit changes the package name from v14 to v15 in go and proto files in the internal, auth, client, cmd packages. proto: Update major package number in package name tools: Change major version number in package name from v14 to v15 gitaly-git2go: Change the package name from v14 to v15 update module updater for v15 Update the documentation for the module updater to reflect v15
2022-02-28localrepo: Remove flag to switch to sidechannels for internal fetchesPatrick Steinhardt
In commit 8e5cb6419 (git: Convert internal fetches to use sidechannel, 2022-02-16), we have converted internalf teches to use the sidechannel. With this change, communication exchanged between git-upload-pack(1) and git-fetch(1) don't use gRPC encoding anymore, but instead use pkt-line encoding such that we can avoid having to serialize and deserialize lots of gRPC messages. This avoids the overhead induced by grpc-go and should thus reduce the load while serving an internal fetch. This change has been rolled out to production on February 23rd without any issues observed. Remove the feature flag to unconditionally enable use of the sidechannel. Changelog: changed
2022-02-16git: Convert internal fetches to use sidechannelPatrick Steinhardt
With commit b5722938b (Merge branch 'jv-ssh-sidechannel-2' into 'master', 2022-01-18) we have introduced a new RPC which allows us to serve SSH-based fetches with a sidechannel. Instead of using gRPC as a means for communicating between client and server we instead use a simple protocol based on pktlines, which allows us to avoid the overhead introduced by gRPC message serialization and deserialization. For now, use of the sidechannel is only enabled for external clients which come in via gitlab-shell. This commit adds the necessary infra to also use the sidechannel for internal fetches, which most importantly includes the RPCs ReplicateRepository, FetchSourceBranch and a subset of RPCs in the OperationService which know to fetch from a remote repository. The new code is guarded by a feature flag. Changelog: performance
2022-02-02Propagate test context to setup helpers in repository packageSami Hiltunen
setupRepositoryService is currently using a TODO context. This commit propagates the test context down from the tests to the setup helper.
2022-02-02Create repositories via API in most repository service testsSami Hiltunen
This commit creates the repositories in tests of repsository service via API. This enables the tests to work with Praefect without the metadata creation hack as Praefect can create the metadata when is proxies the creation calls. The tests converted in this commit are the ones where it was straighforward replacing, the rest will be done in more detailed follow up commits.
2022-01-27Automatically clean up testhelper.ContextSami Hiltunen
testhelper.Context() currently return a cancellation function as a second return value. Majority of the tests do not need to explicitly cancel the context but they simply defer its cancellation to clean up after the test. Given this, we can reduce the test verbosity and make testhelper.Context easier to compose by removing the unnecessary second return value. This adds a t.Cleanup function to automatically cancel the context at the end of the tests and omits the returned cancellation function. Tests which simply `defer cancel()` have had the extra call removed. Some tests explicitly call the cancellation, and these tests have been modified to add context.WithCancel around the testhelper.Context call. There are a few loctions where testing.TB was passed down to test helpers that create the context.
2021-12-06testhelper: Rename `RequireGrpcError()` to `RequireGrpcCode()`Patrick Steinhardt
The `RequireGrpcError()` helper function misleadingly doesn't check the error for equality, but instead only verifies that the error has the expected gRPC code. Rename the function to `RequireGrpcCode()` to clarify this.
2021-10-26testhelper: Move helper to get Gitaly server metadataPatrick Steinhardt
Move the helper to get Gitaly server metadata from the Gitaly config from the testhelper package into the testcfg package. This is required to break the dependency of the testhelper on `internal/gitaly/config`, such that this package can start to use the testhelper package.
2021-08-05gittest: Rename `CloneRepoAtStorage()` to `CloneRepo()`Patrick Steinhardt
Rename `CloneRepoAtStorage()` to `CloneRepo()`. We always have storages available, and there are no other gittest functions to clone a repo anymore, so having the shorter name should suffice.
2021-08-05gittest: Drop cleanup function from `CloneRepoAtStorage()`Patrick Steinhardt
`CloneRepoAtStorage()` currently returns a cleanup function. Since Go has `t.Cleanup()`, this is considered bad style, so let's remove it and convert all callers.
2021-08-05gittest: Make relative path of `CloneRepoAtStorage` optionalPatrick Steinhardt
Most tests don't really care about the relative path of the repository that is to be created. Furthermore, manually specifying a relative path will lead to repository paths outside of our typicaly hashed storage paths, and as thus they don't really match what we'd see in production. Put the relative path into an optional `CloneRepoOpts` structure: if unset, we'll compute random hashed storage-style repository paths. Most callers are converted to not pass a relative path at all, while a small bunch of tests which relies on deterministic paths are converted to use the options struct.
2021-06-29Parallel execution of the tests in the repository packagePavlo Strokov
To speed up execution of the tests we mark them allowed to run in parallel by calling t.Parallel(). As a first step we mark for parallel execution only upper-level test and no sub-tests.
2021-05-27Create module v14 gitaly versionPavlo Strokov
The new "v14" version of the Gitaly module is named to match the next GitLab release. The module versioning is needed in order to pull gitaly as a dependency in other projects. The change updates all imports to include v14 version. The go.mod file was modified as well after go mod tidy execution. And the changes in dependency licenses are reflected in the NOTICE file. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/3177
2021-05-17Break dependency of the CloneRepoAtStorage on the global config.ConfigPavlo Strokov
In order to get rid of the global variable config.Config we change CloneRepoAtStorage function to accept config.Cfg as an input parameter. We use locally defined instance of the config.Cfg type to call modified function, so the usage of it is no longer depend on the config.Config variable. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
2021-05-07gittest: Refactor interface to write commitsPatrick Steinhardt
The current interface to write commits is leaving a lot to be desired. It's inflexible, we have multiple functions which all do some specific things which others don't, and in general it's not a breeze to use. As a first step to improve it, this commit refactors `CreateCommit()`: instead of an options structure it now receives callback-like options and it is renamed to `WriteCommit()` to bring it in line with the other object-writing test helpers.
2021-05-05localrepo: Provide test helper to construct reposPatrick Steinhardt
It's really hard right now to add additional dependencies on the localrepo constructor given that it's used all over the place. To address one part of the problem, introduce a new test helper which constructs a `localrepo.Repo` given only a Gitaly config and a repository interface -- all other dependencies get created ad-hoc. Ideally, this would not be hosted in the localrepo package itself but in the gittest package, but this doesn't work due to cyclic dependencies. But given both the function name `NewTestRepo()` and that the function requires a `testing.T` interface as first parameter, it shouldn't really be possible to use it in production code.
2021-04-23Refactor fetch_test.goPavlo Strokov
The old test setup code is refactored to use the new setup functions. The TestFetchFullServerRequiresAuthentication test removed as it was just a sanity check for the test-setup code. Package changed from repository_test to repository, because circular dependency is broken with new test setup functions. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
2021-04-23Pop up config.Config from functions body to parametersPavlo Strokov
In order to break dependency on the global config.Config variable this change modifies the parameter list of the functions that use config.Config internally to accept it from the outside.
2021-04-21Change gittest.CreateCommit to use provided configurationPavlo Strokov
The function gittest.CreateCommit changed to accept configuration as an input parameter and now uses Exec and ExecStream functions internally to run git commands. All dependencies aligned on that change. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
2021-04-12Change registration of the gitaly services on the gRPC serverPavlo Strokov
Current project structure sometimes causes us a circular dependency issues. The main reason of it is RegisterAll function in the internal/gitaly/service package. It is a package on a higher level that imports packages from the deeper levels, like internal/gitaly/service/blob, etc. It is not an issue for the production code, but it causes troubles in the tests. The solution used so far was to use a separate package '<package>_test' for the tests. Other than that the old server setup doesn't use production code for the initialization. With RunGitalyServer helper we re-use production code for gRPC server setup and can register only required services on it. The dependencies services relies on could be overwritten with the optional parameters. All dependencies assembled into a single struct Dependencies for that purpose as well as to reduce amount of parameters to pass into the function call. The access to the dependencies is done via a GetXXX methods, so it is easy to replace it with interface and whatever implementation afterwards.
2021-04-07dependency inject backchannel registry into Gitaly componentsSami Hiltunen
This commit dependency injects a shared backchannel registry to the components that need it, namely the GitalyServerFactory and transaction manager.
2021-03-18Linguist converted into an instantiation dependencyPavlo Strokov
Implementation of the linguist package relies on the package-private state: the use of the colorMap variable. It is filled with a hook mechanism after validation of the gitaly configuration. The problem is that this operation invokes ruby code to get it done and this call is pretty expensive. It also doesn't allow us to convert tests to parallel as it causes race conditions in attempt to fill the global variable. The solution to this problem is creation of the struct instance that encapsulates the state and can be instantiated only when needed. The change also includes minification in generating test configuration that does not require to make a ruby call and uses a stub file for initialisation. The behaviour could be returned back to the normal with usage of the WithActualLinguist option for configuration creation. The change also includes renames of the test functions for the linguist package. The change speeds up execution of the tests: before 0m43.907s and after 0m21.659s on my local. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
2021-03-01testhelper: Move repository helpers into `gittest`Patrick Steinhardt
It's currently not possible to use our git DSL in the testhelper package because of an import cycle between the testhelper and git package. To fix this import cycle, we thus move test-related git helpers into the gittest package. This commit moves the repository helpers. As we're already touching all sites which use these helpers anyway, it also aligns functions to have more consistent naming.
2021-03-01testhelper: Move commit helpers into `gittest`Patrick Steinhardt
It's currently not possible to use our git DSL in the testhelper package because of an import cycle between the testhelper and git package. To fix this import cycle, we thus move test-related git helpers into the gittest package. This commit moves the commit helpers.
2021-02-17Gitaly-ruby server should be a provided dependencyPavlo Strokov
Server factory should not manage gitaly-ruby server internally as it completely independent entity and should be provided only as a dependency into other components. The change also restructure creation of the gRPC servers by the factory, so that doesn't rely on the specific services. This gives us un opportunity to re-use setup code in the tests and remove the helpers that are not complete compared to actual production used.
2021-02-12DI git.CommandFactory into localrepo.RepoPavlo Strokov
Current implementation of the localrepo.Repo creates *git.ExecCommandFactory internally and use it for running git commands. This dependency needs to be provided from the outside instead. The git.CommandFactory parameter added to the constructor func and all its usages fixed thor out the code.
2021-02-11Add pass-through PackObjectsHook RPCJacob Vosmaer
2021-02-11tests: Convert code to use `localrepo.ReadCommit()`Patrick Steinhardt
This commit converts all users of `log.GetCommit()` and `log.GetCommitWithTrailers()` to instead use the new `localrepo.ReadCommit()` function.
2021-02-03Injection of the git.CommandFactory into catfile packagePavlo Strokov
As we are abstracting dependencies required to create a git command we introduced git.CommandFactory interface that is in duty of creation of the git commands. The catfile package used across different services and as a first step we provide factory as an additional constructor parameter. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
2021-02-03Removal of unused storage.LocatorPavlo Strokov
Changes done in 052682f51 (git: Convert needless use of `SafeBareCmd`, 2021-01-13) remove need in having storage.Locator dependency in catfile package. This commits removes that dependency as unused. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
2021-02-03Refactoring of the gitaly gRPC server creationPavlo Strokov
Factory extended with additional constructor parameters to reduce code coupling and make it dependent on abstractions. Two server constructors combined into one that has a single additional parameter to control tls usage. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
2021-01-29repository: Inject transaction transaction managerPatrick Steinhardt
We'll need the transaction manager in the RepositoryService in order to enable transactional voting for RPCs which modify the repository state. So let's inject the manager to make it available.
2021-01-29hook: Dependency-inject transaction managerPatrick Steinhardt
The transaction.Manager is currently instantiated by the hook.Manager directly, which was done in order to make splitting up transaction and hook logic focussed on the task without doing global changes in the preceding commit. We do want to dependency inject it from external though given that hooks aren't going to be the single location where they're used. So let's do so and adjust all sites where the hook manager is instantiated to also pass a transaction manager.
2021-01-25featureflag: Remove GoFetchSourceBranch feature flagPatrick Steinhardt
The GoFetchSourceBranch feature flag has been default-enabled in commit 8443b3333 (featureflag: Enable Go implementation of FetchSourceBranch by default, 2021-01-13), which was released with v13.8.0. We can thus remove this feature flag altogether now.
2021-01-14log: Convert interface to accept RevisionsPatrick Steinhardt
Instead of accepting an untyped string, this commit refactors the log interface to accept Revisions instead.
2021-01-12testhelper: Use test context in `GetTemporaryGitalySocketFileName()`Patrick Steinhardt
The `testhelper.GetTemporaryGitalySocketFileName()` function currently returns an error. Given that all callers use `require.NoError()` on that error, let's convert it to instead receive a `testing.TB` and not return an error.
2021-01-06testhelper: Accept `testing.TB` when starting the serverPatrick Steinhardt
Currently, `TestServer.Start()` returns an error. Given that it's only used for tests and never inside of the test's main function, let's convert it to instead receive a `testing.TB` and use `require`.
2020-12-16Break dependency of the catfile on global config.ConfigPavlo Strokov
The catfile package directly or indirectly uses config.Config value. And as we are about to remove config.Config from the code we need to break this dependency and substitute with other abstractions. For now those are storage.Locator and alternates.Env instead of the old alternates.PathAndEnv that depends on the global var. It was decided to extend constructor function of the catfile to accept storage.Locator as a dependency as it is already injected in most of the "server"s which handle requests. The other option could be creation of the "factory", but it will require a new dependency to be injected into all existing services which is a lot more changes and adds currently unnecessary abstraction that needs to be managed. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
2020-12-03Inject locator into Hook manager to resolve repository pathPavlo Strokov
To remove dependencies on the global config.Config var the Locator dependency injected into hook manager. To reduce amount of parameters to pass into GitlabAPI.Allowed method a new AllowedParams struct defined and used instead. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
2020-11-26repository: Set up hook servicePatrick Steinhardt
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.
2020-11-20Unbound initialization and validation funcs from global ConfigPavlo Strokov
In order to remove dependency on the global config.Config var we need to break dependencies between Config and it's initialization and validation functions. Most of them now represented as a methods on the config.Cfg type. It allows us to setup required Cfg struct for the tests to run without need to sync changes done on the shared global Config var. The tests that were heavily dependent on the Config var now depend on the struct initialized inside the test instead. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699 Blocks: https://gitlab.com/gitlab-org/gitaly/-/issues/3166
2020-10-30dependency inject connection pool in to the operations serverSami Hiltunen
Dependency inject connection pool in to the operations server to share connections between multiple services.
2020-10-16Introduce Locator abstraction to repository servicePavlo Strokov
In order to break dependency on the shared global config.Config variable the Locator interface is injected into the service. Calls that eventually lead to global config.Config var were removed. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
2020-09-07gitaly: Move Gitaly-specific code into `internal/gitaly`Patrick Steinhardt
Since the introduction of Praefect, our code layout started to become confusing: while Praefect code lives in `internal/praefect`, Gitaly-specific code is all over the place and not neatly singled out. This makes it hard at times to tell apart Praefect- and Gitaly-specific from generic code. To improve the situation, this commit thus moves most of the server specific code into a new `internal/gitaly` package. Currently, this is the `internal/config`, `internal/server`, `internal/service` and `internal/rubyserver` packages, which are all main components of Gitaly. The move was realized with the following script: #!/bin/sh mkdir -p internal/gitaly git mv internal/{config,server,service,rubyserver} internal/gitaly/ find . -name '*.go' -exec sed -i \ -e 's|gitlab-org/gitaly/internal/rubyserver|gitlab-org/gitaly/internal/gitaly/rubyserver|' \ -e 's|gitlab-org/gitaly/internal/server|gitlab-org/gitaly/internal/gitaly/server|' \ -e 's|gitlab-org/gitaly/internal/service|gitlab-org/gitaly/internal/gitaly/service|' \ -e 's|gitlab-org/gitaly/internal/config|gitlab-org/gitaly/internal/gitaly/config|' {} \; In addition to that, some minor adjustments were needed for tests which used relative paths.