Commit bdd25de6 authored by Nick Thomas's avatar Nick Thomas

Implement progressive elasticsearch indexing for project mirrors

parent 9f2608ba
...@@ -47,7 +47,10 @@ module EE ...@@ -47,7 +47,10 @@ module EE
end end
if current_application_settings.elasticsearch_indexing? if current_application_settings.elasticsearch_indexing?
project.run_after_commit { ElasticCommitIndexerWorker.perform_async(project.id) } project.run_after_commit do
last_indexed_commit = project.index_status&.last_commit
ElasticCommitIndexerWorker.perform_async(project.id, last_indexed_commit)
end
end end
end end
......
---
title: Implement progressive elasticsearch indexing for project mirrors
merge_request: 2393
author:
...@@ -1824,6 +1824,46 @@ describe Project, models: true do ...@@ -1824,6 +1824,46 @@ describe Project, models: true do
expect(housekeeping_service).not_to have_received(:execute) expect(housekeeping_service).not_to have_received(:execute)
end end
context 'elasticsearch indexing disabled' do
before do
stub_application_setting(elasticsearch_indexing: false)
end
it 'does not index the repository' do
project = create(:empty_project, :import_started, import_type: :github)
expect(ElasticCommitIndexerWorker).not_to receive(:perform_async)
project.import_finish
end
end
context 'elasticsearch indexing enabled' do
let(:project) { create(:project, :import_started, import_type: :github) }
before do
stub_application_setting(elasticsearch_indexing: true)
end
context 'no index status' do
it 'schedules a full index of the repository' do
expect(ElasticCommitIndexerWorker).to receive(:perform_async).with(project.id, nil)
project.import_finish
end
end
context 'with index status' do
let!(:index_status) { project.create_index_status!(indexed_at: Time.now, last_commit: 'foo') }
it 'schedules a progressive index of the repository' do
expect(ElasticCommitIndexerWorker).to receive(:perform_async).with(project.id, index_status.last_commit)
project.import_finish
end
end
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment