Cleanup deployment class
What does this MR do and why?
This MR refactors deployment
and deployment_spec
classes, it cleans up Rubocop offences, and improves the specs' performance.
As result, we achieved close to 40% reduction in spec execution.
In addition, it takes care of Drop `cluster_id` column in `deployments` table (#427682 - closed).
Specs
Before
[TEST PROF INFO] Time spent in factories: 02:26.695 (80.62% of total time)
[TEST PROF INFO] Factories usage
Total: 1731
Total top-level: 499
Total time: 02:26.695 (out of 03:11.449)
Total uniq factories: 13
total top-level total time time per call top-level time name
253 32 22.3941s 0.0885s 1.1933s ci_pipeline
253 0 1.3575s 0.0054s 0.0000s ci_stage
249 76 15.3620s 0.0617s 9.5983s ci_build
244 244 105.3392s 0.4317s 105.3392s deployment
233 0 17.8835s 0.0768s 0.0000s namespace
233 31 115.1615s 0.4943s 15.9996s project
190 41 86.0821s 0.4531s 1.9113s environment
60 60 7.8808s 0.1313s 7.8808s ci_bridge
7 7 0.2443s 0.0349s 0.2443s user
6 6 4.3211s 0.7202s 4.3211s merge_request
1 1 0.0107s 0.0107s 0.0107s license
1 1 0.1973s 0.1973s 0.1973s jira_connect_subscription
1 0 0.1900s 0.1900s 0.0000s jira_connect_installation
After
[TEST PROF INFO] Time spent in factories: 01:21.692 (73.01% of total time)
[TEST PROF INFO] Factories usage
Total: 1111
Total top-level: 342
Total time: 01:21.692 (out of 02:00.691)
Total uniq factories: 13
total top-level total time time per call top-level time name
176 75 12.5459s 0.0713s 9.6013s ci_build
173 173 59.8195s 0.3458s 59.8195s deployment
163 0 0.8670s 0.0053s 0.0000s ci_stage
156 10 17.1754s 0.1101s 0.2607s ci_pipeline
136 2 62.0089s 0.4559s 1.7103s project
136 0 10.6795s 0.0785s 0.0000s namespace
97 9 48.2070s 0.4970s 0.0797s environment
59 59 6.8566s 0.1162s 6.8566s ci_bridge
7 7 0.2410s 0.0344s 0.2410s user
5 5 2.9181s 0.5836s 2.9181s merge_request
1 1 0.1954s 0.1954s 0.1954s jira_connect_subscription
1 0 0.1827s 0.1827s 0.0000s jira_connect_installation
1 1 0.0096s 0.0096s 0.0096s license
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Edited by Bojan Marjanovic