Improve group_service_spec.rb spec speed
What does this MR do and why?
Related to #482020 (closed)
for ee/spec/services/search/group_service_spec.rb
this MR makes a bunch of changes:
- fixes Rubocop TODOs
- verified test order going to random using https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#test-order
- move all factory creates to
let_it_be
, this required usingElastic::ProcessInitialBookkeeping.track!
methods to be added. I've found this is a good way to avoid recreating data for every test - remove
sidekiq_inline
unless testinggit
backed data: commits, blobs, and wikis - move wiki visibility tests into their own spec file:
ee/spec/services/search/group_service_wiki_visibility_spec.rb
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
N/A
Before
from issue
The total running time of ./ee/spec/services/search/group_service_spec.rb is 1533.97 seconds (25.56min) and it executes 103124 queries.
After
local runs are much faster
> bundle exec rspec ee/spec/services/search/group_service_spec.rb
...
Finished in 8 minutes 55 seconds (files took 5.3 seconds to load)
545 examples, 0 failures
Randomized with seed 31360
[TEST PROF INFO] Time spent in factories: 00:32.385 (5.98% of total time)
> bundle exec rspec ee/spec/services/search/group_service_wiki_visibility_spec.rb
...
Finished in 4 minutes 36.2 seconds (files took 5.55 seconds to load)
85 examples, 0 failures
Randomized with seed 49092
[TEST PROF INFO] Time spent in factories: 00:06.373 (2.26% of total time)```
How to set up and validate locally
N/A
Edited by Terri Chu