Retry SCP upload 5 times as well
This commit is contained in:
parent
8dc57c6796
commit
abef4d29ce
|
@ -57,9 +57,16 @@ module Vagrant
|
||||||
# or StringIO, and `to` is expected to be a path. This method simply forwards
|
# or StringIO, and `to` is expected to be a path. This method simply forwards
|
||||||
# the arguments to `Net::SCP#upload!` so view that for more information.
|
# the arguments to `Net::SCP#upload!` so view that for more information.
|
||||||
def upload!(from, to)
|
def upload!(from, to)
|
||||||
execute do |ssh|
|
tries = 5
|
||||||
scp = Net::SCP.new(ssh.session)
|
|
||||||
scp.upload!(from, to)
|
begin
|
||||||
|
execute do |ssh|
|
||||||
|
scp = Net::SCP.new(ssh.session)
|
||||||
|
scp.upload!(from, to)
|
||||||
|
end
|
||||||
|
rescue IOError
|
||||||
|
retry if (tries -= 1) > 0
|
||||||
|
raise
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -144,6 +144,13 @@ class SshTest < Test::Unit::TestCase
|
||||||
@ssh.expects(:execute).yields(ssh).once
|
@ssh.expects(:execute).yields(ssh).once
|
||||||
@ssh.upload!("foo", "bar")
|
@ssh.upload!("foo", "bar")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "retry 5 times" do
|
||||||
|
@ssh.expects(:execute).times(5).raises(IOError)
|
||||||
|
assert_raises(IOError) {
|
||||||
|
@ssh.upload!("foo", "bar")
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "checking if host is up" do
|
context "checking if host is up" do
|
||||||
|
|
Loading…
Reference in New Issue