Commit e2ed31b1 authored by Terri Chu's avatar Terri Chu

Index wiki after project import finishes

Add a call to index the wiki repository after project import is
finished for Elastic Search enabled projects. This will only be
run if the project is being imported and is not a fork. The indexing
for wiki repositories will not run when mirrors are updated.
parent 76a8a8c7
......@@ -596,6 +596,10 @@ module EE
repository.log_geo_updated_event
wiki.repository.log_geo_updated_event
design_repository.log_geo_updated_event
# Index the wiki repository after import of non-forked projects only, the project repository is indexed
# in ProjectImportState so ElasticSearch will get project repository changes when mirrors are updated
ElasticCommitIndexerWorker.perform_async(id, nil, nil, true) if use_elasticsearch? && !forked?
end
override :import?
......
---
title: Fix wiki indexing for imported projects.
merge_request: 29952
author:
type: fixed
......@@ -1728,6 +1728,41 @@ describe Project do
project.after_import
end
context 'elasticsearch indexing disabled for this project' do
before do
expect(project).to receive(:use_elasticsearch?).and_return(false)
end
it 'does not index the wiki repository' do
expect(ElasticCommitIndexerWorker).not_to receive(:perform_async)
project.after_import
end
end
context 'elasticsearch indexing enabled for this project' do
before do
expect(project).to receive(:use_elasticsearch?).and_return(true)
end
it 'schedules a full index of the wiki repository' do
expect(ElasticCommitIndexerWorker).to receive(:perform_async).with(project.id, nil, nil, true)
project.after_import
end
context 'when project is forked' do
before do
expect(project).to receive(:forked?).and_return(true)
end
it 'does not index the wiki repository' do
expect(ElasticCommitIndexerWorker).not_to receive(:perform_async)
project.after_import
end
end
end
end
describe '#lfs_http_url_to_repo' do
......
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