Speed up metrics dashboard annotation policy specs
What does this MR do?
This MR improves the performance of metrics dashboard annotation policy specs by using let_it_be
where applicable.
Related to &3752.
Here's the output from test-prof
when run with FPROF=1
. Note:
-
Total
amount of factories created went down from 177 to 11🚀 - A tiny speed improvement from ~19s down to ~12s
Before
Finished in 18.59 seconds (files took 2.04 seconds to load)
32 examples, 0 failures
[TEST PROF INFO] Factories usage
Total: 177
Total top-level: 97
Total time: 9.0351s
Total uniq factories: 7
total top-level total time time per call top-level time name
48 32 2.2580s 0.0470s 1.2036s user
32 0 5.8768s 0.1837s 0.0000s project
32 0 1.4873s 0.0465s 0.0000s namespace
32 32 0.1483s 0.0046s 0.1483s metrics_dashboard_annotation
16 16 4.5745s 0.2859s 4.5745s cluster
16 16 3.0968s 0.1936s 3.0968s environment
1 1 0.0119s 0.0119s 0.0119s license
Total sql.active_record
events: 4233
After
32 examples, 0 failures
[TEST PROF INFO] Factories usage
Total: 11
Total top-level: 6
Total time: 0.8200s
Total uniq factories: 7
total top-level total time time per call top-level time name
2 1 0.1116s 0.0558s 0.0743s user
2 0 0.5364s 0.2682s 0.0000s project
2 0 0.0714s 0.0357s 0.0000s namespace
2 2 0.0260s 0.0130s 0.0260s metrics_dashboard_annotation
1 1 0.0061s 0.0061s 0.0061s license
1 1 0.4691s 0.4691s 0.4691s cluster
1 1 0.2445s 0.2445s 0.2445s environment
Total sql.active_record
events: 1345
Queries saved: 2888
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