Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

allow override of tcp and ssh timeout through environment variable VE…

…EWEE_TIMEOUT. This allows for automated timeouts
  • Loading branch information...
commit 739472f5c14ed76e247c15f41b4084d10c96ef8b 1 parent 3058d13
@jedi4ever jedi4ever authored
View
12 Rakefile
@@ -67,6 +67,9 @@ end
desc 'Autobuilds all templates and runs validation'
task :autotest do
+ # We overrule all timeouts for tcp and ssh
+ ENV['VEEWEE_TIMEOUT']='6'
+
ve=Veewee::Environment.new()
ve.templates.each do |name,template|
begin
@@ -81,6 +84,15 @@ task :autotest do
box.destroy
rescue Exception => ex
puts "AUTO: Template #{name} failed - #{ex}"
+ if box.running?
+ begin
+ screenshot="screenshot-auto-#{name}.png"
+ puts "AUTO: Taking snapshot #{screenshot}"
+ box.screenshot(screenshot)
+ rescue Veewee::Error => ex
+ puts "AUTO: Error taking screenshot"
+ end
+ end
end
end
end
View
11 lib/veewee/provider/core/helper/ssh.rb
@@ -25,16 +25,18 @@ def when_ssh_login_works(ip="127.0.0.1", options = { } , &block)
defaults={ :port => '22', :timeout => 20000 }
options=defaults.merge(options)
+ timeout = options[:timeout]
+ timeout=ENV['VEEWEE_TIMEOUT'] unless ENV['VEEWEE_TIMEOUT'].nil?
- ui.info "Waiting for ssh login on #{ip} with user #{options[:user]} to sshd on port => #{options[:port]} to work, timeout=#{options[:timeout]} sec"
+ ui.info "Waiting for ssh login on #{ip} with user #{options[:user]} to sshd on port => #{options[:port]} to work, timeout=#{timeout} sec"
begin
- Timeout::timeout(options[:timeout]) do
+ Timeout::timeout(timeout) do
connected=false
while !connected do
begin
env.ui.info ".",{:new_line => false , :prefix => false}
- Net::SSH.start(ip, options[:user], { :port => options[:port] , :password => options[:password], :paranoid => false , :timeout => options[:timeout] }) do |ssh|
+ Net::SSH.start(ip, options[:user], { :port => options[:port] , :password => options[:password], :paranoid => false , :timeout => timeout }) do |ssh|
ui.info "\n", {:prefix => false}
block.call(ip);
@@ -46,8 +48,7 @@ def when_ssh_login_works(ip="127.0.0.1", options = { } , &block)
end
end
rescue Timeout::Error
- ui.error "Ssh timeout #{options[:timeout]} sec has been reached."
- raise Veewee::Error, "Ssh timeout #{options[:timeout]} sec has been reached."
+ raise Veewee::Error, "Ssh timeout #{timeout} sec has been reached."
end
ui.info ""
return false
View
6 lib/veewee/provider/core/helper/tcp.rb
@@ -52,9 +52,11 @@ def execute_when_tcp_available(ip="127.0.0.1", options = { } , &block)
defaults={ :port => 22, :timeout => 2 , :pollrate => 5}
options=defaults.merge(options)
+ timeout=options[:timeout]
+ timeout=ENV['VEEWEE_TIMEOUT'] unless ENV['VEEWEE_TIMEOUT'].nil?
begin
- Timeout::timeout(options[:timeout]) do
+ Timeout::timeout(timeout) do
connected=false
while !connected do
begin
@@ -69,7 +71,7 @@ def execute_when_tcp_available(ip="127.0.0.1", options = { } , &block)
end
end
rescue Timeout::Error
- raise 'timeout connecting to port'
+ raise "Timeout connecting to TCP port {options[:port]} exceeded #{timeout} secs."
end
return false
Please sign in to comment.
Something went wrong with that request. Please try again.