Skip to content

Greatly reduce test duration for git_access_spec

Robert Speicher requested to merge rs-git-access-spec-speed into master

This spec is slow -- 6+ minutes on CI. Numbers below are local.

Baseline

    Factory usage counts:
      name               total  avg   count
      project-repository 60.452 0.101 601
      user               38.205 0.028 1383
      merge_request      20.799 0.13  160
      namespace          20.101 0.033 616

Finished in 3 minutes 32.9 seconds (files took 6.67 seconds to load)`

Combine multiple it blocks into one where it made sense

    Factory usage counts:
      name               total  avg   count
      project-repository 57.953 0.098 590
      user               36.881 0.027 1361
      merge_request      20.958 0.131 160
      namespace          19.201 0.032 605

Finished in 2 minutes 28.5 seconds (files took 13.19 seconds to load)

Use set for the top-level User record

    Factory usage counts:
      name               total  avg   count
      project-repository 60.995 0.103 590
      merge_request      22.188 0.139 160
      user               21.092 0.028 766
      namespace          20.077 0.033 605

Finished in 2 minutes 19.7 seconds (files took 12.79 seconds to load)

Refactor permission matrix tests

    Factory usage counts:
      name               total  avg   count
      project-repository 10.206 0.102 100
      user               3.841  0.028 136
      namespace          3.774  0.033 115
      merge_request      2.793  0.14  20

Finished in 26.86 seconds (files took 13.24 seconds to load)

🎉

Reduce duplication in GitAccess spec around error messages

  • Adds a new ProjectMovedError class to encapsulate that error condition. Inherits from NotFoundError so existing rescues should continue to work.
  • Separating that condition out of NotFoundError allowed us to simplify the raise_not_found helper and avoid repeating the literal string.
  • Spec makes use of ERROR_MESSAGES hash to avoid repeating literal error message strings.

Merge request reports