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>2024-01-24 01:10:29 +0300
committerJames Fargher <jfargher@gitlab.com>2024-01-24 01:10:29 +0300
commit9c1eb7ffa88fb7fa99a5aabb2429b75ee8881b70 (patch)
tree049a1cc05b9ba3e341c4e9f88bcb745975e2e050
parentd3743e91caa9bdc342df4dd33c5df380f9860826 (diff)
backup: Refactor restore tests to use manifests
We are looking to replace all locators with the manifest locator. This changes all the restore tests to use manifests only.
-rw-r--r--internal/backup/backup_test.go119
1 files changed, 74 insertions, 45 deletions
diff --git a/internal/backup/backup_test.go b/internal/backup/backup_test.go
index 96a06fba3..1b8d5c62a 100644
--- a/internal/backup/backup_test.go
+++ b/internal/backup/backup_test.go
@@ -636,6 +636,14 @@ func TestManager_Restore_latest(t *testing.T) {
relativePath := stripRelativePath(tb, repo)
testhelper.WriteFiles(tb, backupRoot, map[string]any{
+ filepath.Join("manifests", repo.GetStorageName(), repo.GetRelativePath(), "+latest.toml"): fmt.Sprintf(`
+object_format = '%[1]s'
+
+[[steps]]
+bundle_path = '%[2]s.bundle'
+ref_path = '%[2]s.refs'
+custom_hooks_path = '%[2]s/custom_hooks.tar'
+ `, gittest.DefaultObjectHash.Format, relativePath),
relativePath + ".bundle": repoBundle,
relativePath + ".refs": repoRefs,
})
@@ -653,6 +661,14 @@ func TestManager_Restore_latest(t *testing.T) {
relativePath := stripRelativePath(tb, repo)
customHooksPath := filepath.Join(backupRoot, relativePath, "custom_hooks.tar")
testhelper.WriteFiles(tb, backupRoot, map[string]any{
+ filepath.Join("manifests", repo.GetStorageName(), repo.GetRelativePath(), "+latest.toml"): fmt.Sprintf(`
+object_format = '%[1]s'
+
+[[steps]]
+bundle_path = '%[2]s.bundle'
+ref_path = '%[2]s.refs'
+custom_hooks_path = '%[2]s/custom_hooks.tar'
+ `, gittest.DefaultObjectHash.Format, relativePath),
relativePath + ".bundle": repoBundle,
relativePath + ".refs": repoRefs,
})
@@ -696,6 +712,13 @@ func TestManager_Restore_latest(t *testing.T) {
relativePath := stripRelativePath(tb, repo)
testhelper.WriteFiles(tb, backupRoot, map[string]any{
+ filepath.Join("manifests", repo.GetStorageName(), repo.GetRelativePath(), "+latest.toml"): fmt.Sprintf(`
+object_format = '%[1]s'
+
+[[steps]]
+ref_path = '%[2]s.refs'
+custom_hooks_path = '%[2]s/custom_hooks.tar'
+ `, gittest.DefaultObjectHash.Format, relativePath),
relativePath + ".refs": "",
})
@@ -711,6 +734,13 @@ func TestManager_Restore_latest(t *testing.T) {
relativePath := stripRelativePath(tb, repo)
testhelper.WriteFiles(tb, backupRoot, map[string]any{
+ filepath.Join("manifests", repo.GetStorageName(), repo.GetRelativePath(), "+latest.toml"): fmt.Sprintf(`
+object_format = '%[1]s'
+
+[[steps]]
+ref_path = '%[2]s.refs'
+custom_hooks_path = '%[2]s/custom_hooks.tar'
+ `, gittest.DefaultObjectHash.Format, relativePath),
relativePath + ".refs": "",
})
@@ -730,6 +760,14 @@ func TestManager_Restore_latest(t *testing.T) {
relativePath := stripRelativePath(tb, repo)
testhelper.WriteFiles(tb, backupRoot, map[string]any{
+ filepath.Join("manifests", repo.GetStorageName(), repo.GetRelativePath(), "+latest.toml"): fmt.Sprintf(`
+object_format = '%[1]s'
+
+[[steps]]
+bundle_path = '%[2]s.bundle'
+ref_path = '%[2]s.refs'
+custom_hooks_path = '%[2]s/custom_hooks.tar'
+ `, gittest.DefaultObjectHash.Format, relativePath),
relativePath + ".bundle": repoBundle,
relativePath + ".refs": repoRefs,
})
@@ -739,43 +777,6 @@ func TestManager_Restore_latest(t *testing.T) {
expectExists: true,
},
{
- desc: "single incremental",
- locators: []string{"pointer"},
- setup: func(tb testing.TB) (*gitalypb.Repository, *git.Checksum) {
- const backupID = "abc123"
- repo, _ := gittest.CreateRepository(t, ctx, cfg)
-
- relativePath := stripRelativePath(tb, repo)
- testhelper.WriteFiles(tb, backupRoot, map[string]any{
- filepath.Join(relativePath, "LATEST"): backupID,
- filepath.Join(relativePath, backupID, "LATEST"): "001",
- filepath.Join(relativePath, backupID, "001.bundle"): repoBundle,
- filepath.Join(relativePath, backupID, "001.refs"): repoRefs,
- })
-
- return repo, repoChecksum
- },
- expectExists: true,
- },
- {
- desc: "single incremental, empty backup",
- locators: []string{"pointer"},
- setup: func(tb testing.TB) (*gitalypb.Repository, *git.Checksum) {
- const backupID = "abc123"
- repo, _ := gittest.CreateRepository(t, ctx, cfg)
-
- relativePath := stripRelativePath(tb, repo)
- testhelper.WriteFiles(tb, backupRoot, map[string]any{
- filepath.Join(relativePath, "LATEST"): backupID,
- filepath.Join(relativePath, backupID, "LATEST"): "001",
- filepath.Join(relativePath, backupID, "001.refs"): "",
- })
-
- return repo, new(git.Checksum)
- },
- expectExists: true,
- },
- {
desc: "many incrementals",
locators: []string{"pointer"},
setup: func(tb testing.TB) (*gitalypb.Repository, *git.Checksum) {
@@ -819,8 +820,19 @@ func TestManager_Restore_latest(t *testing.T) {
relativePath := stripRelativePath(tb, repo)
testhelper.WriteFiles(tb, backupRoot, map[string]any{
- filepath.Join(relativePath, "LATEST"): backupID,
- filepath.Join(relativePath, backupID, "LATEST"): "002",
+ filepath.Join("manifests", repo.GetStorageName(), repo.GetRelativePath(), "+latest.toml"): fmt.Sprintf(`
+object_format = '%[1]s'
+
+[[steps]]
+bundle_path = '%[2]s/%[3]s/001.bundle'
+ref_path = '%[2]s/%[3]s/001.refs'
+custom_hooks_path = '%[2]s/%[3]s/001.custom_hooks.tar'
+
+[[steps]]
+bundle_path = '%[2]s/%[3]s/002.bundle'
+ref_path = '%[2]s/%[3]s/002.refs'
+custom_hooks_path = '%[2]s/%[3]s/002.custom_hooks.tar'
+ `, gittest.DefaultObjectHash.Format, relativePath, backupID),
filepath.Join(relativePath, backupID, "001.bundle"): bundle1,
filepath.Join(relativePath, backupID, "002.bundle"): bundle2,
filepath.Join(relativePath, backupID, "001.refs"): refs1,
@@ -988,8 +1000,14 @@ func TestManager_Restore_specific(t *testing.T) {
relativePath := stripRelativePath(tb, repo)
testhelper.WriteFiles(tb, backupRoot, map[string]any{
- filepath.Join(relativePath, "LATEST"): backupID,
- filepath.Join(relativePath, backupID, "LATEST"): "001",
+ filepath.Join("manifests", repo.GetStorageName(), repo.GetRelativePath(), backupID+".toml"): fmt.Sprintf(`
+object_format = '%[1]s'
+
+[[steps]]
+bundle_path = '%[2]s/%[3]s/001.bundle'
+ref_path = '%[2]s/%[3]s/001.refs'
+custom_hooks_path = '%[2]s/%[3]s/001.custom_hooks.tar'
+ `, gittest.DefaultObjectHash.Format, relativePath, backupID),
filepath.Join(relativePath, backupID, "001.bundle"): repoBundle,
filepath.Join(relativePath, backupID, "001.refs"): repoRefs,
})
@@ -1041,8 +1059,19 @@ func TestManager_Restore_specific(t *testing.T) {
relativePath := stripRelativePath(tb, repo)
testhelper.WriteFiles(tb, backupRoot, map[string]any{
- filepath.Join(relativePath, "LATEST"): backupID,
- filepath.Join(relativePath, backupID, "LATEST"): "002",
+ filepath.Join("manifests", repo.GetStorageName(), repo.GetRelativePath(), backupID+".toml"): fmt.Sprintf(`
+object_format = '%[1]s'
+
+[[steps]]
+bundle_path = '%[2]s/%[3]s/001.bundle'
+ref_path = '%[2]s/%[3]s/001.refs'
+custom_hooks_path = '%[2]s/%[3]s/001.custom_hooks.tar'
+
+[[steps]]
+bundle_path = '%[2]s/%[3]s/002.bundle'
+ref_path = '%[2]s/%[3]s/002.refs'
+custom_hooks_path = '%[2]s/%[3]s/002.custom_hooks.tar'
+ `, gittest.DefaultObjectHash.Format, relativePath, backupID),
filepath.Join(relativePath, backupID, "001.bundle"): bundle1,
filepath.Join(relativePath, backupID, "002.bundle"): bundle2,
filepath.Join(relativePath, backupID, "001.refs"): refs1,
@@ -1059,7 +1088,7 @@ func TestManager_Restore_specific(t *testing.T) {
expectExists: true,
},
{
- desc: "manifest, empty backup",
+ desc: "empty backup",
setup: func(tb testing.TB) (*gitalypb.Repository, *git.Checksum) {
repo, _ := gittest.CreateRepository(tb, ctx, cfg)
@@ -1082,7 +1111,7 @@ custom_hooks_path = 'custom_hooks.tar'
expectedHeadReference: "refs/heads/banana",
},
{
- desc: "manifest",
+ desc: "head reference",
setup: func(tb testing.TB) (*gitalypb.Repository, *git.Checksum) {
repo, _ := gittest.CreateRepository(tb, ctx, cfg)