aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/testing/parallelization.rb
Commit message (Collapse)AuthorAgeFilesLines
* If exception occurs during setup, add to each test executedAric Walker2019-04-181-1/+10
| | | | | | Resolves https://github.com/rails/rails/issues/35835 If an exception occurs during `parallelize_setup` make sure to catch that exception and apply it to the result of each successive test run. This results in marking all of the tests as failed to bring attention to the issue & ensure it is addressed before proceeding.
* running test with_info_handler methodMauri Mustonen2019-04-161-1/+3
|
* Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-211-22/+20
| | | | | | | | | | Currently we sometimes find a redundant begin block in code review (e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205). I'd like to enable `Style/RedundantBegin` cop to avoid that, since rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5 (https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with that situation than before.
* Pass the test reporter by referenceyuuji.yaginuma2018-11-281-0/+1
| | | | | | | | | | | This prevents the array from being dumped as a DRbObject so we can reduce communication with the server. In DRb, if `Marshal.dump` fails, `Marshal.dump` is executed again after converting the object to `DRbObject`. This also possible to reduce the execution of `Marshal.dump` by converting to a format that can be marshalized in advance using `DRbObject`. This is the same approach to Action Pack's parallel test. Ref: 5751b7ea58d7cf259dda30fb42fff51fc6ae93d5
* Merge pull request #34410 from gmcgibbon/test_support_windowsEileen M. Uchitelle2018-11-191-1/+1
|\ | | | | Windows support for parallelization and instrumenter
| * Windows support for parallelization and instrumenterGannon McGibbon2018-11-081-1/+1
| | | | | | | | | | Add Windows support for `ActiveSupport::Testing::Parallelization` and `ActiveSupport::Notifications::Instrumenter`.
* | Correctly handle unknown object in parallel testsyuuji.yaginuma2018-11-171-0/+2
|/ | | | | | | | | | | | | | | | | | | | | DRb wraps in `DRbUnknown` if the data contains a type that can not be resolved locally. This can happen if an error occurs in the test and the error class can not be resolved on the server side. When this happens, an instance of `DRbUnknown` is passed to the `result` of `Server#record`. This causes another error(undefined method assertions for #<DRb::DRbUnknown:> (NoMethodError)) in `reporter.record`. This can confirm by the following steps. ``` $ rails new app -B --dev; cd app $ rails g scaffold user name:string $ edit `config.action_controller.allow_forgery_protection = true` in environments/test.rb $ bin/rails t ``` In the case of `DRbUnknown` occurs, can't resolve error exception. So wrap exception with `DRbRemoteError` in the same way as an unmarshalled object.
* Merge pull request #34131 from lsylvester/defend-against-unmarshable-exceptionsEileen M. Uchitelle2018-11-051-1/+8
|\ | | | | Fix DRb::DRbServerNotFound errors in parallel tests
| * resque errors caused by Marshal dump failures and wrap exceptions in ↵Lachlan Sylvester2018-10-091-1/+8
| | | | | | | | marshallable DRbRemoteError
* | Missing require "core_ext/module/attribute_accessors"Akira Matsuda2018-10-301-0/+1
|/
* Ensure we always cleanup the databasesEileen Uchitelle2018-09-051-11/+13
| | | | | | This commit moves the `run_cleanup` hook into an `ensure` block so we make sure to cleanup the databases even if an exception is raised while running the parallel tests.
* Turn on performance based copsDillon Welch2018-07-231-10/+6
| | | | | | | | | | | | | | | | Use attr_reader/attr_writer instead of methods method is 12% slower Use flat_map over map.flatten(1) flatten is 66% slower Use hash[]= instead of hash.merge! with single arguments merge! is 166% slower See https://github.com/rails/rails/pull/32337 for more conversation
* Add test parallelization to Railseileencodes2018-02-151-0/+102
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]