mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
make the install command raise exception if some error happened
Fixes #5862
This commit is contained in:
parent
88bec2f24f
commit
5472186a24
4 changed files with 14 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue