make redhat test uninstall a packege after test are done also making sure install errors are raised only when an error code is != 0

Fixes #5936
This commit is contained in:
Pere Urbon-Bayes 2016-09-16 16:13:20 +02:00 committed by Suyog Rao
parent 9549d1291e
commit 8be69814c8
2 changed files with 7 additions and 1 deletions

View file

@ -5,6 +5,7 @@ require 'logstash/version'
RSpec.shared_examples "installable" do |logstash|
before(:each) do
logstash.uninstall
logstash.install({:version => LOGSTASH_VERSION})
end

View file

@ -23,17 +23,22 @@ module ServiceTester
def install(package, host=nil)
hosts = (host.nil? ? servers : Array(host))
errors = []
exit_status = 0
at(hosts, {in: :serial}) do |_host|
cmd = sudo_exec!("yum install -y #{package}")
exit_status += cmd.exit_status
errors << cmd.stderr unless cmd.stderr.empty?
end
raise InstallException.new(errors.join("\n")) unless errors.empty?
if exit_status > 0
raise InstallException.new(errors.join("\n"))
end
end
def uninstall(package, host=nil)
hosts = (host.nil? ? servers : Array(host))
at(hosts, {in: :serial}) do |_|
sudo_exec!("yum remove -y #{package}")
sudo_exec!("rm -rf /etc/logstash")
end
end