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:
authorSami Hiltunen <shiltunen@gitlab.com>2021-07-29 14:50:54 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2021-08-02 11:17:32 +0300
commit0425c080744de23a26dcc659d0d1ac642c7cdbaa (patch)
tree419c0a38d716a5081972e86e7bc45fd9c2cba2ef
parent5b2c9725b168b5dac3a3f818f812e838921b3f06 (diff)
Create repositories explicitly in Coordinator's tests
SetGeneration should not create repository records but only set the generation of a replica. This commit creates repositories explicitly in Coordinator's tests so we can change the behavior of SetGeneration in a follow up commit. StreamDirector's tests also currently create generation records with a negative generation. Negative generations are used in some contexts to indicate a missing record. In this case though, we should just not create the records if they are supposed to be missing.
-rw-r--r--internal/praefect/coordinator_pg_test.go11
-rw-r--r--internal/praefect/replicator_pg_test.go3
2 files changed, 12 insertions, 2 deletions
diff --git a/internal/praefect/coordinator_pg_test.go b/internal/praefect/coordinator_pg_test.go
index 81f67738d..632398d14 100644
--- a/internal/praefect/coordinator_pg_test.go
+++ b/internal/praefect/coordinator_pg_test.go
@@ -206,7 +206,18 @@ func TestStreamDirectorMutator_Transaction(t *testing.T) {
// set up the generations prior to transaction
rs := datastore.NewPostgresRepositoryStore(getDB(t), conf.StorageNames())
+
+ repoCreated := false
for i, n := range tc.nodes {
+ if n.generation == datastore.GenerationUnknown {
+ continue
+ }
+
+ if !repoCreated {
+ repoCreated = true
+ require.NoError(t, rs.CreateRepository(ctx, repo.StorageName, repo.RelativePath, storageNodes[i].Storage, nil, nil, false, false))
+ }
+
require.NoError(t, rs.SetGeneration(ctx, repo.StorageName, repo.RelativePath, storageNodes[i].Storage, n.generation))
}
diff --git a/internal/praefect/replicator_pg_test.go b/internal/praefect/replicator_pg_test.go
index 630f6944b..429d47625 100644
--- a/internal/praefect/replicator_pg_test.go
+++ b/internal/praefect/replicator_pg_test.go
@@ -86,8 +86,7 @@ func TestReplicatorDestroy(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- require.NoError(t, rs.SetGeneration(ctx, "virtual-storage-1", "relative-path-1", "storage-1", 0))
- require.NoError(t, rs.SetGeneration(ctx, "virtual-storage-1", "relative-path-1", "storage-2", 0))
+ require.NoError(t, rs.CreateRepository(ctx, "virtual-storage-1", "relative-path-1", "storage-1", []string{"storage-2"}, nil, false, false))
ln, err := net.Listen("tcp", "localhost:0")
require.NoError(t, err)