3 $ARV_API_SERVER_DIR = File.expand_path('../..', __FILE__)
4 SERVER_PID_PATH = 'tmp/pids/passenger.3002.pid'
6 class WebsocketTestRunner < MiniTest::Unit
8 Bundler.with_clean_env do
9 if not system({'ARVADOS_WEBSOCKETS' => 'ws-only', 'RAILS_ENV' => 'test'}, *cmd)
10 raise RuntimeError, "Command failed with exit status #{$?}: #{cmd.inspect}"
16 server_pid = Dir.chdir($ARV_API_SERVER_DIR) do |apidir|
17 # Only passenger seems to be able to run the websockets server successfully.
18 _system('passenger', 'start', '-d', '-p3002')
19 timeout = Time.now.tv_sec + 10
23 server_pid = IO.read(SERVER_PID_PATH).to_i
24 good_pid = (server_pid > 0) and (Process.kill(0, pid) rescue false)
28 end while (not good_pid) and (Time.now.tv_sec < timeout)
30 raise RuntimeError, "could not find API server Rails pid"
37 Dir.chdir($ARV_API_SERVER_DIR) do
38 _system('passenger', 'stop', '-p3002')
40 # DatabaseCleaner leaves the database empty. Prefer to leave it full.
41 dc = DatabaseController.new
42 dc.define_singleton_method :render do |*args| end
48 MiniTest::Unit.runner = WebsocketTestRunner.new