diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/models/project_statistics_spec.rb | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/models/project_statistics_spec.rb')
-rw-r--r-- | spec/models/project_statistics_spec.rb | 61 |
1 files changed, 58 insertions, 3 deletions
diff --git a/spec/models/project_statistics_spec.rb b/spec/models/project_statistics_spec.rb index 20fc14113ef..2c29d4c42f4 100644 --- a/spec/models/project_statistics_spec.rb +++ b/spec/models/project_statistics_spec.rb @@ -36,7 +36,7 @@ RSpec.describe ProjectStatistics do snippets_size: 1.exabyte, pipeline_artifacts_size: 512.petabytes - 1, uploads_size: 512.petabytes, - container_registry_size: 8.exabytes - 1 + container_registry_size: 12.petabytes ) statistics.reload @@ -50,7 +50,7 @@ RSpec.describe ProjectStatistics do expect(statistics.snippets_size).to eq(1.exabyte) expect(statistics.pipeline_artifacts_size).to eq(512.petabytes - 1) expect(statistics.uploads_size).to eq(512.petabytes) - expect(statistics.container_registry_size).to eq(8.exabytes - 1) + expect(statistics.container_registry_size).to eq(12.petabytes) end end @@ -62,6 +62,7 @@ RSpec.describe ProjectStatistics do statistics.build_artifacts_size = 4 statistics.snippets_size = 5 statistics.uploads_size = 3 + statistics.container_registry_size = 8 expect(statistics.total_repository_size).to eq 5 end @@ -104,6 +105,7 @@ RSpec.describe ProjectStatistics do allow(statistics).to receive(:update_snippets_size) allow(statistics).to receive(:update_storage_size) allow(statistics).to receive(:update_uploads_size) + allow(statistics).to receive(:update_container_registry_size) end context "without arguments" do @@ -118,6 +120,7 @@ RSpec.describe ProjectStatistics do expect(statistics).to have_received(:update_lfs_objects_size) expect(statistics).to have_received(:update_snippets_size) expect(statistics).to have_received(:update_uploads_size) + expect(statistics).to have_received(:update_container_registry_size) end end @@ -133,6 +136,7 @@ RSpec.describe ProjectStatistics do expect(statistics).not_to have_received(:update_wiki_size) expect(statistics).not_to have_received(:update_snippets_size) expect(statistics).not_to have_received(:update_uploads_size) + expect(statistics).not_to have_received(:update_container_registry_size) end end @@ -148,11 +152,13 @@ RSpec.describe ProjectStatistics do expect(statistics).to have_received(:update_wiki_size) expect(statistics).to have_received(:update_snippets_size) expect(statistics).to have_received(:update_uploads_size) + expect(statistics).to have_received(:update_container_registry_size) expect(statistics.repository_size).to eq(0) expect(statistics.commit_count).to eq(0) expect(statistics.wiki_size).to eq(0) expect(statistics.snippets_size).to eq(0) expect(statistics.uploads_size).to eq(0) + expect(statistics.container_registry_size).to eq(0) end end @@ -174,11 +180,13 @@ RSpec.describe ProjectStatistics do expect(statistics).to have_received(:update_wiki_size) expect(statistics).to have_received(:update_snippets_size) expect(statistics).to have_received(:update_uploads_size) + expect(statistics).to have_received(:update_container_registry_size) expect(statistics.repository_size).to eq(0) expect(statistics.commit_count).to eq(0) expect(statistics.wiki_size).to eq(0) expect(statistics.snippets_size).to eq(0) expect(statistics.uploads_size).to eq(0) + expect(statistics.container_registry_size).to eq(0) end end @@ -224,6 +232,7 @@ RSpec.describe ProjectStatistics do expect(statistics).not_to receive(:update_lfs_objects_size) expect(statistics).not_to receive(:update_snippets_size) expect(statistics).not_to receive(:update_uploads_size) + expect(statistics).not_to receive(:update_container_registry_size) expect(statistics).not_to receive(:save!) expect(Namespaces::ScheduleAggregationWorker) .not_to receive(:perform_async) @@ -319,8 +328,42 @@ RSpec.describe ProjectStatistics do end end + describe '#update_container_registry_size' do + subject(:update_container_registry_size) { statistics.update_container_registry_size } + + it 'stores the project container registry repositories size' do + allow(project).to receive(:container_repositories_size).and_return(10) + + update_container_registry_size + + expect(statistics.container_registry_size).to eq(10) + end + + it 'handles nil values for the repositories size' do + allow(project).to receive(:container_repositories_size).and_return(nil) + + update_container_registry_size + + expect(statistics.container_registry_size).to eq(0) + end + + context 'with container_registry_project_statistics FF disabled' do + before do + stub_feature_flags(container_registry_project_statistics: false) + end + + it 'does not update the container_registry_size' do + expect(project).not_to receive(:container_repositories_size) + + update_container_registry_size + + expect(statistics.container_registry_size).to eq(0) + end + end + end + describe '#update_storage_size' do - it "sums all storage counters" do + it "sums the relevant storage counters" do statistics.update!( repository_size: 2, wiki_size: 4, @@ -337,6 +380,18 @@ RSpec.describe ProjectStatistics do expect(statistics.storage_size).to eq 28 end + it 'excludes the container_registry_size' do + statistics.update!( + repository_size: 2, + uploads_size: 5, + container_registry_size: 10 + ) + + statistics.reload + + expect(statistics.storage_size).to eq 7 + end + it 'works during wiki_size backfill' do statistics.update!( repository_size: 2, |