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, "#{cmd[0]} returned exit code #{$?.exitstatus}"
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 Process.kill('TERM', server_pid)
42 MiniTest::Unit.runner = WebsocketTestRunner.new