diff options
author | Gabriel Mazetto <brodock@gmail.com> | 2018-12-22 04:01:24 +0100 |
---|---|---|
committer | Gabriel Mazetto <brodock@gmail.com> | 2019-01-07 23:53:06 +0100 |
commit | ee4af0c64cdf00d2c34ce7feb773e057f9758cff (patch) | |
tree | e020ae1eda2b9c2eb24a1e24c862d502c4f8e748 /spec/services/projects | |
parent | 7380364240a26d184d67edb1fe7ae0fc07217e0f (diff) | |
download | gitlab-ce-ee4af0c64cdf00d2c34ce7feb773e057f9758cff.tar.gz |
Only set as `read_only` when starting the per-project migration53966-hashed-storage-read-only
In the previous code, we locked the project during the migration
scheduling step, which works fine for small setups, but can be
problematic in really big installations.
We now moved the logic to inside the worker, so we minimize the time a
project will be read-only. We also make sure we only do that if
reference counter is `0` (no current operation is in progress).
Diffstat (limited to 'spec/services/projects')
-rw-r--r-- | spec/services/projects/hashed_storage/migrate_repository_service_spec.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/services/projects/hashed_storage/migrate_repository_service_spec.rb b/spec/services/projects/hashed_storage/migrate_repository_service_spec.rb index 0e82194e9ee..b720f37ffdb 100644 --- a/spec/services/projects/hashed_storage/migrate_repository_service_spec.rb +++ b/spec/services/projects/hashed_storage/migrate_repository_service_spec.rb @@ -15,6 +15,20 @@ describe Projects::HashedStorage::MigrateRepositoryService do allow(service).to receive(:gitlab_shell) { gitlab_shell } end + context 'repository lock' do + it 'tries to lock the repository' do + expect(service).to receive(:try_to_set_repository_read_only!) + + service.execute + end + + it 'fails when a git operation is in progress' do + allow(project).to receive(:repo_reference_count) { 1 } + + expect { service.execute }.to raise_error(Projects::HashedStorage::RepositoryMigrationError) + end + end + context 'when succeeds' do it 'renames project and wiki repositories' do service.execute |