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:
Diffstat (limited to 'internal/backup/backup_test.go')
-rw-r--r--internal/backup/backup_test.go115
1 files changed, 10 insertions, 105 deletions
diff --git a/internal/backup/backup_test.go b/internal/backup/backup_test.go
index 81e87a33a..14341ec6a 100644
--- a/internal/backup/backup_test.go
+++ b/internal/backup/backup_test.go
@@ -28,10 +28,13 @@ import (
"google.golang.org/protobuf/proto"
)
-func TestManager_RemoveRepository(t *testing.T) {
- if testhelper.IsPraefectEnabled() {
- t.Skip("local backup manager expects to operate on the local filesystem so cannot operate through praefect")
- }
+func TestManager_RemoveAllRepositories(t *testing.T) {
+ testhelper.SkipWithWAL(t, `
+RemoveAll is removing the entire content of the storage. This would also remove the database's and
+the transaction manager's disk state. The RPC needs to be updated to shut down all partitions and
+the database and only then perform the removal.
+
+Issue: https://gitlab.com/gitlab-org/gitaly/-/issues/5269`)
t.Parallel()
@@ -55,109 +58,11 @@ func TestManager_RemoveRepository(t *testing.T) {
require.NoError(t, err)
fsBackup := backup.NewManager(sink, locator, pool)
- err = fsBackup.RemoveRepository(ctx, &backup.RemoveRepositoryRequest{
- Server: storage.ServerInfo{Address: cfg.SocketPath, Token: cfg.Auth.Token},
- Repo: repo,
+ err = fsBackup.RemoveAllRepositories(ctx, &backup.RemoveAllRepositoriesRequest{
+ Server: storage.ServerInfo{Address: cfg.SocketPath, Token: cfg.Auth.Token},
+ StorageName: repo.StorageName,
})
require.NoError(t, err)
- require.NoDirExists(t, repoPath)
-
- // With an invalid repository
- err = fsBackup.RemoveRepository(ctx, &backup.RemoveRepositoryRequest{
- Server: storage.ServerInfo{Address: cfg.SocketPath, Token: cfg.Auth.Token},
- Repo: &gitalypb.Repository{StorageName: "nonexistent", RelativePath: "nonexistent"},
- })
-
- require.EqualError(t, err, "remove repo: remove: rpc error: code = InvalidArgument desc = storage name not found")
-}
-
-func TestManager_ListRepositories(t *testing.T) {
- t.Parallel()
-
- for _, tc := range []struct {
- desc string
- repos map[string][]*gitalypb.Repository
- }{
- {
- desc: "no repos",
- repos: make(map[string][]*gitalypb.Repository),
- },
- {
- desc: "repos in a single storage",
- repos: map[string][]*gitalypb.Repository{
- "storage-1": {
- {RelativePath: "a", StorageName: "storage-1"},
- {RelativePath: "b", StorageName: "storage-1"},
- },
- },
- },
- {
- desc: "repos in multiple storages",
- repos: map[string][]*gitalypb.Repository{
- "storage-1": {
- {RelativePath: "a", StorageName: "storage-1"},
- {RelativePath: "b", StorageName: "storage-1"},
- },
- "storage-2": {
- {RelativePath: "c", StorageName: "storage-2"},
- {RelativePath: "d", StorageName: "storage-2"},
- },
- },
- },
- } {
- t.Run(tc.desc, func(t *testing.T) {
- if testhelper.IsPraefectEnabled() {
- t.Skip("local backup manager expects to operate on the local filesystem so cannot operate through praefect")
- }
-
- var storages []string
- for storageName := range tc.repos {
- storages = append(storages, storageName)
- }
-
- // We don't really need a "default" storage, but this makes initialisation cleaner since
- // WithStorages() takes at least one argument.
- cfg := testcfg.Build(t, testcfg.WithStorages("default", storages...))
- cfg.SocketPath = testserver.RunGitalyServer(t, cfg, setup.RegisterAll)
-
- ctx := testhelper.Context(t)
-
- for storageName, repos := range tc.repos {
- for _, repo := range repos {
- storagePath, ok := cfg.StoragePath(storageName)
- require.True(t, ok)
-
- _, _ = gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- RelativePath: repo.RelativePath,
- Storage: config.Storage{Name: storageName, Path: storagePath},
- })
- }
- }
-
- pool := client.NewPool()
- defer testhelper.MustClose(t, pool)
-
- backupRoot := testhelper.TempDir(t)
- sink := backup.NewFilesystemSink(backupRoot)
- defer testhelper.MustClose(t, sink)
-
- locator, err := backup.ResolveLocator("pointer", sink)
- require.NoError(t, err)
-
- fsBackup := backup.NewManager(sink, locator, pool)
-
- for storageName, repos := range tc.repos {
- actualRepos, err := fsBackup.ListRepositories(ctx, &backup.ListRepositoriesRequest{
- Server: storage.ServerInfo{Address: cfg.SocketPath, Token: cfg.Auth.Token},
- StorageName: storageName,
- })
-
- require.NoError(t, err)
- require.EqualValues(t, repos, actualRepos)
- }
- })
- }
}
func TestManager_Create(t *testing.T) {