Skip to content

Speed up EE project policy specs

Peter Leitzen requested to merge pl-speedup-spec-policy-project into master

What does this MR do?

This MR improves the performance of EE project policy specs by using let_it_be and before_all (thanks to @dosuken123) and reusing created factories.

Related to &3752.

Here's the output from test-prof when run with FPROF=1. Note:

  • Total amount of factories created went down from 550 to 237 🚀
  • Speed improvement from 2m50s down to 40s (mostly due to the use of before_all) 🚀

Before

Finished in 2 minutes 50 seconds (files took 2.42 seconds to load)
372 examples, 0 failures

Randomized with seed 4099

[TEST PROF INFO] Factories usage

 Total: 550
 Total top-level: 484
 Total time: 56.9410s
 Total uniq factories: 13

   total   top-level   total time   top-level time                           name

     384         372     53.2865s         51.0458s                        project
      57          37      2.2574s          1.4687s                           user
      34           0      1.4563s          0.0000s                      namespace
      26          26      0.8180s          0.8180s                          group
       8           8      0.3919s          0.3919s                          admin
       8           8      1.5054s          1.5054s               push_rule_sample
       8           8      0.1868s          0.1868s                  saml_provider
       8           8      0.2544s          0.2544s            group_saml_identity
       4           4      0.0353s          0.0353s      push_rule_without_project
       4           4      0.8071s          0.8071s                      push_rule
       4           4      0.0212s          0.0212s                 ip_restriction
       4           4      0.3983s          0.3983s                   group_member
       1           1      0.0081s          0.0081s                        license

After

Finished in 40.83 seconds (files took 2.19 seconds to load)
372 examples, 0 failures

Randomized with seed 12084

[TEST PROF INFO] Factories usage

 Total: 237
 Total top-level: 171
 Total time: 14.5346s
 Total uniq factories: 13

   total   top-level   total time   top-level time                           name

      80          68     11.6853s          9.6882s                        project
      48          28      1.8275s          1.0739s                           user
      34           0      1.3269s          0.0000s                      namespace
      26          26      0.7996s          0.7996s                          group
       8           8      0.3692s          0.3692s                          admin
       8           8      1.4188s          1.4188s               push_rule_sample
       8           8      0.0911s          0.0911s                  saml_provider
       8           8      0.0708s          0.0708s            group_saml_identity
       4           4      0.6654s          0.6654s                      push_rule
       4           4      0.0276s          0.0276s      push_rule_without_project
       4           4      0.2970s          0.2970s                   group_member
       4           4      0.0201s          0.0201s                 ip_restriction
       1           1      0.0129s          0.0129s                        license

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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

Merge request reports