Reduce amount of project factory creations in ErrorTracking API specs
requested to merge 393904-error-tracking-make-api-specs-faster-and-reduce-amount-of-project-factory-creations into master
What does this MR do and why?
This MR reduces the amount of factory creations (project
) and also:
- Fix some RuboCop offenses for
RSpec/ContextWording
- Remove specs for Reporter access since we are testing Developer already
- Run specs in random order
RSpec Profiling
Here's the output from test-prof
when run with FPROF=1
. Note:
-
Total amount
of factories created went down from 116 to 34🚀 -
Total events
went down from 5046 to 2074 - Queries saved: 2972
Before
Finished in 27.56 seconds (files took 12.02 seconds to load)
30 examples, 0 failures
Randomized with seed 6059
[TEST PROF INFO] Time spent in factories: 00:09.592 (32.01% of total time)
[TEST PROF INFO] Factories usage
Total: 116
Total top-level: 59
Total time: 00:09.592 (out of 00:37.725)
Total uniq factories: 6
total top-level total time time per call top-level time name
30 3 7.8077s 0.2603s 0.6139s project
30 0 2.6931s 0.0898s 0.0000s namespace
27 27 8.2645s 0.3061s 8.2645s project_error_tracking_setting
27 27 0.2980s 0.0110s 0.2980s personal_access_token
1 1 0.4079s 0.4079s 0.4079s user
1 1 0.0085s 0.0085s 0.0085s license
After
Finished in 16.95 seconds (files took 10.28 seconds to load)
27 examples, 0 failures
Randomized with seed 1702
[TEST PROF INFO] Time spent in factories: 00:01.659 (8.7% of total time)
[TEST PROF INFO] Factories usage
Total: 34
Total top-level: 30
Total time: 00:01.659 (out of 00:24.959)
Total uniq factories: 6
total top-level total time time per call top-level time name
24 24 0.3211s 0.0134s 0.3211s personal_access_token
3 2 0.9110s 0.3037s 0.6815s project
3 0 0.2031s 0.0677s 0.0000s namespace
2 2 0.3040s 0.1520s 0.3040s project_error_tracking_setting
1 1 0.3445s 0.3445s 0.3445s user
1 1 0.0079s 0.0079s 0.0079s license
How to set up and validate locally
bin/rspec spec/requests/api/error_tracking/project_settings_spec.rb
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #393904 (closed)
Edited by Peter Leitzen