summaryrefslogtreecommitdiff
path: root/spec/services/projects/lfs_pointers
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-08-27 06:07:38 -0700
committerStan Hu <stanhu@gmail.com>2019-08-27 15:52:33 -0700
commit2022e6799bcbf119ea80145e4993ffdb7bb108e3 (patch)
tree19fb831f799ad9353751f7f51b0a5f309f4eead8 /spec/services/projects/lfs_pointers
parenta58f4f00cf7cc8b4755d0d20094cbbd547d31d2b (diff)
downloadgitlab-ce-2022e6799bcbf119ea80145e4993ffdb7bb108e3.tar.gz
Makes LFS object linker process OIDs in batchessh-lfs-object-batches
During a project import, `LfsLinkService` attempts to link `LfsObjects` that have not already been associated with a project. It's possible for a large repo to have thousands of OIDs, which can cause long database query and parsing times. By processing a batch of 1000 at a time, we can reduce that time at the expense of a few more SQL queries. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/66274
Diffstat (limited to 'spec/services/projects/lfs_pointers')
-rw-r--r--spec/services/projects/lfs_pointers/lfs_link_service_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/services/projects/lfs_pointers/lfs_link_service_spec.rb b/spec/services/projects/lfs_pointers/lfs_link_service_spec.rb
index 849601c4a63..66233787d3a 100644
--- a/spec/services/projects/lfs_pointers/lfs_link_service_spec.rb
+++ b/spec/services/projects/lfs_pointers/lfs_link_service_spec.rb
@@ -30,5 +30,23 @@ describe Projects::LfsPointers::LfsLinkService do
expect(subject.execute(new_oid_list.keys)).to eq linked
end
+
+ it 'links in batches' do
+ stub_const("#{described_class}::BATCH_SIZE", 3)
+
+ expect(Gitlab::Import::Logger)
+ .to receive(:info)
+ .with(class: described_class.name,
+ project_id: project.id,
+ project_path: project.full_path,
+ lfs_objects_linked_count: 7,
+ iterations: 3)
+
+ lfs_objects = create_list(:lfs_object, 7)
+ linked = subject.execute(lfs_objects.pluck(:oid))
+
+ expect(project.all_lfs_objects.count).to eq 9
+ expect(linked.size).to eq 7
+ end
end
end