Improve search global service spec
Description
This improves the eight slow test (see Rspec stats), from 16:01 to 9:53 minutes.
Before
[TEST PROF INFO] Time spent in factories: 01:19.103 (8.19% of total time)
[TEST PROF INFO] Factories usage
Total: 1435
Total top-level: 971
Total time: 01:19.103 (out of 16:06.204)
Total uniq factories: 23
name total top-level total time time per call top-level time
user 475 452 28.1878s 0.0593s 26.9959s
work_item_type 239 0 2.0330s 0.0085s 0.0000s
issue 161 119 13.7891s 0.0856s 10.2210s
merge_request 108 66 11.7816s 0.1091s 7.7600s
work_item 78 60 7.5636s 0.0970s 6.5948s
note 71 71 2.3655s 0.0333s 2.3655s
note_on_merge_request 42 42 5.9426s 0.1415s 5.9426s
note_on_issue 42 42 5.7773s 0.1376s 5.7773s
note_on_commit 42 42 2.9351s 0.0699s 2.9351s
project_snippet 42 0 1.2129s 0.0289s 0.0000s
note_on_project_snippet 42 42 3.3165s 0.0790s 3.3165s
epic 36 18 3.9129s 0.1087s 2.5066s
author 18 0 1.0780s 0.0599s 0.0000s
organization 9 0 0.0831s 0.0092s 0.0000s
project 8 8 4.1108s 0.5138s 4.1108s
namespace 5 0 0.3677s 0.0735s 0.0000s
group 4 4 0.4241s 0.1060s 0.4241s
namespace_settings 4 0 0.0307s 0.0077s 0.0000s
namespace_ci_cd_settings 4 0 0.0119s 0.0030s 0.0000s
group_wiki 2 2 0.0817s 0.0408s 0.0817s
admin 1 1 0.0291s 0.0291s 0.0291s
milestone 1 1 0.0280s 0.0280s 0.0280s
license 1 1 0.0141s 0.0141s 0.0141s
After
[TEST PROF INFO] Time spent in factories: 01:03.838 (10.71% of total time)
[TEST PROF INFO] Factories usage
Total: 1366
Total top-level: 928
Total time: 01:03.838 (out of 09:56.957)
Total uniq factories: 23
name total top-level total time time per call top-level time
user 475 452 21.9561s 0.0462s 20.9162s
work_item_type 215 0 1.8195s 0.0085s 0.0000s
issue 137 95 11.0249s 0.0805s 7.3172s
merge_request 90 48 8.2931s 0.0921s 4.4873s
work_item 78 60 7.4833s 0.0959s 6.3001s
note 71 71 2.2081s 0.0311s 2.2081s
note_on_issue 42 42 6.2174s 0.1480s 6.2174s
project_snippet 42 0 1.0324s 0.0246s 0.0000s
note_on_project_snippet 42 42 3.0582s 0.0728s 3.0582s
note_on_commit 42 42 2.3133s 0.0551s 2.3133s
note_on_merge_request 42 42 5.4997s 0.1309s 5.4997s
epic 36 18 3.8234s 0.1062s 2.4936s
author 18 0 0.8692s 0.0483s 0.0000s
organization 8 0 0.0667s 0.0083s 0.0000s
project 7 7 2.4927s 0.3561s 2.4927s
group 4 4 0.3968s 0.0992s 0.3968s
namespace 4 0 0.2963s 0.0741s 0.0000s
namespace_ci_cd_settings 4 0 0.0191s 0.0048s 0.0000s
namespace_settings 4 0 0.0266s 0.0066s 0.0000s
group_wiki 2 2 0.0603s 0.0301s 0.0603s
admin 1 1 0.0401s 0.0401s 0.0401s
milestone 1 1 0.0250s 0.0250s 0.0250s
license 1 1 0.0126s 0.0126s 0.0126s
Some strategies used:
- Convert
let
tolet_it_be
- Remove
sidekiq_inline
if possible
Extra:
- Fix Rubocop TODOs
- Tested running in random order
Reference: https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#test-slowness
Related to #491671 (closed).
Edited by Arturo Herrero