Speed up pipeline presenter specs
What does this MR do?
This MR improves the performance of pipeline presenter specs by using let_it_be
and before_all
where applicable.
Related to &3752.
Contributes to https://gitlab.com/gitlab-org/plan/-/issues/145.
Here's the output from test-prof
when run with FPROF=1
. Note:
-
Total
amount of factories created went down from 228 to 37🚀 -
Total events
went down from 7677 to 1641 - Queries saved: 6036
Before
[TEST PROF INFO] EventProf results for sql.active_record
Total time: 00:11.392 of 00:23.731 (48.01%)
Total events: 7677
Top 5 slowest suites (by time):
Ci::PipelinePresenter (./spec/presenters/ci/pipeline_presenter_spec.rb:5) – 00:11.392 (7677 / 46) of 00:23.731 (48.01%)
Finished in 29.44 seconds (files took 2.13 seconds to load)
46 examples, 0 failures
[TEST PROF INFO] Factories usage
Total: 228
Total top-level: 152
Total time: 18.1097s
Total uniq factories: 6
total top-level total time time per call top-level time name
53 46 10.5854s 0.1997s 9.2279s project
53 0 2.5169s 0.0475s 0.0000s namespace
52 52 2.0841s 0.0401s 2.0841s user
46 30 1.4166s 0.0308s 0.9277s ci_pipeline
23 23 5.8630s 0.2549s 5.8630s merge_request
1 1 0.0070s 0.0070s 0.0070s license
After
[TEST PROF INFO] EventProf results for sql.active_record
Total time: 00:02.430 of 00:06.481 (37.51%)
Total events: 1641
Top 5 slowest suites (by time):
Ci::PipelinePresenter (./spec/presenters/ci/pipeline_presenter_spec.rb:5) – 00:02.430 (1641 / 46) of 00:06.481 (37.51%)
Finished in 11.98 seconds (files took 9.09 seconds to load)
46 examples, 0 failures
[TEST PROF INFO] Factories usage
Total: 37
Total top-level: 22
Total time: 4.6656s
Total uniq factories: 6
total top-level total time time per call top-level time name
10 10 3.6072s 0.3607s 3.6072s merge_request
9 3 0.3345s 0.0372s 0.1103s ci_pipeline
7 7 0.4449s 0.0636s 0.4449s user
5 1 1.3331s 0.2666s 0.4950s project
5 0 0.2294s 0.0459s 0.0000s namespace
1 1 0.0082s 0.0082s 0.0082s license
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
- [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Peter Leitzen