Optionally run rspec tests with Gitaly Praefect using real database
What does this MR do and why?
At the moment tests use Praefect with the in-memory election strategy. This strategy is deprecated, and we at Gitaly like to get rid of it. But it's still used in testing.
This MR introduces the first GITALY_PRAEFECT_WITH_DB=1
in the environment.
There's also a job added to CI to run tests like this, but for now it's only triggered manually and allowed to fail.
Part of #336749 (closed)
How to set up and validate locally
-
You need to make sure PostgreSQL is running:
gdk start db
-
You need to load the DB environment from GDK:
cd ../gitaly && eval $(gdk env) && cd -
-
Create the database:
createdb --encoding=UTF8 --locale=C --echo praefect_test
-
By default Praefect isn't used in GDK, so enable that in
config/gitlab.yml
:diff --git a/config/gitlab.yml b/config/gitlab.yml index 5d6b720b..115606f4 100644 --- a/config/gitlab.yml +++ b/config/gitlab.yml @@ -1065,7 +1065,7 @@ test: storages: default: path: tmp/tests/repositories/ - gitaly_address: unix:tmp/tests/gitaly/gitaly.socket + gitaly_address: unix:tmp/tests/gitaly/praefect.socket gitaly: token: secret
-
Run a test that fails when using in-db election:
GITALY_PRAEFECT_WITH_DB=1 be rspec spec/requests/api/commits_spec.rb
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.