Skip to content

Improve group_service_spec.rb spec speed

Terri Chu requested to merge 482020-improve-slow-tests into master

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:

  1. fixes Rubocop TODOs
  2. verified test order going to random using https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#test-order
  3. move all factory creates to let_it_be, this required using Elastic::ProcessInitialBookkeeping.track! methods to be added. I've found this is a good way to avoid recreating data for every test
  4. remove sidekiq_inline unless testing git backed data: commits, blobs, and wikis
  5. 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

Merge request reports

Loading