Fix flaky ee/spec/requests/api/graphql/search/blob_search_spec.rb
What does this MR do and why?
Summary of Changes
This merge request improves the testing setup for the Zoekt search integration in GitLab. The main changes:
-
Restructured the test setup by moving project indexing operations from individual test blocks to
before_allandafter_allhooks, ensuring indexes are properly created once before tests run and cleaned up afterward. -
Added
zoekt_truncate_index!calls to clean up the search index before and after tests, preventing test pollution. -
Simplified the blob search test by using a smaller repository with a simpler test file ("test.txt" instead of "PROCESS.md"), making the test more focused and reliable.
-
Improved the indexing wait logic by checking against the actual file count and increasing the maximum wait time, giving Zoekt more time to complete indexing.
-
Removed the
:zoekttag from the client spec, making it consistent with other tests. -
Updated test expectations to match the simplified test data, making tests more predictable.
These changes make the Zoekt search tests more reliable by properly setting up and tearing down test data, and by using simpler test cases that are less likely to be affected by changes to the codebase.
The main fixes to fix the flakiness are following:
- Increase the time to allow indexing to finish.
- With increasing time, the test runs longer and during the test, the Node went offline because the ThresholdOnline is 1 minute. I stubbed this to 5 minutes in the test
References
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #541530 (closed)