Skip to content

Commit 5472186

Browse files
author
Pere Urbon-Bayes
committed
make the install command raise exception if some error happened
Fixes #5862
1 parent 88bec2f commit 5472186

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

qa/rspec/commands/base.rb

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
module ServiceTester
66

7+
class InstallException < Exception; end
8+
79
class Base
810
LOCATION="/logstash-build".freeze
911
LOGSTASH_PATH="/usr/share/logstash/".freeze

qa/rspec/commands/debian.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ def package_for(filename, base=ServiceTester::Base::LOCATION)
2222

2323
def install(package, host=nil)
2424
hosts = (host.nil? ? servers : Array(host))
25+
errors = []
2526
at(hosts, {in: :serial}) do |_|
26-
sudo_exec!("dpkg -i --force-confnew #{package}")
27+
cmd = sudo_exec!("dpkg -i --force-confnew #{package}")
28+
if cmd.exit_status != 0
29+
errors << cmd.stderr.to_s
30+
end
2731
end
32+
raise InstallException.new(errors.join("\n")) unless errors.empty?
2833
end
2934

3035
def uninstall(package, host=nil)

qa/rspec/commands/redhat.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ def package_for(filename, base=ServiceTester::Base::LOCATION)
2222

2323
def install(package, host=nil)
2424
hosts = (host.nil? ? servers : Array(host))
25-
errors = {}
25+
errors = []
2626
at(hosts, {in: :serial}) do |_host|
2727
cmd = sudo_exec!("yum install -y #{package}")
28-
errors[_host] = cmd.stderr unless cmd.stderr.empty?
28+
errors << cmd.stderr unless cmd.stderr.empty?
2929
end
30-
errors
30+
raise InstallException.new(errors.join("\n")) unless errors.empty?
3131
end
3232

3333
def uninstall(package, host=nil)

qa/rspec/commands/suse.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ def package_for(filename, base=ServiceTester::Base::LOCATION)
1919

2020
def install(package, host=nil)
2121
hosts = (host.nil? ? servers : Array(host))
22-
errors = {}
22+
errors = []
2323
at(hosts, {in: :serial}) do |_host|
2424
cmd = sudo_exec!("zypper --no-gpg-checks --non-interactive install #{package}")
25-
errors[_host] = cmd.stderr unless cmd.stderr.empty?
25+
errors << cmd.stderr unless cmd.stderr.empty?
2626
end
27-
errors
27+
raise InstallException.new(errors.join("\n")) unless errors.empty?
2828
end
2929

3030
def uninstall(package, host=nil)

0 commit comments

Comments
 (0)