1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Merge pull request #442 from willbryant/master

Handle Net::SSH::Disconnected like IOError in teardown_connections_to
This commit is contained in:
Lee Hambley 2013-04-22 00:38:05 -07:00
commit 341629b2b9
2 changed files with 19 additions and 1 deletions

View file

@ -141,7 +141,7 @@ module Capistrano
begin
session = sessions.delete(server)
session.close if session
rescue IOError
rescue IOError, Net::SSH::Disconnect
# the TCP connection is already dead
end
end

View file

@ -398,6 +398,24 @@ class ConfigurationConnectionsTest < Test::Unit::TestCase
@config.execute_on_servers {}
end
def test_execute_on_servers_should_cope_with_already_disconnected_connections_when_attempting_to_close_them
cap1 = server("cap1")
cap2 = server("cap2")
connection1 = mock()
connection2 = mock()
connection3 = mock()
connection4 = mock()
connection1.expects(:close).raises(Net::SSH::Disconnect)
connection2.expects(:close)
connection3.expects(:close)
connection4.expects(:close)
@config.current_task = mock_task(:max_hosts => 1)
@config.expects(:find_servers_for_task).times(2).with(@config.current_task, {}).returns([cap1, cap2])
Capistrano::SSH.expects(:connect).times(4).returns(connection1).then.returns(connection2).then.returns(connection3).then.returns(connection4)
@config.execute_on_servers {}
@config.execute_on_servers {}
end
def test_connect_should_honor_once_option
assert @config.sessions.empty?
@config.current_task = mock_task