semaperepelitsa / spork-minitest

MiniTest runner for Spork
MIT License
13 stars 25 forks source link

Timeout / DRb::DRbConnError: #7

Closed rking closed 11 years ago

rking commented 11 years ago

Using: https://github.com/rking/demo-ruby-tests/tree/debugging/guard-spork

Running bundle exec spork minitest -p 8988

Gives:

Spork is ready and listening on 8988!

But then bundle exec testdrb -Itest test/foo_test.rb

Gives:

Running tests with args ["-Itest", "test/foo_test.rb"]...
Exception encountered: #<DRb::DRbConnError: druby://zak:32787 - #<Errno::ETIMEDOUT: Connection timed out - connect(2)>>
backtrace:
/usr/lib64/ruby/1.9.1/drb/drb.rb:736:in `rescue in block in open'
/usr/lib64/ruby/1.9.1/drb/drb.rb:730:in `block in open'
/usr/lib64/ruby/1.9.1/drb/drb.rb:729:in `each'
/usr/lib64/ruby/1.9.1/drb/drb.rb:729:in `open'
/usr/lib64/ruby/1.9.1/drb/drb.rb:1191:in `initialize'
/usr/lib64/ruby/1.9.1/drb/drb.rb:1171:in `new'
/usr/lib64/ruby/1.9.1/drb/drb.rb:1171:in `open'
/usr/lib64/ruby/1.9.1/drb/drb.rb:1087:in `block in method_missing'
/usr/lib64/ruby/1.9.1/drb/drb.rb:1105:in `with_friend'
/usr/lib64/ruby/1.9.1/drb/drb.rb:1086:in `method_missing'
/usr/lib64/ruby/1.9.1/drb/drb.rb:1074:in `respond_to?'
/home/rking/.gem/ruby/1.9.1/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:10:in
`block in run'
/home/rking/.gem/ruby/1.9.1/gems/spork-0.9.2/lib/spork/forker.rb:21:in `block
in initialize'
/home/rking/.gem/ruby/1.9.1/gems/spork-0.9.2/lib/spork/forker.rb:18:in `fork'
/home/rking/.gem/ruby/1.9.1/gems/spork-0.9.2/lib/spork/forker.rb:18:in
`initialize'
/home/rking/.gem/ruby/1.9.1/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in
`new'
/home/rking/.gem/ruby/1.9.1/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in
`run'
/home/rking/.gem/ruby/1.9.1/gems/spork-0.9.2/lib/spork/server.rb:48:in `run'
/usr/lib64/ruby/1.9.1/drb/drb.rb:1548:in `perform_without_block'
/usr/lib64/ruby/1.9.1/drb/drb.rb:1508:in `perform'
/usr/lib64/ruby/1.9.1/drb/drb.rb:1586:in `block (2 levels) in main_loop'
/usr/lib64/ruby/1.9.1/drb/drb.rb:1582:in `loop'
/usr/lib64/ruby/1.9.1/drb/drb.rb:1582:in `block in main_loop'
Done.

The same tests, if run as bundle exec testrb -Itest test/foo_test.rb work fine.

semaperepelitsa commented 11 years ago

What version of spork-minitest are you running? Do you have SPORK_URI or SPORK_PORT environment variables set?

semaperepelitsa commented 11 years ago

Oops, sorry, I see the version in the provided repository.

semaperepelitsa commented 11 years ago

You are not connecting to the standard server URL druby://127.0.0.1:8988, not sure what is causing this.

rking commented 11 years ago

Semyon,

First off, thanks for your reply. I'm on a quest to find the ultimate Ruby test setup, and Spork is one of the key ingredients.

I looked again tonight to try to figure out some more info to give you, and in the strace output I see:

connect(12, {sa_family=AF_INET, sin_port=htons(46560), sin_addr=inet_addr("67.215.65.132")}, 16 <unfinished ...> 

So that 46560 there is the same as the 32787 in my original post to this issue. That is, it's some arbitrary port trying to be used on my local machine, but in both cases it's trying to connect to zak, which is my hostname. Since I'm running OpenDNS it resolves to 67.215.65.132 then times out.

I'll post more in a bit. I'm excited to have a clue after this not having worked for me, so far.

rking commented 11 years ago

Made a bit of progress, still no real understanding, though.

testdrb is basically this:

DRb.start_service
exit_code = DRbObject.new_with_uri("druby://127.0.0.1:8988").run(ARGV, $stderr, $stdout)

That DRb.start_service ends up making a DRb::DRbServer instance with an @uri of "druby://zak:47696" (the bogus URI, that is), then trying to connect to it and failling.

(Thanks!)

semaperepelitsa commented 11 years ago

Can you see if DRb works on your machine at all? Try the first example at http://www.ruby-doc.org/stdlib-1.9.3/libdoc/drb/rdoc/DRb.html (run server first, then client)

rking commented 11 years ago

Yes, the RSpec spork stuff works fine for me.

I took a look at https://github.com/dchelimsky/rspec/blob/master/lib/spec/runner/drb_command_line.rb and mimicked it.

DRb.start_service "druby://localhost:0"
exit_code = DRbObject.new_with_uri("druby://127.0.0.1:8988").run(ARGV, $stderr, $stdout)

And now it works when I do this!:

bundle exec testdrb test/foo_test.rb 

Now I'm trying to figure out what's wrong with

guard 'minitest', drb: true

As it generates a failing run like this:

$ testdrb -r /home/rking/.gem/ruby/1.9.1/gems/guard-minitest-0.5.0/lib/guard/minitest/runners/default_runner.rb -e ::GUARD_NOTIFY=true test/test_helper.rb test/foo_test.rb
[test_helper.rb toplevel running]
[Spork.each_run running]
Exception encountered: #<LoadError: cannot load such file -- -r>
backtrace:
/home/rking/.gem/ruby/1.9.1/gems/spork-minitest-0.0.3/lib/spork/test_framework/minitest.rb:13:in `require'
/home/rking/.gem/ruby/1.9.1/gems/spork-minitest-0.0.3/lib/spork/test_framework/minitest.rb:13:in `block in run_tests'
/home/rking/.gem/ruby/1.9.1/gems/spork-minitest-0.0.3/lib/spork/test_framework/minitest.rb:12:in `each'
/home/rking/.gem/ruby/1.9.1/gems/spork-minitest-0.0.3/lib/spork/test_framework/minitest.rb:12:in `run_tests'
semaperepelitsa commented 11 years ago

That is a different error. Spork minitest does not support options like -r and -e, it only accepts a list of files to load. Guard-minitest is currently incompatible with this gem as it was originally designed for spork-testunit. You can see a discussion at #5

rking commented 11 years ago

Yes, I was trying to understand:

https://github.com/guard/guard-minitest/pull/41 and https://github.com/semaperepelitsa/spork-minitest/pull/5

rking commented 11 years ago

So, I get that there is a different error there, but why did I have to edit testdrb to say:

DRb.start_service "druby://localhost:0"
semaperepelitsa commented 11 years ago

As I understand, dRuby starts a service on your computer's hostname which is named zak. But this hostname doesn't actually point to your machine. Is there a reason to use a such hostname as default?