How to disable test parallelization *just* for system tests?

I’m finding that the default test parallelization makes chromedriver tests highly unreliable. But I’d like to keep other tests parallel.

I’ve tried this in application_system_test_case.rb:

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
  parallelize(workers: 1)
  # ...
end

…but it doesn’t seem to override the default.

2 Likes

I have the same problems with reliability of the parallel system tests. When on CI and using different nodes could be done with setting PARALLEL_WORKERS env variable.

1 Like

Yeah, I’m using that env var manually right now, but I’d love to find a way to capture this guideline into the project’s defaults.

Interestingly this is not just a Rails problem. When I was playing with writing a web scraper in Rust a while back, Rust’s test parallelization caused ALLLLLLLL kinds of failures. The root cause there was that the chromedriver process was a contended resource between threads.

I’m really curious about what mechanisms Eileen (?) has put in place here to make this work to even the degree it does. I found it to be a difficult enough problem in Rust, and Rust has a lot more affordances for getting control over parallelization issues than Ruby does.

FWIW, this is how I’ve just solved it after (finally) upgrading our app to Rails 6 and enabling parallelization:

# application_system_test_case.rb
ENV["PARALLEL_WORKERS"] ||= "1"

require "test_helper"
# test_helper.rb

class ActiveSupport::TestCase
  parallelize(workers: ENV.fetch("PARALLEL_WORKERS", :number_of_processors))

At least works out of the box for any dev or CI running our system tests.

However, being able to run system tests reliably in parallel would be even better of course, did anyone find ways to make them more reliable?