test: Install Gitaly incrementally

What does this MR do and why?

In 08af0f9f (Speed up gitaly setup in tests, 2021-07-20) the setup of Gitaly was sped up in test by copying it over from GDK whenever possible. This drastically reduced the setup time, but it complicates installations of Ruby gems in Gitaly.

This change rolls back that copy-from-GDK installation, but instead incrementally installs Gitaly. So instead of removing tmp/tests/gitaly completely and setting up from scratch, we now fetch the revision specified in GITALY_SERVER_VERSION and trust make inside the Gitaly directory to The Right Thing(tm).

Combined with the introduction of gitlab-development-kit@d2229da0 (Makefile: Stop nuking gitlab/tmp/tests/gitaly, 2021-12-06) this should avoid Gitaly in test ever again would be built from scratch.

In case this would not work in some situations, we still look at FORCE_GITALY_INSTALL and if the environment variable is set tmp/tests/gitaly is deleted before installing Gitaly again.

With these changes, now scripts/gitaly-test-build & scripts/gitaly-test-spawn are only used in CI. When running tests in a local GDK, the Ruby code to build and spawn Gitaly in test is directly called from TestEnv.init.

Before these changes I was not able to run tests with vendored gems, but now I am.

Closes #344274 (closed)

How to set up and validate locally

  • Run any test locally
  • Run rm -rf tmp/tests/gitaly and try running the test again
  • Run any test, but with FORCE_GITALY_INSTALL=1 set in the environment

Benchmarks

Disclaimer:

  • I ran these on my local machine and only for a single run, so the numbers are rather indicative.
  • To test an "Update" I've changed GITALY_SERVER_VERSION from gitaly@0e0aeb5c to gitaly@152dd3c6
  • It wasn't the objective of this MR to make it faster, but more reliable on any system, and easier to maintain.
  • I think in many cases on master an incorrect version of Gitaly would be used, most often it would not be an issue, but with this MR that should not happen no more. This will help us in the future when we introduce #336749 (closed).
Clean install Update FORCE... update
master 9.907706319s 8.924018147s 156.177587381s
this MR 156.741139316s 14.92400761s 153.790645001s

Possible future improvements

Improvements can be built on top of this MR.

  • We can consider running something like make -C <gdk>/gitaly DESTDIR=tmp/tests/gitaly PREFIX=_build
  • That could be part of gdk update, so instead of testing if the GitLab install is part of GDK, build that as part of GDK itself.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Toon Claes

Merge request reports

Loading