1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/guides/source
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
..
kindle
2_2_release_notes.md Fix some broken links in guides 2018-01-11 15:53:20 +01:00
2_3_release_notes.md Fix some broken links in guides 2018-01-11 15:53:20 +01:00
3_0_release_notes.md Fix some broken links in guides 2018-01-11 15:53:20 +01:00
3_1_release_notes.md
3_2_release_notes.md Cosmetic changes [ci skip] 2017-11-30 09:35:26 +03:00
4_0_release_notes.md
4_1_release_notes.md Cosmetic changes [ci skip] 2017-11-30 09:35:26 +03:00
4_2_release_notes.md Cosmetic changes [ci skip] 2017-11-30 09:35:26 +03:00
5_0_release_notes.md
5_1_release_notes.md [docs] Add mention of removal of HWIA interface from AC:Parameters 2017-12-22 22:01:49 +01:00
5_2_release_notes.md Fix the desc for image_alt change [ci skip] 2018-01-07 22:29:13 +05:30
_license.html.erb
_welcome.html.erb
action_cable_overview.md [ci skip] Add missing **DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** 2017-12-15 14:02:25 +09:00
action_controller_overview.md [ci skip] Update MVC wiki link 2017-11-28 16:42:11 +05:30
action_mailer_basics.md Fix typos [ci skip] 2018-01-11 00:56:35 +03:00
action_view_overview.md Update "Action View Overview" guide [ci skip] 2017-12-26 13:30:39 +02:00
active_job_basics.md Missing backquote, extra end keyword [ci skip] 2018-02-15 08:03:48 +03:00
active_model_basics.md
active_record_basics.md tweaks for #31704 [ci skip] 2018-01-24 09:11:18 +09:00
active_record_callbacks.md Move touch method from Skipping Callbacks section to Running Callbacks section [ci skip] 2017-11-13 15:48:25 +05:30
active_record_migrations.md Remove default ENGINE documentation for MySQL and MariaDB 2017-12-11 10:46:25 +01:00
active_record_postgresql.md
active_record_querying.md Update "Active Record Query Interface" guide [ci skip] 2017-12-04 01:18:59 +02:00
active_record_validations.md Fix typos [ci skip] 2018-01-11 00:56:35 +03:00
active_storage_overview.md Update google-cloud-storage gem version [ci skip] 2018-01-28 10:38:53 +09:00
active_support_core_extensions.md Change structure of AS core extensions [ci skip] 2018-02-12 23:29:34 +03:00
active_support_instrumentation.md [ci skip] Update instrumentation guide for ActiveStorage 2017-12-12 04:17:14 +09:00
api_app.md [ci skip] Add missing **DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** 2017-12-15 14:02:25 +09:00
api_documentation_guidelines.md Use new RDoc URL of Ruby core [ci skip] 2017-11-10 18:14:45 +09:00
asset_pipeline.md Remove out-of-date references to jQuery 2018-01-28 15:36:30 -05:00
association_basics.md Fix example migrations in Associations guide 2018-01-26 12:26:46 +08:00
autoloading_and_reloading_constants.md Remove parentheses [ci skip] 2018-02-12 09:31:24 +03:00
caching_with_rails.md Use SHA-1 for non-sensitive digests by default 2018-01-08 20:45:46 +00:00
command_line.md Use -e option to specify the environment in console command [ci skip] 2017-11-10 13:50:16 +09:00
configuring.md Add configuration to set custom serializers 2018-02-14 13:10:08 -05:00
contributing_to_ruby_on_rails.md Clarification for noobs. (#31704) 2018-01-23 17:39:40 -05:00
credits.html.erb
debugging_rails_applications.md
development_dependencies_install.md
documents.yaml Sync header title with file name [ci skip] 2017-12-15 16:52:27 +09:00
engines.md Clarify that config.eager_load controls eager loading [ci skip] 2017-12-30 22:37:44 +00:00
form_helpers.md Merge pull request #30474 from yhirano55/make_it_same_title_in_index_and_page 2017-12-13 10:23:14 -05:00
generators.md
getting_started.md Improve wording in getting started guide 2018-02-09 23:33:35 -08:00
i18n.md Cosmetic changes [ci skip] 2017-11-30 09:35:26 +03:00
index.html.erb
initialization.md Cosmetic changes [ci skip] 2017-11-30 09:35:26 +03:00
layout.html.erb Update guide layout [ci skip] 2017-11-25 14:04:42 +00:00
layouts_and_rendering.md Update "Layouts and Rendering in Rails" guide [ci skip] 2018-01-17 16:31:08 +02:00
maintenance_policy.md
plugins.md
rails_application_templates.md
rails_on_rack.md Add Rack::TempfileReaper to tests and docs 2018-01-30 18:21:07 -05:00
routing.md [ci skip] Update routing guide for Direct 2017-12-12 14:07:58 +09:00
ruby_on_rails_guides_guidelines.md
security.md Remove password anecdotes from guides [ci skip] 2018-02-07 18:00:10 -05:00
testing.md Add test parallelization to Rails 2018-02-15 19:21:24 -05:00
threading_and_code_execution.md Fix typos [ci skip] 2018-01-11 00:56:35 +03:00
upgrading_ruby_on_rails.md Merge pull request #31577 from prathamesh-sonpatki/upgrade-guide-bootsnap 2018-01-18 15:02:02 -05:00
working_with_javascript_in_rails.md Fix typos [ci skip] 2018-01-11 00:56:35 +03:00