Skip to content

Improve test performance of conan request tests

  • Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you can request access to GitLab Duo.

What does this MR do and why?

While working on another MR, I noticed that there was potential to improve the performance of the conan tests, see the output of the factory profiler before and after this MR.

This MR improves test performance of conan request tests by:

  • Using let_it_be blocks to improve the performance of the tests

🛠️ with ❤️ at Siemens

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

MR Checklist (@gerardo-navarro)

Screenshots or screen recordings

This changes in this MR improve the performance of the conan specs by a significant ammount, see the console output

Before this MR

Here is the console output after succcessfully executing tests with the following command: FPROF=1 bundle exec rspec spec/requests/api/conan/v1/instance_packages_spec.rb spec/requests/api/conan/v1/project_packages_spec.rb ee/spec/requests/api/conan/v1/project_packages_spec.rb

Finished in 12 minutes 15 seconds (files took 1 minute 3.87 seconds to load)
431 examples, 0 failures

Randomized with seed 10477

[TEST PROF INFO] Time spent in factories: 05:59.008 (46.08% of total time)
[TEST PROF INFO] Factories usage

 Total: 8374
 Total top-level: 470
 Total time: 05:59.008 (out of 13:11.446)
 Total uniq factories: 19

   name                    total   top-level     total time      time per call      top-level time

   conan_file_metadatum     2185           0       12.5916s            0.0058s             0.0000s
   conan_package_file       2185           0       42.1722s            0.0193s             0.0000s
   organization              881           0       11.0230s            0.0125s             0.0000s
   project                   878           1      301.1067s            0.3429s             0.1532s
   namespace                 877           0      100.1130s            0.1142s             0.0000s
   conan_package             874         437      503.3127s            0.5759s           352.0380s
   conan_metadatum           437           0      153.5347s            0.3513s             0.0000s
   ci_pipeline                12           0        4.7466s            0.3956s             0.0000s
   ci_build                   12          12        5.3147s            0.4429s             5.3147s
   nuget_package               8           8        0.2553s            0.0319s             0.2553s
   package_file                8           0        0.1898s            0.0237s             0.0000s
   user                        4           1        0.6629s            0.1657s             0.0471s
   personal_access_token       3           3        0.8775s            0.2925s             0.8775s
   license                     3           3        0.0274s            0.0091s             0.0274s
   ip_restriction              2           2        0.0126s            0.0063s             0.0126s
   deploy_token                2           2        0.0292s            0.0146s             0.0292s
   group                       1           1        0.2536s            0.2536s             0.2536s
   namespace_settings          1           0        0.0279s            0.0279s             0.0000s
   namespace_ci_cd_settings    1           0        0.0042s            0.0042s             0.0000s

After this MR

Here is the console output after succcessfully executing tests with the following command: FPROF=1 bundle exec rspec spec/requests/api/conan/v1/instance_packages_spec.rb spec/requests/api/conan/v1/project_packages_spec.rb ee/spec/requests/api/conan/v1/project_packages_spec.rb

Finished in 2 minutes 46.4 seconds (files took 22.01 seconds to load)
431 examples, 0 failures

Randomized with seed 2712

[TEST PROF INFO] Time spent in factories: 00:06.531 (3.8% of total time)
[TEST PROF INFO] Factories usage

 Total: 232
 Total top-level: 40
 Total time: 00:06.531 (out of 03:01.824)
 Total uniq factories: 20

   name                    total   top-level     total time      time per call      top-level time

   conan_file_metadatum       55           0        0.1971s            0.0036s             0.0000s
   conan_package_file         55           0        0.7538s            0.0137s             0.0000s
   conan_package              22          11        6.4576s            0.2935s             3.6878s
   organization               19           0        0.1776s            0.0093s             0.0000s
   project                    16           3        4.3384s            0.2712s             1.3254s
   namespace                  15           0        1.7276s            0.1152s             0.0000s
   conan_metadatum            11           0        2.8027s            0.2548s             0.0000s
   nuget_package               8           8        0.2086s            0.0261s             0.2086s
   package_file                8           0        0.1290s            0.0161s             0.0000s
   user                        4           3        0.2787s            0.0697s             0.2546s
   license                     3           3        0.0218s            0.0073s             0.0218s
   personal_access_token       3           3        0.0689s            0.0230s             0.0689s
   ip_restriction              2           2        0.0110s            0.0055s             0.0110s
   ci_pipeline                 2           0        0.6070s            0.3035s             0.0000s
   project_deploy_token        2           2        0.0150s            0.0075s             0.0150s
   deploy_token                2           2        0.0207s            0.0104s             0.0207s
   ci_build                    2           2        0.7325s            0.3663s             0.7325s
   namespace_settings          1           0        0.0185s            0.0185s             0.0000s
   namespace_ci_cd_settings    1           0        0.0043s            0.0043s             0.0000s
   group                       1           1        0.1852s            0.1852s             0.1852s

How to set up and validate locally

  1. Execute the conan-related tests with the factory profiler
FPROF=1 bundle exec rspec spec/requests/api/conan/v1/instance_packages_spec.rb spec/requests/api/conan/v1/project_packages_spec.rb ee/spec/requests/api/conan/v1/project_packages_spec.rb

Related to #323975

Edited by Gerardo Navarro

Merge request reports

Loading