summaryrefslogtreecommitdiffstats
path: root/features/support/helpers/exec_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'features/support/helpers/exec_helper.rb')
-rw-r--r--features/support/helpers/exec_helper.rb20
1 files changed, 13 insertions, 7 deletions
diff --git a/features/support/helpers/exec_helper.rb b/features/support/helpers/exec_helper.rb
index b0d3a9c..400b0ae 100644
--- a/features/support/helpers/exec_helper.rb
+++ b/features/support/helpers/exec_helper.rb
@@ -11,12 +11,10 @@ class VMCommand
end
def VMCommand.wait_until_remote_shell_is_up(vm, timeout = 30)
- begin
- Timeout::timeout(timeout) do
- VMCommand.execute(vm, "true", { :user => "root", :spawn => false })
+ try_for(30, :msg => "Remote shell seems to be down") do
+ Timeout::timeout(3) do
+ VMCommand.execute(vm, "echo 'hello?'")
end
- rescue Timeout::Error
- raise "Remote shell seems to be down"
end
end
@@ -34,14 +32,14 @@ class VMCommand
options[:spawn] ||= false
type = options[:spawn] ? "spawn" : "call"
socket = TCPSocket.new("127.0.0.1", vm.get_remote_shell_port)
- STDERR.puts "#{type}ing as #{options[:user]}: #{cmd}" if $debug
+ STDERR.puts "#{type}ing as #{options[:user]}: #{cmd}" if $config["DEBUG"]
begin
socket.puts(JSON.dump([type, options[:user], cmd]))
s = socket.readline(sep = "\0").chomp("\0")
ensure
socket.close
end
- STDERR.puts "#{type} returned: #{s}" if $debug
+ STDERR.puts "#{type} returned: #{s}" if $config["DEBUG"]
begin
return JSON.load(s)
rescue JSON::ParserError
@@ -58,4 +56,12 @@ class VMCommand
return @returncode == 0
end
+ def to_s
+ "Return status: #{@returncode}\n" +
+ "STDOUT:\n" +
+ @stdout +
+ "STDERR:\n" +
+ @stderr
+ end
+
end