From 86da47f58dab2bad66929c3708830c264e311451 Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Wed, 22 Nov 2023 11:51:43 +0800 Subject: [PATCH] FIX: `docker:test` Rake task did not run system tests in parallel (#24507) Why this change? We support a `USE_TURBO` environment variable which tells the `docker:test` rake task to run rspec tests in parallel. However, this currently does not apply to system tests. What does this change do? This commit runs system specs for both core and plugins using `./bin/turbo_rspec` when the `USE_TURBO` environment is present. Note that when running system specs, we will only spawn X number of test processes where X is half the number of available CPU cores. This is done because we have to leave CPU resources for the chrome processes that will be created. --- lib/tasks/docker.rake | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/tasks/docker.rake b/lib/tasks/docker.rake index 5dad8b1daff..0b791b04a88 100644 --- a/lib/tasks/docker.rake +++ b/lib/tasks/docker.rake @@ -78,6 +78,10 @@ def migrate_databases(parallel: false, load_plugins: false) success end +def system_tests_parallel_tests_processors_env + "PARALLEL_TEST_PROCESSORS=#{Etc.nprocessors / 2}" +end + # Environment Variables (specific to this rake task) desc "Setups up the test environment" task "docker:test:setup" do @@ -214,6 +218,8 @@ task "docker:test" do ) unless ENV["JS_ONLY"] + @good &&= run_or_fail("bin/ember-cli --build") if ENV["RUN_SYSTEM_TESTS"] + if ENV["WARMUP_TMP_FOLDER"] run_or_fail("bundle exec rspec ./spec/requests/groups_controller_spec.rb") end @@ -236,14 +242,21 @@ task "docker:test" do end if ENV["RUN_SYSTEM_TESTS"] - @good &&= run_or_fail("bin/ember-cli --build") - @good &&= run_or_fail("timeout --verbose 1800 bundle exec rspec spec/system") + @good &&= + if ENV["USE_TURBO"] + run_or_fail( + "#{system_tests_parallel_tests_processors_env} timeout --verbose 1800 bundle exec ./bin/turbo_rspec spec/system", + ) + else + run_or_fail("timeout --verbose 1800 bundle exec rspec spec/system") + end end end unless ENV["SKIP_PLUGINS"] if ENV["SINGLE_PLUGIN"] @good &&= run_or_fail("bundle exec rake plugin:spec['#{ENV["SINGLE_PLUGIN"]}']") + if ENV["RUN_SYSTEM_TESTS"] @good &&= run_or_fail( @@ -254,11 +267,18 @@ task "docker:test" do fail_fast = "RSPEC_FAILFAST=1" unless ENV["SKIP_FAILFAST"] task = ENV["USE_TURBO"] ? "plugin:turbo_spec" : "plugin:spec" @good &&= run_or_fail("#{fail_fast} bundle exec rake #{task}") + if ENV["RUN_SYSTEM_TESTS"] @good &&= - run_or_fail( - "LOAD_PLUGINS=1 timeout --verbose 1600 bundle exec rspec plugins/*/spec/system".strip, - ) + if ENV["USE_TURBO"] + run_or_fail( + "LOAD_PLUGINS=1 #{system_tests_parallel_tests_processors_env} timeout --verbose 1600 bundle exec ./bin/turbo_rspec plugins/*/spec/system", + ) + else + run_or_fail( + "LOAD_PLUGINS=1 timeout --verbose 1600 bundle exec rspec plugins/*/spec/system", + ) + end end end end