Skip to content

prerake, test_helper and cucumber_environment do not connect #123

Closed
simeonwillbanks opened this Issue Sep 24, 2012 · 25 comments
@simeonwillbanks

$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.7.4
BuildVersion: 11E53

$ curl https://raw.github.com/gist/1688857/rbenv.sh | sh ; rbenv global 1.9.3-p194-perf

$ rbenv version
1.9.3-p194-perf (set by /Users/simeon/.rbenv/version)

$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]

$ gem install zeus

$ gem install bundler

$ rbenv rehash

$ bundle install

$ bundle exec rails -v
Rails 3.2.8

$ zeus init

$ cat zeus.json

{
  "command": "ruby -rubygems -rzeus/rails -eZeus.go",

  "plan": {
    "boot": {
      "default_bundle": {
        "development_environment": {
          "prerake": {"rake": []},
          "runner": ["r"],
          "console": ["c"],
          "server": ["s"],
          "generate": ["g"],
          "dbconsole": []
        },
        "test_environment": {
          "cucumber_environment": {"cucumber": []},
          "test_helper": {"test": ["rspec", "testrb"]}
        }
      }
    }
  }
}

$ zeus start

If anymore information is needed, please ask!

Thanks for zeus.

@whtt-eric

I'm seeing the same issue. I've installed the GC patch, and the only differences are that I'm using rvm and Rails 3.0.5.

The Zeus gem version is 0.12.0.

@hoelmer
hoelmer commented Sep 26, 2012

I experienced the same problem a few days ago. If you are using homebrew try upgrading all packages and then try reinstalling the Zeus gem again. My guess is that something in my build environment was not up to date.

@simeonwillbanks

@hoelmer I uninstalled zeus then ran brew doctor. I followed the suggestions such as brew update and brew install x y and z. After reinstalling zeus, I get the same output as the original screen capture. 😢

@whtt-eric

@hoelmer Thanks for the suggestion. I also gave it a shot, but to no avail.

@simeonwillbanks if you remove the prerake and development sections from the zeus.json file, does it work for you?

I did this and generate, dbconsole, console, runner, and server all show green, but when I try zeus s or zeus c, nothing happens.

@simeonwillbanks

@whtt-eric I really want to use zeus for speeding up TDD; removing prerake and test_environment wouldn't make any sense. That said, thanks for the suggestion.

@hajee
hajee commented Oct 1, 2012

I have the same issue. I'm using rails 3.2.7 and rvm 1.16.6.

Did anybody made any progress?? I really miss zeus.

@fatum
fatum commented Oct 2, 2012

I have the same issue too.

System

ProductName: Mac OS X
ProductVersion: 10.7.4
BuildVersion: 11E53

Rails 3.2.6

@ottbot
ottbot commented Oct 16, 2012

Seeing this on Linux, with rubies:

ruby-1.9.3-p194 [ x86_64 ]
ruby-1.9.3-p194-perf [ x86_64 ]

@knoopx
knoopx commented Nov 7, 2012

Experiencing the same problem here, I just reinstalled rvm/ruby/zeus and the problem still appears.

@richardjohansson

I'm having these issues, but now simply running zeus version 0.4.4 and it works like a charm. I'm not sure what features I'm missing out on thought. :)

@simeonwillbanks

@richardjohansson Why'd you choose 0.4.4? There are a lot of releases between 0.12.0 and 0.4.4.

https://rubygems.org/gems/zeus/versions

@sporto
sporto commented Nov 16, 2012

Same issue here

Mac 10.8.2
RVM 1.16
ruby-1.9.3-p327-perf
rails 3.2.9
zeus 0.12.0

@richardjohansson

@simeonwillbanks Well it just works. :) I tried a few other releases but had the same problem. Would not spend more time debugging this since 0.4.4 does the job, for what I use it for. (rspec, console, rake)

@simeonwillbanks

@richardjohansson Got it. I'll try 0.4.4. Thanks!

@simeonwillbanks

Now we're cooking with gas. 🔥 🚀

$ zeus console
Loading development environment (Rails 3.2.8)
[1] pry(main)>

$ zeus rspec spec/models/user_spec.rb
Finished in 0.14386 seconds
24 examples, 24 failures

@richardjohansson you rock! 😤

@simeonwillbanks

