rails: Parallel testing causes DRb error without ActiveRecord
Steps to reproduce
I created a brand new app with Rails 6 edge using this command:
rails new rails6-demo --edge --skip-activerecord -d postgresql --api
I then installed pg
, sequel-rails
, and generated a simple Post
model with a failing test. All of these steps have already been performed on the repo/branch linked above.
Note that due to a bug in sequel-rails, you have to manually createdb rails6_demo_development && rake db:test:prepare
because rake db:create
doesn’t currently work when it can’t connect to an existing dev database.
After that, I ran rake test
and got the following DRb error:
/Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:1733:in `current_server': DRb::DRbServerNotFound (DRb::DRbConnError)
Full stacktrace here:
Running via Spring preloader in process 66577
Run options: --seed 53695
# Running:
Traceback (most recent call last):
28: from -e:1:in `<main>'
27: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
26: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
25: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/minitest-5.11.3/lib/minitest.rb:63:in `block in autorun'
24: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/minitest-5.11.3/lib/minitest.rb:133:in `run'
23: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bundler/gems/rails-611e1102d3bd/activesupport/lib/active_support/testing/parallelization.rb:70:in `start'
22: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bundler/gems/rails-611e1102d3bd/activesupport/lib/active_support/testing/parallelization.rb:70:in `map'
21: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bundler/gems/rails-611e1102d3bd/activesupport/lib/active_support/testing/parallelization.rb:70:in `each'
20: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bundler/gems/rails-611e1102d3bd/activesupport/lib/active_support/testing/parallelization.rb:70:in `times'
19: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bundler/gems/rails-611e1102d3bd/activesupport/lib/active_support/testing/parallelization.rb:71:in `block in start'
18: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bundler/gems/rails-611e1102d3bd/activesupport/lib/active_support/testing/parallelization.rb:71:in `fork'
17: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bundler/gems/rails-611e1102d3bd/activesupport/lib/active_support/testing/parallelization.rb:84:in `block (2 levels) in start'
16: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:1139:in `method_missing'
15: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:1159:in `with_friend'
14: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:1140:in `block in method_missing'
13: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:1228:in `open'
12: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:1141:in `block (2 levels) in method_missing'
11: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:1252:in `send_message'
10: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:925:in `send_request'
9: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:610:in `send_request'
8: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:610:in `each'
7: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:611:in `block in send_request'
6: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:564:in `dump'
5: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:567:in `rescue in dump'
4: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:650:in `make_proxy'
3: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:650:in `new'
2: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:1102:in `initialize'
1: from /Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:1802:in `to_id'
/Users/bgentry/.rbenv/versions/2.5.0/lib/ruby/2.5.0/drb/drb.rb:1733:in `current_server': DRb::DRbServerNotFound (DRb::DRbConnError)
Finished in 0.095432s, 0.0000 runs/s, 0.0000 assertions/s.
0 runs, 0 assertions, 0 failures, 0 errors, 0 skips
Expected behavior
I expected the test to run and output a failure (since no model validation has been added yet). Note that I am not yet expecting my tests to run in parallel. In fact the purpose of me creating this app was to try to add parallel test support to sequel-rails 😃
I at least expected that the addition of parallel testing support wouldn’t break non-ActiveRecord Rails apps.
For comparison, I also created a new app that uses ActiveRecord, and the test runs as expected there.
Actual behavior
A DRb::DRbServerNotFound
exception occurs .
System configuration
Rails version: 6.0.0.alpha
Ruby version: 2.5.0
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (17 by maintainers)
Commits related to this issue
- Address minitest parallelization bug See: https://github.com/rails/rails/issues/32682 https://github.com/rails/rails/issues/38424 — committed to precisely/api by aneilbaboo 4 years ago
I am still seeing this issue with Rails 6.1, should I report a new issue?
Bah, the reason this breaks is because test parallelization is enabled by default and I didn’t realize I needed to disable it by commenting out this in my
test_helper.rb
:Doing so makes the tests run as expected.
That being said, maybe this is still a bug in some form even if it’s really just a UX issue? I’ll let somebody with more knowledge chime in. I understand if you just want to close this though!
parallelize
defaults towith: :processes
, when I change it toparallelize(workers: 2, with: :threads)
the failing test behaves as expected. Does this work in your reproduction app, @bgentry ?