Add the archived in the MilestoneInstanceProxy
What does this MR do and why?
This MR is setting the boolean archived
field value for the milestone
documents if the migration add_archived_to_main_index
is finished. Also setting elastic_index_dependant_association
on milestone
to synch the archived values for milestone documents
Screenshots or screen recordings
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
- Ensure Elasticsearch is enabled in the
gdk
Case migration add_archived_to_main_index
is not finished
- To simulate this case make an early return here
def migration_has_finished?(name)
return false if name.eql?(:add_archived_to_main_index)
Rails.cache.fetch cache_key(:migration_has_finished, name.to_s.underscore), expires_in: CACHE_TIMEOUT do
migration_has_finished_uncached?(name)
end
end
- Create a new milestone in any project that is allowed to use elasticsearch
- Check the Elastic that the new milestone should not have an
archived
field - Now archive that project, and again check on Elastic, the
archived
field still should not be present for this milestone - Again unarchive the project and make sure on Elastic, the
archived
field still should not be present for this milestone
Case migration add_archived_to_main_index
is finished
- To be sure the migration is finished, run the following commands in the rails console. To start the rails console run the following command.
bundle exec rails c
- Now in the console run the following commands
require_relative 'ee/elastic/migrate/20230719144243_add_archived_to_main_index.rb'
AddArchivedToNotes.new(20230719144243).migrate
- Create a new milestone on any project
- Check the Elastic that the new note should have an
archived
field - Now archive that project, and again check on Elastic, the
archived
field should be set totrue
- Again
unarchive
the project and make sure on Elastic, thearchived
field should be set tofalse
This is a curl request you can use to check the milestone. Replace the project_id
with the one you used for the testing
curl -XGET "http://localhost:9200/gitlab-development/_search" -H "kbn-xsrf: reporting" -H "Content-Type: application/json" -d'
{
"query": {
"bool": {
"filter": [
{
"term": {
"project_id": #{project_id}
}
},
{
"term": {
"type": "milestone"
}
}
]
}
}
}' | json_pp
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #421464 (closed)