mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -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
|
module ServiceTester
|
||||||
|
|
||||||
|
class InstallException < Exception; end
|
||||||
|
|
||||||
class Base
|
class Base
|
||||||
LOCATION="/logstash-build".freeze
|
LOCATION="/logstash-build".freeze
|
||||||
LOGSTASH_PATH="/usr/share/logstash/".freeze
|
LOGSTASH_PATH="/usr/share/logstash/".freeze
|
||||||
|
|
|
@ -22,10 +22,15 @@ module ServiceTester
|
||||||
|
|
||||||
def install(package, host=nil)
|
def install(package, host=nil)
|
||||||
hosts = (host.nil? ? servers : Array(host))
|
hosts = (host.nil? ? servers : Array(host))
|
||||||
|
errors = []
|
||||||
at(hosts, {in: :serial}) do |_|
|
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
|
||||||
end
|
end
|
||||||
|
raise InstallException.new(errors.join("\n")) unless errors.empty?
|
||||||
|
end
|
||||||
|
|
||||||
def uninstall(package, host=nil)
|
def uninstall(package, host=nil)
|
||||||
hosts = (host.nil? ? servers : Array(host))
|
hosts = (host.nil? ? servers : Array(host))
|
||||||
|
|
|
@ -22,12 +22,12 @@ module ServiceTester
|
||||||
|
|
||||||
def install(package, host=nil)
|
def install(package, host=nil)
|
||||||
hosts = (host.nil? ? servers : Array(host))
|
hosts = (host.nil? ? servers : Array(host))
|
||||||
errors = {}
|
errors = []
|
||||||
at(hosts, {in: :serial}) do |_host|
|
at(hosts, {in: :serial}) do |_host|
|
||||||
cmd = sudo_exec!("yum install -y #{package}")
|
cmd = sudo_exec!("yum install -y #{package}")
|
||||||
errors[_host] = cmd.stderr unless cmd.stderr.empty?
|
errors << cmd.stderr unless cmd.stderr.empty?
|
||||||
end
|
end
|
||||||
errors
|
raise InstallException.new(errors.join("\n")) unless errors.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def uninstall(package, host=nil)
|
def uninstall(package, host=nil)
|
||||||
|
|
|
@ -19,12 +19,12 @@ module ServiceTester
|
||||||
|
|
||||||
def install(package, host=nil)
|
def install(package, host=nil)
|
||||||
hosts = (host.nil? ? servers : Array(host))
|
hosts = (host.nil? ? servers : Array(host))
|
||||||
errors = {}
|
errors = []
|
||||||
at(hosts, {in: :serial}) do |_host|
|
at(hosts, {in: :serial}) do |_host|
|
||||||
cmd = sudo_exec!("zypper --no-gpg-checks --non-interactive install #{package}")
|
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
|
end
|
||||||
errors
|
raise InstallException.new(errors.join("\n")) unless errors.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def uninstall(package, host=nil)
|
def uninstall(package, host=nil)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue