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>2022-10-21 17:45:33 +0300
committerJohn Cai <jcai@gitlab.com>2022-11-02 20:44:46 +0300
commit26225271693f6c779a79911e6956241c9be6049e (patch)
tree1a0eb67c98b9969594907d7f887c8c1c617cdc43
parent33755606055bb0e64f157eb778e96b2759a3f1e4 (diff)
git: Add v2.38 Git version execution environment
Add a git execution environment for v2.38, as well as a feature flag to enable it.
-rw-r--r--internal/git/command_factory_test.go38
-rw-r--r--internal/git/execution_environment.go6
-rw-r--r--internal/metadata/featureflag/ff_git_v238.go9
-rw-r--r--internal/testhelper/testhelper.go2
4 files changed, 43 insertions, 12 deletions
diff --git a/internal/git/command_factory_test.go b/internal/git/command_factory_test.go
index 66737b181..45a2b8e2e 100644
--- a/internal/git/command_factory_test.go
+++ b/internal/git/command_factory_test.go
@@ -20,6 +20,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v15/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v15/internal/helper/text"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper/testcfg"
)
@@ -219,8 +220,7 @@ func TestCommandFactory_ExecutionEnvironment(t *testing.T) {
})
t.Run("set using GITALY_TESTING_BUNDLED_GIT_PATH", func(t *testing.T) {
- suffix := "-v2.37.1.gl1"
-
+ suffixes := []string{"-v2.37.1.gl1", "-v2.38"}
bundledGitDir := testhelper.TempDir(t)
var bundledGitConstructors []git.BundledGitEnvironmentConstructor
@@ -232,8 +232,11 @@ func TestCommandFactory_ExecutionEnvironment(t *testing.T) {
}
require.NotEmpty(t, bundledGitConstructors)
- bundledGitExecutable := filepath.Join(bundledGitDir, "gitaly-git"+suffix)
- bundledGitRemoteExecutable := filepath.Join(bundledGitDir, "gitaly-git-remote-http"+suffix)
+ var bundledGitExecutables, bundledGitRemoteExecutables []string
+ for _, suffix := range suffixes {
+ bundledGitExecutables = append(bundledGitExecutables, filepath.Join(bundledGitDir, "gitaly-git"+suffix))
+ bundledGitRemoteExecutables = append(bundledGitRemoteExecutables, filepath.Join(bundledGitDir, "gitaly-git-remote-http"+suffix))
+ }
t.Setenv("GITALY_TESTING_BUNDLED_GIT_PATH", bundledGitDir)
@@ -245,30 +248,41 @@ func TestCommandFactory_ExecutionEnvironment(t *testing.T) {
t.Run("missing gitaly-git executable", func(t *testing.T) {
_, _, err := git.NewExecCommandFactory(config.Cfg{BinDir: testhelper.TempDir(t)}, git.WithSkipHooks())
require.Error(t, err)
- require.Contains(t, err.Error(), fmt.Sprintf(`statting "gitaly-git%s":`, suffix))
+ require.Contains(t, err.Error(), `statting "gitaly-git-v2.38"`)
require.True(t, errors.Is(err, os.ErrNotExist))
})
t.Run("missing git-remote-http executable", func(t *testing.T) {
- require.NoError(t, os.WriteFile(bundledGitExecutable, []byte{}, 0o777))
+ for _, bundledGitExecutable := range bundledGitExecutables {
+ require.NoError(t, os.WriteFile(bundledGitExecutable, []byte{}, 0o777))
+ }
_, _, err := git.NewExecCommandFactory(config.Cfg{BinDir: testhelper.TempDir(t)}, git.WithSkipHooks())
require.Error(t, err)
- require.Contains(t, err.Error(), fmt.Sprintf("statting \"gitaly-git-remote-http%s\":", suffix))
+ require.Contains(t, err.Error(), `statting "gitaly-git-remote-http-v2.38"`)
require.True(t, errors.Is(err, os.ErrNotExist))
})
t.Run("missing git-http-backend executable", func(t *testing.T) {
- require.NoError(t, os.WriteFile(bundledGitExecutable, []byte{}, 0o777))
- require.NoError(t, os.WriteFile(bundledGitRemoteExecutable, []byte{}, 0o777))
+ for _, bundledGitExecutable := range bundledGitExecutables {
+ require.NoError(t, os.WriteFile(bundledGitExecutable, []byte{}, 0o777))
+ }
+ for _, bundledGitRemoteExecutable := range bundledGitRemoteExecutables {
+ require.NoError(t, os.WriteFile(bundledGitRemoteExecutable, []byte{}, 0o777))
+ }
_, _, err := git.NewExecCommandFactory(config.Cfg{BinDir: testhelper.TempDir(t)}, git.WithSkipHooks())
require.Error(t, err)
- require.Contains(t, err.Error(), fmt.Sprintf("statting \"gitaly-git-http-backend%s\":", suffix))
+ require.Contains(t, err.Error(), `statting "gitaly-git-http-backend-v2.38"`)
require.True(t, errors.Is(err, os.ErrNotExist))
})
t.Run("bin_dir with executables", func(t *testing.T) {
+ expectedSuffix := "-v2.37.1.gl1"
+ if featureflag.GitV238.IsEnabled(ctx) {
+ expectedSuffix = "-v2.38"
+ }
+
for _, bundledGitConstructor := range bundledGitConstructors {
for _, gitBinary := range []string{"gitaly-git", "gitaly-git-remote-http", "gitaly-git-http-backend"} {
require.NoError(t, os.WriteFile(filepath.Join(bundledGitDir, gitBinary+bundledGitConstructor.Suffix), []byte{}, 0o777))
@@ -289,14 +303,14 @@ func TestCommandFactory_ExecutionEnvironment(t *testing.T) {
// executable in Gitaly's BinDir.
target, err := os.Readlink(symlinkPath)
require.NoError(t, err)
- require.Equal(t, filepath.Join(binDir, "gitaly-"+executable+suffix), target)
+ require.Equal(t, filepath.Join(binDir, "gitaly-"+executable+expectedSuffix), target)
// And in a test setup, the symlink in Gitaly's BinDir must point to
// the Git binary pointed to by the GITALY_TESTING_BUNDLED_GIT_PATH
// environment variable.
target, err = os.Readlink(target)
require.NoError(t, err)
- require.Equal(t, filepath.Join(bundledGitDir, "gitaly-"+executable+suffix), target)
+ require.Equal(t, filepath.Join(bundledGitDir, "gitaly-"+executable+expectedSuffix), target)
}
})
})
diff --git a/internal/git/execution_environment.go b/internal/git/execution_environment.go
index b313dce85..8ce1fbb7f 100644
--- a/internal/git/execution_environment.go
+++ b/internal/git/execution_environment.go
@@ -26,6 +26,12 @@ var (
// case `IsEnabled()` returns `false` though.
ExecutionEnvironmentConstructors = []ExecutionEnvironmentConstructor{
BundledGitEnvironmentConstructor{
+ Suffix: "-v2.38",
+ FeatureFlags: []featureflag.FeatureFlag{
+ featureflag.GitV238,
+ },
+ },
+ BundledGitEnvironmentConstructor{
Suffix: "-v2.37.1.gl1",
},
DistributedGitEnvironmentConstructor{},
diff --git a/internal/metadata/featureflag/ff_git_v238.go b/internal/metadata/featureflag/ff_git_v238.go
new file mode 100644
index 000000000..158e61448
--- /dev/null
+++ b/internal/metadata/featureflag/ff_git_v238.go
@@ -0,0 +1,9 @@
+package featureflag
+
+// GitV238 will enable the use of Git v2.38
+var GitV238 = NewFeatureFlag(
+ "git_v238",
+ "v15.6.0",
+ "https://gitlab.com/gitlab-org/gitaly/-/issues/4553",
+ false,
+)
diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go
index bf8d59899..116f70937 100644
--- a/internal/testhelper/testhelper.go
+++ b/internal/testhelper/testhelper.go
@@ -203,6 +203,8 @@ func ContextWithoutCancel(opts ...ContextOpt) context.Context {
// Randomly enable the flag to exercise both paths to some extent.
ctx = featureflag.ContextWithFeatureFlag(ctx, featureflag.NodeErrorCancelsVoter, rnd.Int()%2 == 0)
+ ctx = featureflag.ContextWithFeatureFlag(ctx, featureflag.GitV238, rnd.Int()%2 == 0)
+
for _, opt := range opts {
ctx = opt(ctx)
}