Kouhei Sutou
null+****@clear*****
Sun Jul 20 23:43:53 JST 2014
Kouhei Sutou 2014-07-20 23:43:53 +0900 (Sun, 20 Jul 2014) New Revision: 0c7117b89e6982fbb8b36e87f006ec191bdb4d8f https://github.com/droonga/drntest/commit/0c7117b89e6982fbb8b36e87f006ec191bdb4d8f Message: Use --ready-notify-fd to wait droonga-engine is ready Modified files: lib/drntest/engine.rb Modified: lib/drntest/engine.rb (+9 -27) =================================================================== --- lib/drntest/engine.rb 2014-07-16 22:43:26 +0900 (75a2241) +++ lib/drntest/engine.rb 2014-07-20 23:43:53 +0900 (25084a3) @@ -105,37 +105,31 @@ module Drntest output.puts(JSON.pretty_generate(catalog_json)) end + ready_notify_in, ready_notify_out = IO.pipe command = [ @config.droonga_engine, "--host", @config.host, "--port", @config.port.to_s, "--tag", @config.tag, + "--base-dir", temporary_dir.to_s, + "--ready-notify-fd", ready_notify_out.fileno.to_s, *@config.droonga_engine_options, ] env = { - "DROONGA_BASE_DIR" => temporary_dir.to_s, } options = { - :chdir => temporary_dir.to_s, :err => :out, + ready_notify_out => ready_notify_out, } arguments = [env, *command] arguments << options @pid = Process.spawn(*arguments) - - wait_until_ready - @ready_time = Time.now + ready_notify_out.close + wait_until_ready(ready_notify_in) + ready_notify_in.close end def teardown - # TODO: REMOVE ME. Workaround for kill -TERM shutdown failure of - # omit tests. - running_time = Time.now - @ready_time - least_running_time = 1 - if running_time < least_running_time - sleep(least_running_time - running_time) - end - Process.kill(:TERM, @pid) Process.wait(@pid) @@ -171,20 +165,8 @@ module Drntest temporary_base_dir + "drntest" end - def ready? - begin - socket = TCPSocket.new(@config.host, @config.port) - socket.close - true - rescue Errno::ECONNREFUSED - false - end - end - - def wait_until_ready - until ready? - sleep(0.1) - end + def wait_until_ready(ready_notify_in) + ready_notify_in.gets end end end -------------- next part -------------- HTML����������������������������...Download