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/models/project_spec.rb | |
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/models/project_spec.rb')
-rw-r--r-- | spec/models/project_spec.rb | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 72284035b57..7bf60083d10 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -2410,6 +2410,20 @@ describe Project do end end + describe '#set_repository_read_only!' do + let(:project) { create(:project) } + + it 'returns true when there is no existing git transfer in progress' do + expect(project.set_repository_read_only!).to be_truthy + end + + it 'returns false when there is an existing git transfer in progress' do + allow(project).to receive(:git_transfer_in_progress?) { true } + + expect(project.set_repository_read_only!).to be_falsey + end + end + describe '#pushes_since_gc' do let(:project) { create(:project) } @@ -3143,6 +3157,33 @@ describe Project do end end + describe '#git_transfer_in_progress?' do + let(:project) { build(:project) } + + subject { project.git_transfer_in_progress? } + + it 'returns false when repo_reference_count and wiki_reference_count are 0' do + allow(project).to receive(:repo_reference_count) { 0 } + allow(project).to receive(:wiki_reference_count) { 0 } + + expect(subject).to be_falsey + end + + it 'returns true when repo_reference_count is > 0' do + allow(project).to receive(:repo_reference_count) { 2 } + allow(project).to receive(:wiki_reference_count) { 0 } + + expect(subject).to be_truthy + end + + it 'returns true when wiki_reference_count is > 0' do + allow(project).to receive(:repo_reference_count) { 0 } + allow(project).to receive(:wiki_reference_count) { 2 } + + expect(subject).to be_truthy + end + end + context 'legacy storage' do let(:project) { create(:project, :repository, :legacy_storage) } let(:gitlab_shell) { Gitlab::Shell.new } @@ -3203,10 +3244,6 @@ describe Project do expect(project.migrate_to_hashed_storage!).to be_truthy end - it 'flags as read-only' do - expect { project.migrate_to_hashed_storage! }.to change { project.repository_read_only }.to(true) - end - it 'does not validate project visibility' do expect(project).not_to receive(:visibility_level_allowed_as_fork) expect(project).not_to receive(:visibility_level_allowed_by_group) |