Commit 1e4c07a6 authored by Terri Chu's avatar Terri Chu

Change ElasticDeleteProjectWorker to delete by project_id

parent 00d3a4eb
......@@ -25,16 +25,18 @@ class ElasticDeleteProjectWorker
bool: {
should: [
{
has_parent: {
parent_type: 'project',
query: {
term: { id: project_id }
}
term: {
_id: es_id
}
},
{
term: {
_id: es_id
project_id: project_id
}
},
{
term: {
target_project_id: project_id # handle merge_request which aliases project_id to target_project_id
}
}
]
......
......@@ -14,7 +14,7 @@ RSpec.describe ElasticDeleteProjectWorker, :elastic do
stub_ee_application_setting(elasticsearch_indexing: true)
end
it 'deletes a project with all nested objects' do
it 'deletes a project with all nested objects', :aggregate_failures do
project = create :project, :repository
issue = create :issue, project: project
milestone = create :milestone, project: project
......@@ -38,5 +38,12 @@ RSpec.describe ElasticDeleteProjectWorker, :elastic do
expect(Milestone.elastic_search('*', **search_options).total_count).to be(0)
expect(Note.elastic_search('*', **search_options).total_count).to be(0)
expect(MergeRequest.elastic_search('*', **search_options).total_count).to be(0)
# verify that entire index is empty
# searches use joins on the parent record (project)
# and the previous queries will not find data left in the index
helper = Gitlab::Elastic::Helper.default
expect(helper.documents_count).to be(0)
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