1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/guides
eileencodes 26821d9b57 Add test parallelization to Rails
Provides both a forked process and threaded parallelization options. To
use add `parallelize` to your test suite.

Takes a `workers` argument that controls how many times the process
is forked. For each process a new database will be created suffixed
with the worker number; test-database-0 and test-database-1
respectively.

If `ENV["PARALLEL_WORKERS"]` is set the workers argument will be ignored
and the environment variable will be used instead. This is useful for CI
environments, or other environments where you may need more workers than
you do for local testing.

If the number of workers is set to `1` or fewer, the tests will not be
parallelized.

The default parallelization method is to fork processes. If you'd like to
use threads instead you can pass `with: :threads` to the `parallelize`
method. Note the threaded parallelization does not create multiple
database and will not work with system tests at this time.

parallelize(workers: 2, with: :threads)

The threaded parallelization uses Minitest's parallel exector directly.
The processes paralleliztion uses a Ruby Drb server.

For parallelization via threads a setup hook and cleanup hook are
provided.

```
class ActiveSupport::TestCase
  parallelize_setup do |worker|
    # setup databases
  end

  parallelize_teardown do |worker|
    # cleanup database
  end

  parallelize(workers: 2)
end
```

[Eileen M. Uchitelle, Aaron Patterson]
2018-02-15 19:21:24 -05:00
..
assets [ci skip] Rails Associations examples contains ActiveRecord::Base reference instead of ApplicationRecord in images 2017-11-24 22:13:21 +05:30
bug_report_templates Revert "Specify bundler version in template files" 2017-12-22 23:07:14 +09:00
rails_guides Fix typos and add a few suggestions 2017-11-28 19:27:43 +01:00
source Add test parallelization to Rails 2018-02-15 19:21:24 -05:00
.document
CHANGELOG.md Start Rails 6.0 development!!! 2018-01-30 18:51:17 -05:00
rails_guides.rb Use frozen string literal in guides/ 2017-08-13 22:04:09 +09:00
Rakefile Use frozen string literal in guides/ 2017-08-13 22:04:09 +09:00
w3c_validator.rb Use frozen string literal in guides/ 2017-08-13 22:04:09 +09:00