make the install command raise exception if some error happened

Fixes #5862
This commit is contained in:
Pere Urbon-Bayes 2016-09-05 19:28:47 +02:00
parent 254297eec7
commit 8271304f59
4 changed files with 14 additions and 7 deletions

View file

@ -4,6 +4,8 @@ require_relative "system_helpers"
module ServiceTester
class InstallException < Exception; end
class Base
LOCATION="/logstash-build".freeze
LOGSTASH_PATH="/usr/share/logstash/".freeze

View file

@ -22,9 +22,14 @@ module ServiceTester
def install(package, host=nil)
hosts = (host.nil? ? servers : Array(host))
errors = []
at(hosts, {in: :serial}) do |_|
sudo_exec!("dpkg -i --force-confnew #{package}")
cmd = sudo_exec!("dpkg -i --force-confnew #{package}")
if cmd.exit_status != 0
errors << cmd.stderr.to_s
end
end
raise InstallException.new(errors.join("\n")) unless errors.empty?
end
def uninstall(package, host=nil)

View file

@ -22,12 +22,12 @@ module ServiceTester
def install(package, host=nil)
hosts = (host.nil? ? servers : Array(host))
errors = {}
errors = []
at(hosts, {in: :serial}) do |_host|
cmd = sudo_exec!("yum install -y #{package}")
errors[_host] = cmd.stderr unless cmd.stderr.empty?
errors << cmd.stderr unless cmd.stderr.empty?
end
errors
raise InstallException.new(errors.join("\n")) unless errors.empty?
end
def uninstall(package, host=nil)

View file

@ -19,12 +19,12 @@ module ServiceTester
def install(package, host=nil)
hosts = (host.nil? ? servers : Array(host))
errors = {}
errors = []
at(hosts, {in: :serial}) do |_host|
cmd = sudo_exec!("zypper --no-gpg-checks --non-interactive install #{package}")
errors[_host] = cmd.stderr unless cmd.stderr.empty?
errors << cmd.stderr unless cmd.stderr.empty?
end
errors
raise InstallException.new(errors.join("\n")) unless errors.empty?
end
def uninstall(package, host=nil)