Optimize factory usage in clusters/deployment_entity_spec
What does this MR do and why?
This MR replaces create with build_stubbed in ee/spec/serializers/clusters/deployment_entity_spec.rb to optimize factory
usage as recommended in our handbook.
This spec is part of the list .rubocop_todo/rspec/factory_bot/avoid_create.yml.
It was verified that database persistence is not needed using the factory doctor
command FDOC=1 bin/rspec ee/spec/serializers/clusters/deployment_entity_spec.rb.
Factory Usage Optimization Results
Before optimization:
- Factory time: 2.948s (17.54% of total time)
After optimization:
- Factory time: 0.368s (2.68% of total time)
Improvement:
- Factory time reduced by: 2.580s
- Factory time percentage reduced by: 14.86%
- Overall factory usage improvement: 87.52%
Factory Doctor Output
[TEST PROF INFO] FactoryDoctor report
Total (potentially) bad examples: 3
Total wasted time: 00:02.883
Clusters::DeploymentEntity (./ee/spec/serializers/clusters/deployment_entity_spec.rb:5) (21 records created, 00:02.883)
exposes deployable name (./ee/spec/serializers/clusters/deployment_entity_spec.rb:18) – 7 records created, 00:01.721
exposes id (./ee/spec/serializers/clusters/deployment_entity_spec.rb:10) – 7 records created, 00:00.577
exposes iid (./ee/spec/serializers/clusters/deployment_entity_spec.rb:14) – 7 records created, 00:00.584This MR also adds the missing feature_category to this spec.
References
Relates to: #378910
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Marcos Rocha