Fix flaky spec for data_migration_service_spec.rb

What does this MR do and why?

Flaky spec reported in an unrelated MR, so I opened this MR to fix it separately

Issue was use of :elastic trait in the spec. This only creates the Elasticsearch index one time, so any modifications to the migration records (stored in the index) are not cleaned up. since :elastic trait is faster, I chose to do a cleanup step after in the failing specs otherwise the test time is going to increase dramatically.

Screenshots or screen recordings

N/A

How to set up and validate locally

you can reproduce the failure with the seed from the pipeline failure

bundle exec rspec ee/spec/services/elastic/data_migration_service_spec.rb --seed 3600 -f d

Do this on master branch and it will fail and will pass on this branch.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading