kill osrm-routed if it refuses to shutdown in cuke tests
This commit is contained in:
parent
7f7055a9e7
commit
7e9614b9ec
@ -1,14 +1,24 @@
|
|||||||
require 'socket'
|
require 'socket'
|
||||||
require 'sys/proctable'
|
require 'sys/proctable'
|
||||||
|
|
||||||
LAUNCH_TIMEOUT = 5
|
LAUNCH_TIMEOUT = 2
|
||||||
SHUTDOWN_TIMEOUT = 5
|
SHUTDOWN_TIMEOUT = 2
|
||||||
|
|
||||||
class OSRMLauncher
|
class OSRMLauncher
|
||||||
def initialize &block
|
def initialize &block
|
||||||
Dir.chdir TEST_FOLDER do
|
Dir.chdir TEST_FOLDER do
|
||||||
begin
|
begin
|
||||||
begin
|
launch
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
shutdown
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def launch
|
||||||
Timeout.timeout(LAUNCH_TIMEOUT) do
|
Timeout.timeout(LAUNCH_TIMEOUT) do
|
||||||
osrm_up
|
osrm_up
|
||||||
wait_for_connection
|
wait_for_connection
|
||||||
@ -16,19 +26,16 @@ class OSRMLauncher
|
|||||||
rescue Timeout::Error
|
rescue Timeout::Error
|
||||||
raise "*** Launching osrm-routed timed out."
|
raise "*** Launching osrm-routed timed out."
|
||||||
end
|
end
|
||||||
yield
|
|
||||||
ensure
|
def shutdown
|
||||||
begin
|
|
||||||
Timeout.timeout(SHUTDOWN_TIMEOUT) do
|
Timeout.timeout(SHUTDOWN_TIMEOUT) do
|
||||||
osrm_down
|
osrm_down
|
||||||
end
|
end
|
||||||
rescue Timeout::Error
|
rescue Timeout::Error
|
||||||
|
kill
|
||||||
raise "*** Shutting down osrm-routed timed out."
|
raise "*** Shutting down osrm-routed timed out."
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def osrm_up?
|
def osrm_up?
|
||||||
if @pipe
|
if @pipe
|
||||||
@ -55,7 +62,6 @@ def osrm_down
|
|||||||
if @pipe
|
if @pipe
|
||||||
Process.kill 'TERM', @pipe.pid
|
Process.kill 'TERM', @pipe.pid
|
||||||
wait_for_shutdown
|
wait_for_shutdown
|
||||||
@pipe = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -81,3 +87,4 @@ def wait_for_shutdown
|
|||||||
sleep 0.1
|
sleep 0.1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user