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:
authorWill Chandler <wchandler@gitlab.com>2022-07-15 21:48:41 +0300
committerWill Chandler <wchandler@gitlab.com>2022-07-22 21:25:09 +0300
commit9f45a79e0880977cd36dcf541bf92825bcc704fc (patch)
tree52e3727bafd03a03b17cb603d6f4ef15c65303c5
parent942d8298610eded70b5204863048617ee1c136cd (diff)
praefect: Always use replica paths in tests
We currently enabled feature flag `PraefectGeneratedReplicaPaths` half the time in testing. Several tests for the `remove-repository` are checking that the repository relative path does not exist, but when this feature is enabled the replica path will differ, leading us to check the wrong path. Update these tests to always use `replicaPath` and confirm that the path exists prior to removing it as a check to prevent this from recurring.
-rw-r--r--cmd/praefect/subcmd_remove_repository_test.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/cmd/praefect/subcmd_remove_repository_test.go b/cmd/praefect/subcmd_remove_repository_test.go
index 2f6bbae2a..7811f87d0 100644
--- a/cmd/praefect/subcmd_remove_repository_test.go
+++ b/cmd/praefect/subcmd_remove_repository_test.go
@@ -141,6 +141,10 @@ func TestRemoveRepository_Exec(t *testing.T) {
t.Run("ok", func(t *testing.T) {
var out bytes.Buffer
repo := createRepo(t, ctx, repoClient, praefectStorage, t.Name())
+ replicaPath := gittest.GetReplicaPath(ctx, t, gitalycfg.Cfg{SocketPath: praefectServer.Address()}, repo)
+ require.DirExists(t, filepath.Join(g1Cfg.Storages[0].Path, replicaPath))
+ require.DirExists(t, filepath.Join(g2Cfg.Storages[0].Path, replicaPath))
+
cmd := &removeRepository{
logger: testhelper.NewDiscardingLogger(t),
virtualStorage: repo.StorageName,
@@ -151,8 +155,8 @@ func TestRemoveRepository_Exec(t *testing.T) {
}
require.NoError(t, cmd.Exec(flag.NewFlagSet("", flag.PanicOnError), conf))
- require.NoDirExists(t, filepath.Join(g1Cfg.Storages[0].Path, repo.RelativePath))
- require.NoDirExists(t, filepath.Join(g2Cfg.Storages[0].Path, repo.RelativePath))
+ require.NoDirExists(t, filepath.Join(g1Cfg.Storages[0].Path, replicaPath))
+ require.NoDirExists(t, filepath.Join(g2Cfg.Storages[0].Path, replicaPath))
assert.Contains(t, out.String(), "Repository found in the database.\n")
assert.Contains(t, out.String(), fmt.Sprintf("Attempting to remove %s from the database, and delete it from all gitaly nodes...\n", repo.RelativePath))
assert.Contains(t, out.String(), "Repository removal completed.")
@@ -162,8 +166,11 @@ func TestRemoveRepository_Exec(t *testing.T) {
t.Run("repository doesnt exist on one gitaly", func(t *testing.T) {
var out bytes.Buffer
repo := createRepo(t, ctx, repoClient, praefectStorage, t.Name())
+ replicaPath := gittest.GetReplicaPath(ctx, t, gitalycfg.Cfg{SocketPath: praefectServer.Address()}, repo)
- require.NoError(t, os.RemoveAll(filepath.Join(g2Cfg.Storages[0].Path, repo.RelativePath)))
+ require.DirExists(t, filepath.Join(g2Cfg.Storages[0].Path, replicaPath))
+ require.DirExists(t, filepath.Join(g1Cfg.Storages[0].Path, replicaPath))
+ require.NoError(t, os.RemoveAll(filepath.Join(g2Cfg.Storages[0].Path, replicaPath)))
cmd := &removeRepository{
logger: testhelper.NewDiscardingLogger(t),
@@ -175,8 +182,8 @@ func TestRemoveRepository_Exec(t *testing.T) {
}
require.NoError(t, cmd.Exec(flag.NewFlagSet("", flag.PanicOnError), conf))
- require.NoDirExists(t, filepath.Join(g1Cfg.Storages[0].Path, repo.RelativePath))
- require.NoDirExists(t, filepath.Join(g2Cfg.Storages[0].Path, repo.RelativePath))
+ require.NoDirExists(t, filepath.Join(g1Cfg.Storages[0].Path, replicaPath))
+ require.NoDirExists(t, filepath.Join(g2Cfg.Storages[0].Path, replicaPath))
assert.Contains(t, out.String(), "Repository found in the database.\n")
assert.Contains(t, out.String(), fmt.Sprintf("Attempting to remove %s from the database, and delete it from all gitaly nodes...\n", repo.RelativePath))
assert.Contains(t, out.String(), "Repository removal completed.")