Reduce database calls on CI Templates specs
What does this MR do?
Reduce database calls on CI Templates specs
This change replaces let
with let_it_be
to reduce unnecessary number
of database calls on CI Templates specs. We also replace all instances
of allow_any_instance_of
stubs with allow_next_instance_off
according to the Rubocop lint rules.
Before: 724 calls, 4 minutes 29.7 seconds
Finished in 4 minutes 29.7 seconds (files took 39.46 seconds to load)
204 examples, 0 failures
Randomized with seed 8506
[TEST PROF INFO] Factories usage
Total: 724
Total top-level: 435
Total time: 102.0235s
Total uniq factories: 9
total top-level total time time per call top-level time name
198 198 92.7114s 0.4682s 92.7114s project
198 0 17.3099s 0.0874s 0.0000s namespace
140 140 1.3582s 0.0097s 1.3582s license
80 80 1.0749s 0.0134s 1.0749s ci_variable
39 0 3.2725s 0.0839s 0.0000s user
39 13 7.5797s 0.1944s 5.1383s cluster
13 0 1.5845s 0.1219s 0.0000s cluster_platform_kubernetes
13 0 1.4302s 0.1100s 0.0000s cluster_provider_gcp
4 4 1.7406s 0.4352s 1.7406s merge_request
After: 482 calls, 3 minutes 42.5 seconds
Finished in 3 minutes 42.5 seconds (files took 11.45 seconds to load)203 examples, 0 failures
Randomized with seed 15799
[TEST PROF INFO] Factories usage
Total: 482
Total top-level: 246
Total time: 71.7134s
Total uniq factories: 9
total top-level total time time per call top-level time name
145 145 64.2338s 0.4430s 64.2338s project
145 0 11.3681s 0.0784s 0.0000s namespace
69 69 0.8523s 0.0124s 0.8523s ci_variable
39 13 7.1232s 0.1826s 4.8595s cluster
39 0 3.0037s 0.0770s 0.0000s user
15 15 0.1450s 0.0097s 0.1450s license
13 0 1.3385s 0.1030s 0.0000s cluster_provider_gcp
13 0 1.5114s 0.1163s 0.0000s cluster_platform_kubernetes
4 4 1.6228s 0.4057s 1.6228s merge_request
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?-
I have included a changelog entry. -
I have not included a changelog entry because this change is development-facing only.
-
- [-] 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 Tan Le