Speed up container registry authentication service specs
What does this MR do?
This MR improves the performance of container registry authentication service specs by heavily using let_it_be
and before_all
.
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 1241 to 156🚀 -
Total events
went down from 40479 to 6073 - Queries saved: 34406
Before
[TEST PROF INFO] EventProf results for sql.active_record
Total time: 01:06.654 of 02:14.616 (49.51%)
Total events: 40479
Top 5 slowest suites (by time):
Auth::Contain...icationService (./spec/services/auth/container_registry_authentication_service_spec.rb:5) – 01:06.654 (40479 / 398) of 02:14.616 (49.51%)
Finished in 2 minutes 20.3 seconds (files took 2.4 seconds to load)
398 examples, 0 failures
[TEST PROF INFO] Factories usage
Total: 1241
Total top-level: 812
Total time: 106.9869s
Total uniq factories: 6
total top-level total time time per call top-level time name
447 447 91.1247s 0.2039s 91.1247s project
429 0 22.5282s 0.0525s 0.0000s namespace
251 251 12.4046s 0.0494s 12.4046s user
95 95 2.6231s 0.0276s 2.6231s deploy_token
18 18 0.8266s 0.0459s 0.8266s admin
1 1 0.0078s 0.0078s 0.0078s license
After
[TEST PROF INFO] EventProf results for sql.active_record
Total time: 00:09.233 of 00:25.366 (36.4%)
Total events: 6073
Top 5 slowest suites (by time):
Auth::Contain...icationService (./spec/services/auth/container_registry_authentication_service_spec.rb:5) – 00:09.233 (6073 / 398) of 00:25.366 (36.4%)
Finished in 31.18 seconds (files took 2.39 seconds to load)
398 examples, 0 failures
[TEST PROF INFO] Factories usage
Total: 156
Total top-level: 126
Total time: 9.7079s
Total uniq factories: 6
total top-level total time time per call top-level time name
81 81 2.5188s 0.0311s 2.5188s deploy_token
33 33 6.6206s 0.2006s 6.6206s project
30 0 1.6170s 0.0539s 0.0000s namespace
10 10 0.5114s 0.0511s 0.5114s user
1 1 0.0072s 0.0072s 0.0072s license
1 1 0.0498s 0.0498s 0.0498s admin
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