Well, console is working fine, and rspec was working, but now I'm getting this error.

     Failure/Error: Unable to find matching line from backtrace
     NoMethodError:
       undefined method `query_options' for nil:NilClass
     # ./.zeus.rb:107:in `block (6 levels) in <top (required)>'
@simeonwillbanks

Looks like my failing specs were always failing. : embarrassed:

Here is where the NoMethodError exception is thrown:

simeon at greenwood in ~/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems (master)
$ ack --ruby query_options

activerecord-3.2.8/lib/active_record/connection_adapters/mysql2_adapter.rb
209:        @connection.query_options[:database_timezone] = ActiveRecord::Base.default_timezone
255:        @connection.query_options.merge!(:as => :array)

MySQL connection? Huh. Wait a minute, its spork causing the exception! This was in my spec_helper.rb:

Spork.each_run do
  FactoryGirl.reload
  # Force Rails and Capybara launched web browser to use the same database connection
  # @see https://groups.google.com/forum/#!msg/ruby-capybara/JI6JrirL9gM/R6YiXj4gi_UJ
  # @see http://stackoverflow.com/a/8540668/177524
  # @see above in Spork.prefork block
  ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
end

I removed spork, and I'm all green.

$ zeus rspec spec/models/user_spec.rb
Finished in 0.16323 seconds
24 examples, 0 failures
@burke
Owner
burke commented Dec 3, 2012

This may be helpful/relevant: https://github.com/burke/zeus/wiki/Spork

@burke
Owner
burke commented Dec 3, 2012

I'm working on better diagnostics for when processes fail to connect or error out (#174 -- hopefully sorted out soon.)

@sporto
sporto commented Dec 12, 2012

Version 0.13 fixed this for me

@simeonwillbanks

I've upgraded to 0.13.1, and these are still crashing.

zeus test (alias: rspec, testrb) [run to see backtrace]
zeus cucumber [run to see backtrace]

Looks like Redis is the culprit.

$ zeus rspec spec/models/user_spec.rb                                         
/Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:236:in `rescue in establish_connection': Connection refused - Unable to connect to Redis on localhost:6380 (Errno::ECONNREFUSED)
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:222:in `establish_connection'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:23:in `connect'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus/rails.rb:238:in `block in reconnect_redis'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus/rails.rb:237:in `each_object'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus/rails.rb:237:in `reconnect_redis'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus/rails.rb:32:in `after_fork'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:151:in `run_action'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:54:in `block in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus/load_tracking.rb:7:in `features_loaded_by'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:53:in `go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `block (3 levels) in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `fork'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `block (2 levels) in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:63:in `each'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:63:in `block in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:61:in `loop'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:61:in `go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `block (3 levels) in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `fork'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `block (2 levels) in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:63:in `each'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:63:in `block in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:61:in `loop'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:61:in `go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `block (3 levels) in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `fork'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `block (2 levels) in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:63:in `each'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:63:in `block in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:61:in `loop'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:61:in `go'
    from -e:1:in `<main>'

My specs do not depend on Redis. Actually, I am using MockRedis.

I don't understand how Zeus is trying to connect with localhost:6380. When I connect to Redis in the development environment, I am using the default of localhost:6379. Staging and production environments are using localhost:6380.

I started a Redis server on port 6380:

$ redis-server /etc/redis.conf 
[51082] 12 Dec 19:34:53 * Server started, Redis version 2.2.12
[51082] 12 Dec 19:34:53 * The server is now ready to accept connections on port 6380

I still get these crashes:

