diff options
author | Sami Hiltunen <shiltunen@gitlab.com> | 2021-09-09 17:07:15 +0300 |
---|---|---|
committer | Sami Hiltunen <shiltunen@gitlab.com> | 2021-10-11 13:44:01 +0300 |
commit | c0388d7869bcde00f6d6fefb0ebc7ea4f05e68c9 (patch) | |
tree | 0f2c3e852b05066722d67ca0815da4abfc2a8a5a /cmd | |
parent | 642dccd48e131916d915e01b9f96013438bcf60e (diff) |
Update SetGeneration to use repository ID
This commit updates SetGeneration to use repository ID to identify
a repository instead of the virtual storage and relative path. Logic
is the same but some tests had minor changes to their setups as they
did not setup the repository IDs correctly. SetGeneration is used to
set a repository's generation after successfully applying a replication
job to it. Using the repository ID instead of the virtual storage and
the relative path guarantee any jobs targeting a previous deleted or
renamed repository at the same virtual storage and relative path do
not affect the repository that is now identified by them.
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/praefect/subcmd_accept_dataloss_test.go | 2 | ||||
-rw-r--r-- | cmd/praefect/subcmd_dataloss_test.go | 26 |
2 files changed, 14 insertions, 14 deletions
diff --git a/cmd/praefect/subcmd_accept_dataloss_test.go b/cmd/praefect/subcmd_accept_dataloss_test.go index a3b9940df..55d235afc 100644 --- a/cmd/praefect/subcmd_accept_dataloss_test.go +++ b/cmd/praefect/subcmd_accept_dataloss_test.go @@ -50,7 +50,7 @@ func TestAcceptDatalossSubcommand(t *testing.T) { require.NoError(t, rs.CreateRepository(ctx, 1, vs, repo, storage, nil, nil, false, false)) } - require.NoError(t, rs.SetGeneration(ctx, vs, repo, storage, generation)) + require.NoError(t, rs.SetGeneration(ctx, 1, storage, generation)) } ln, clean := listenAndServe(t, []svcRegistrar{registerPraefectInfoServer(info.NewServer(conf, rs, nil, nil, nil))}) diff --git a/cmd/praefect/subcmd_dataloss_test.go b/cmd/praefect/subcmd_dataloss_test.go index c9d0e38fa..07d7ad602 100644 --- a/cmd/praefect/subcmd_dataloss_test.go +++ b/cmd/praefect/subcmd_dataloss_test.go @@ -54,30 +54,30 @@ func TestDatalossSubcommand(t *testing.T) { for _, q := range []string{ ` - INSERT INTO repositories (virtual_storage, relative_path, "primary") + INSERT INTO repositories (repository_id, virtual_storage, relative_path, "primary") VALUES - ('virtual-storage-1', 'repository-1', 'gitaly-1'), - ('virtual-storage-1', 'repository-2', 'gitaly-3') + (1, 'virtual-storage-1', 'repository-1', 'gitaly-1'), + (2, 'virtual-storage-1', 'repository-2', 'gitaly-3') `, ` - INSERT INTO repository_assignments (virtual_storage, relative_path, storage) + INSERT INTO repository_assignments (repository_id, virtual_storage, relative_path, storage) VALUES - ('virtual-storage-1', 'repository-1', 'gitaly-1'), - ('virtual-storage-1', 'repository-1', 'gitaly-2'), - ('virtual-storage-1', 'repository-2', 'gitaly-1'), - ('virtual-storage-1', 'repository-2', 'gitaly-3') + (1, 'virtual-storage-1', 'repository-1', 'gitaly-1'), + (1, 'virtual-storage-1', 'repository-1', 'gitaly-2'), + (2, 'virtual-storage-1', 'repository-2', 'gitaly-1'), + (2, 'virtual-storage-1', 'repository-2', 'gitaly-3') `, } { _, err := tx.ExecContext(ctx, q) require.NoError(t, err) } - require.NoError(t, gs.SetGeneration(ctx, "virtual-storage-1", "repository-1", "gitaly-1", 1)) - require.NoError(t, gs.SetGeneration(ctx, "virtual-storage-1", "repository-1", "gitaly-2", 0)) - require.NoError(t, gs.SetGeneration(ctx, "virtual-storage-1", "repository-1", "gitaly-3", 0)) + require.NoError(t, gs.SetGeneration(ctx, 1, "gitaly-1", 1)) + require.NoError(t, gs.SetGeneration(ctx, 1, "gitaly-2", 0)) + require.NoError(t, gs.SetGeneration(ctx, 1, "gitaly-3", 0)) - require.NoError(t, gs.SetGeneration(ctx, "virtual-storage-1", "repository-2", "gitaly-2", 1)) - require.NoError(t, gs.SetGeneration(ctx, "virtual-storage-1", "repository-2", "gitaly-3", 0)) + require.NoError(t, gs.SetGeneration(ctx, 2, "gitaly-2", 1)) + require.NoError(t, gs.SetGeneration(ctx, 2, "gitaly-3", 0)) ln, clean := listenAndServe(t, []svcRegistrar{ registerPraefectInfoServer(info.NewServer(cfg, gs, nil, nil, nil)), |