ci: Make TestEnv not depend on Rails nor a DB connection [RUN ALL RSPEC]
What does this MR do?
Control job
7 seconds
Preparing the "docker+machine" executor
Using Docker executor with image registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.7.2.patched-golang-1.14-git-2.31-lfs-2.9-chrome-89-node-14.15-yarn-1.22-postgresql-12-graphicsmagick-1.3.36 ...
Starting service postgres:12 ...
Pulling docker image postgres:12 ...
Using docker image sha256:e782ad565d74bbe4dc50b2e76612e386c6cfbf3dcb32720b2b4c2fdec71bd822 for postgres:12 with digest postgres@sha256:06277995d7028f4455e56f21864146ee2425c83308dc96283c7a96e6881cc826 ...
Starting service redis:5.0-alpine ...
Pulling docker image redis:5.0-alpine ...
Using docker image sha256:618083532dc7c70fde98a8bb5b20e663d5046b3032824d8d2ab8e487ce2369cf for redis:5.0-alpine with digest redis@sha256:01cbc10aa79db974c374820566a46bbdf89c8378a05c795040e2bf9ef02a880e ...
Waiting for services to be up and running...
Authenticating with credentials from job payload (GitLab Registry)
Pulling docker image registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.7.2.patched-golang-1.14-git-2.31-lfs-2.9-chrome-89-node-14.15-yarn-1.22-postgresql-12-graphicsmagick-1.3.36 ...
Using docker image sha256:5427fd94dbf6ac018804070018547f6d744519aeb670f43df73f168d1fd11192 for registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.7.2.patched-golang-1.14-git-2.31-lfs-2.9-chrome-89-node-14.15-yarn-1.22-postgresql-12-graphicsmagick-1.3.36 with digest registry.gitlab.com/gitlab-org/gitlab-build-images@sha256:db1858ab2c8b8fc1c1801c264355338fc6a342aca82c0367104267a59f30152c ...
25 seconds
$ setup_db_user_only
CREATE ROLE
GRANT
==> 'setup_db_user_only' succeeded in 0 seconds.
$ bundle exec rake db:drop db:create db:structure:load db:migrate gitlab:db:setup_ee
Dropped database 'gitlabhq_test'
Created database 'gitlabhq_test'
Dropped database 'gitlabhq_geo_test'
Created database 'gitlabhq_geo_test'
==> 'bundle exec rake db:drop db:create db:structure:load db:migrate gitlab:db:setup_ee' succeeded in 25 seconds.
92 seconds
$ run_timed_command "bundle exec ruby -I. -e 'require \"config/environment\"; TestEnv.init'"
$ bundle exec ruby -I. -e 'require "config/environment"; TestEnv.init'
==> Setting up Gitaly...
Warning
You are running as user root, we hope you know what you are doing.
Things may work/fail for the wrong reasons.
For correct results you should run this as user git.
Gitaly set up in 11.722514348 seconds...
==> Setting up GitLab Workhorse...
GitLab Workhorse set up in 38.727959213 seconds...
==> Setting up gitlab-test repository in /builds/gitlab-org/gitlab/tmp/tests/gitlab-test...
/builds/gitlab-org/gitlab/tmp/tests/gitlab-test set up in 1.160882047 seconds...
==> Setting up gitlab-test bare repository in /builds/gitlab-org/gitlab/tmp/tests/gitlab-test_bare...
/builds/gitlab-org/gitlab/tmp/tests/gitlab-test_bare set up in 0.018316986 seconds...
==> Setting up gitlab-test-fork repository in /builds/gitlab-org/gitlab/tmp/tests/gitlab-test-fork...
/builds/gitlab-org/gitlab/tmp/tests/gitlab-test-fork set up in 0.537366234 seconds...
==> Setting up gitlab-test-fork bare repository in /builds/gitlab-org/gitlab/tmp/tests/gitlab-test-fork_bare...
/builds/gitlab-org/gitlab/tmp/tests/gitlab-test-fork_bare set up in 0.016710016 seconds...
==> Setting up GitLab Elasticsearch Indexer...
GitLab Elasticsearch Indexer set up in 29.597748479 seconds...
==> 'bundle exec ruby -I. -e 'require "config/environment"; TestEnv.init'' succeeded in 92 seconds.
112 seconds
$ run_timed_command "scripts/gitaly-test-build"
$ scripts/gitaly-test-build
...
The Gemfile's dependencies are satisfied
Trying to connect to gitaly: ...... OK
Trying to connect to gitaly2: ............... OK
Trying to connect to praefect: ...... OK
==> 'scripts/gitaly-test-build' succeeded in 112 seconds.
Improved job
3 seconds (-4 seconds)
Using Docker executor with image registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.7.2.patched-golang-1.14-git-2.31-lfs-2.9-chrome-89-node-14.15-yarn-1.22-postgresql-11-graphicsmagick-1.3.36 ...
Authenticating with credentials from job payload (GitLab Registry)
Pulling docker image registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.7.2.patched-golang-1.14-git-2.31-lfs-2.9-chrome-89-node-14.15-yarn-1.22-postgresql-11-graphicsmagick-1.3.36 ...
Using docker image sha256:9b06bf3dd0ab8d484e8c9e9c611f75eab098939f568d587a7fd23a3c96eceb87 for registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.7.2.patched-golang-1.14-git-2.31-lfs-2.9-chrome-89-node-14.15-yarn-1.22-postgresql-11-graphicsmagick-1.3.36 with digest registry.gitlab.com/gitlab-org/gitlab-build-images@sha256:eb4fdeb3196481dd022d7d166468834e40a046b46a29e3349fb3bf3657176290 ...
No setup_db_user_only
(-25 seconds)
72 seconds (-20 seconds)
$ run_timed_command "scripts/setup-test-env"
$ scripts/setup-test-env
Warning
You are running as user root, we hope you know what you are doing.
Things may work/fail for the wrong reasons.
For correct results you should run this as user git.
==> Gitaly set up in 7.602206887 seconds...
==> /builds/gitlab-org/gitlab/tmp/tests/gitlab-test set up in 1.310897097 seconds...
==> /builds/gitlab-org/gitlab/tmp/tests/gitlab-test_bare set up in 0.032068611 seconds...
==> /builds/gitlab-org/gitlab/tmp/tests/gitlab-test-fork set up in 0.526055063 seconds...
==> /builds/gitlab-org/gitlab/tmp/tests/gitlab-test-fork_bare set up in 0.01137741 seconds...
==> GitLab Elasticsearch Indexer set up in 49.831956437 seconds...
==> GitLab Workhorse set up in 67.6907328 seconds...
Test environment set up in 69.560884227 seconds
==> 'scripts/setup-test-env' succeeded in 72 seconds.
117 seconds (+5 seconds, most probably unrelated)
$ run_timed_command "scripts/gitaly-test-build"
$ scripts/gitaly-test-build
...
The Gemfile's dependencies are satisfied
Trying to connect to gitaly: ........ OK
Trying to connect to gitaly2: ............... OK
Trying to connect to praefect: ....... OK
==> 'scripts/gitaly-test-build' succeeded in 117 seconds.
Total savings per job: 44 seconds
-
setup-test-env
jobs per day: around 600
Total savings per day: 26,400 seconds = 7.3 hours
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?-
I have included a changelog entry. -
I have not included a changelog entry because _____.
-
-
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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
Related to #118623 (closed)
Edited by Rémy Coutable