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:
authorJames Fargher <jfargher@gitlab.com>2023-08-07 10:29:13 +0300
committerJames Fargher <jfargher@gitlab.com>2023-08-10 01:06:39 +0300
commitdd4115a82f64932ceb9b9e388c32fecbaf515feb (patch)
tree94a4bdaea403902a122069dd30ce389a2f31b169
parenteb83fe59d4c779e92ac5b52a772052726895d5f9 (diff)
gitaly-backup: Generate refs in restore tests
Refs have been generated for backups for a long time, but since restores have never previously used them, they were never added to the tests. Soon we will use ref files to differentiate between empty and non-existent repos.
-rw-r--r--cmd/gitaly-backup/restore_test.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/cmd/gitaly-backup/restore_test.go b/cmd/gitaly-backup/restore_test.go
index 7a15daeff..069fbf6d0 100644
--- a/cmd/gitaly-backup/restore_test.go
+++ b/cmd/gitaly-backup/restore_test.go
@@ -8,6 +8,7 @@ import (
"flag"
"fmt"
"io"
+ "os"
"path/filepath"
"testing"
@@ -16,6 +17,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/service/setup"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper/testserver"
@@ -38,13 +40,18 @@ func TestRestoreSubcommand(t *testing.T) {
path := testhelper.TempDir(t)
existingRepoBundlePath := filepath.Join(path, existingRepo.RelativePath+".bundle")
+ existingRepoRefPath := filepath.Join(path, existingRepo.RelativePath+".refs")
+
gittest.Exec(t, cfg, "-C", existRepoPath, "bundle", "create", existingRepoBundlePath, "--all")
+ require.NoError(t, os.WriteFile(existingRepoRefPath, gittest.Exec(t, cfg, "-C", existRepoPath, "show-ref"), perm.SharedFile))
var repos []*gitalypb.Repository
for i := 0; i < 2; i++ {
repo := gittest.InitRepoDir(t, cfg.Storages[0].Path, fmt.Sprintf("repo-%d", i))
repoBundlePath := filepath.Join(path, repo.RelativePath+".bundle")
+ repoRefPath := filepath.Join(path, repo.RelativePath+".refs")
testhelper.CopyFile(t, existingRepoBundlePath, repoBundlePath)
+ testhelper.CopyFile(t, existingRepoRefPath, repoRefPath)
repos = append(repos, repo)
}
@@ -116,13 +123,18 @@ func TestRestoreSubcommand_serverSide(t *testing.T) {
gittest.WriteCommit(t, cfg, existRepoPath, gittest.WithBranch(git.DefaultBranch))
existingRepoBundlePath := filepath.Join(path, existingRepo.RelativePath+".bundle")
+ existingRepoRefPath := filepath.Join(path, existingRepo.RelativePath+".refs")
+
gittest.Exec(t, cfg, "-C", existRepoPath, "bundle", "create", existingRepoBundlePath, "--all")
+ require.NoError(t, os.WriteFile(existingRepoRefPath, gittest.Exec(t, cfg, "-C", existRepoPath, "show-ref"), perm.SharedFile))
var repos []*gitalypb.Repository
for i := 0; i < 2; i++ {
repo := gittest.InitRepoDir(t, cfg.Storages[0].Path, fmt.Sprintf("repo-%d", i))
repoBundlePath := filepath.Join(path, repo.RelativePath+".bundle")
+ repoRefPath := filepath.Join(path, repo.RelativePath+".refs")
testhelper.CopyFile(t, existingRepoBundlePath, repoBundlePath)
+ testhelper.CopyFile(t, existingRepoRefPath, repoRefPath)
repos = append(repos, repo)
}