tristandunn / pusher-fake

A fake Pusher server for development and testing.
https://rubygems.org/gems/pusher-fake
MIT License
173 stars 32 forks source link

Multiple Ports for parallel_tests #38

Closed mattpickle closed 9 years ago

mattpickle commented 9 years ago

I'm having some issues with pusher-fake and parallel_tests.

/Users//.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:526:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)

Here's the code I'm running to start multiple ports in spec_helper:config.before(:suite). I'm bypassing the pusher initializer code if running parallel_tests.

# Parallel Tests PusherFake Setup
if !ENV['TEST_ENV_NUMBER'].nil?
  Pusher.host = "127.0.0.1"
  Pusher.port = available_port
  puts "#{ENV['TEST_ENV_NUMBER']}- #{Pusher.host}:#{Pusher.port}"

  fork { PusherFake::Server.start }.tap do |id|
    at_exit { Process.kill("KILL", id) }
  end
end

Any ideas? The above code runs fine for 1 thread with parallel_tests. Fails for 2.

mattpickle commented 9 years ago

Upgrading gem to 1.2.0 seems to have solved the problem.