Clean up orphan indices in elastic test teardown

What does this MR do and why?

The Elasticsearch test teardown helper delete_indices!(ee/spec/support/elastic.rb) enumerates indices via aliases only. An un-aliased index auto-created by a non :elastic spec performing a real bulk index (e.g. gitlab-test-projects) is therefore never cleaned up. The orphan leaks across specs in the same RSpec process and makes a later create_standalone_indices fail with Index or alias under 'gitlab-test-projects' already exists.

This MR changes delete_indices! to enumerate by index pattern so orphans are removed too. It deletes the same logical set as before plus orphans.

This is a pre-requisite for continuing the BulkIndexer namespace migration: moving the spec into Search::Elastic changes predictive test selection so bulk_indexer_spec runs after the bookkeeping spec in one process, exposing this leak and failing rspec-ee unit predictive. Landing this fix first lets that work proceed on a clean test suite.

Full diagnosis and verification by Terri Chu: !238696 (comment 3434353747)

References

Namespace migration: #398183 (closed)

Edited by aishahsofea

Merge request reports

Loading