zeus test (alias: rspec, testrb) [run to see backtrace]
zeus cucumber [run to see backtrace]
$ zeus rspec spec/models/user_spec.rb                                         
/Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:236:in `rescue in establish_connection': Connection refused - Unable to connect to Redis on localhost:6379 (Errno::ECONNREFUSED)
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:222:in `establish_connection'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:23:in `connect'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus/rails.rb:238:in `block in reconnect_redis'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus/rails.rb:237:in `each_object'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus/rails.rb:237:in `reconnect_redis'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus/rails.rb:32:in `after_fork'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:151:in `run_action'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:54:in `block in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus/load_tracking.rb:7:in `features_loaded_by'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:53:in `go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `block (3 levels) in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `fork'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `block (2 levels) in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:63:in `each'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:63:in `block in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:61:in `loop'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:61:in `go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `block (3 levels) in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `fork'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `block (2 levels) in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:63:in `each'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:63:in `block in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:61:in `loop'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:61:in `go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `block (3 levels) in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `fork'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:67:in `block (2 levels) in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:63:in `each'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:63:in `block in go'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:61:in `loop'
    from /Users/simeon/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/zeus-0.13.1/lib/zeus.rb:61:in `go'
    from -e:1:in `<main>'

localhost:6379? OK. I started a second Redis server on port 6379. Looks like zeus test is ready.

zeus cucumber [run to see backtrace]
zeus test (alias: rspec, testrb)
$ zeus rspec spec/models/user_spec.rb
...
Finished in 2.64 seconds
30 examples, 0 failures

Woot!

This app doesn't have any features, so I didn't try cucumber.

@burke Hope this helps. If you have any questions, please let me know. I'll go back to using 0.4.4. Thanks so much for this gem; its awesome!

@simeonwillbanks

More info for debugging:

$ bundle exec rails console test
Loading test environment (Rails 3.2.8)
[1] pry(main)> ObjectSpace.each_object(Redis::Client).each {|r| puts r.inspect}
#<Redis::Client:0x007fedf60456a0 @path=nil, @host="localhost", @port=6379, @db=1, @timeout=5.0, @password=nil, @logger=nil, @reconnect=true, @connection=#<Redis::Connection::Ruby:0x007fedf6045510 @sock=nil>>
#<Redis::Client:0x007fedf6053480 @path=nil, @host="localhost", @port=6380, @db=0, @timeout=5.0, @password=nil, @logger=nil, @reconnect=true, @connection=#<Redis::Connection::Ruby:0x007fedf6053430 @sock=nil>>
#<Redis::Client:0x007fedf60d5bb0 @path=nil, @host="localhost", @port=6379, @db=8, @timeout=5.0, @password=nil, @logger=nil, @reconnect=true, @connection=#<Redis::Connection::Ruby:0x007fedf60d5b38 @sock=nil>>
=> 3
$ bundle exec rails console
Loading development environment (Rails 3.2.8)
[1] pry(main)> ObjectSpace.each_object(Redis::Client).each {|r| puts r.inspect}
#<Redis::Client:0x007fe2107b30a0 @path=nil, @host="localhost", @port=6379, @db=1, @timeout=5.0, @password=nil, @logger=nil, @reconnect=true, @connection=#<Redis::Connection::Ruby:0x007fe2107b2e98 @sock=nil>>
#<Redis::Client:0x007fe210d636d0 @path=nil, @host="localhost", @port=6379, @db=8, @timeout=5.0, @password=nil, @logger=nil, @reconnect=true, @connection=#<Redis::Connection::Ruby:0x007fe210d63608 @sock=nil>>
#<Redis::Client:0x007fe210e31c88 @path=nil, @host="localhost", @port=6379, @db=0, @timeout=5.0, @password=nil, @logger=nil, @reconnect=true, @connection=#<Redis::Connection::Ruby:0x007fe210e31be8 @sock=nil>>
#<Redis::Client:0x007fe210e56790 @path=nil, @host="localhost", @port=6379, @db=1, @timeout=5.0, @password=nil, @logger=nil, @reconnect=true, @connection=#<Redis::Connection::Ruby:0x007fe210e56150 @sock=nil>>
=> 4

I think the answer is to ensure Redis::Client is not defined when it is not needed. Thoughts?

@MattRogish

I'm on zeus 0.13.1 on OSX 10.8.x and I've noticed now (after upgrading from zeus 0.12.0) I get occasional hangs waiting on test_helper that didn't happen on 0.12.0. I have to restart zeus to run specs again.

@dpickett dpickett added a commit that referenced this issue Dec 28, 2012
@dpickett dpickett don't manage redis connections in test
as alluded to in #123, allow users of zeus to self
manage their redis connections in test.
9cf85d3
@turadg
Collaborator
turadg commented Jan 22, 2013

Is this still a problem in 0.13.2? redis_reconnect now fails silently: 4009bf3

@burke
Owner
burke commented Feb 28, 2014

Issue looks dead, closing.

@burke burke closed this Feb 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.