summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-12-05 16:39:55 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2018-12-05 16:39:55 -0800
commit69b9bed127edd0cf38bac6a53eba6122888a2cb4 (patch)
treeb19457fe7ef54755979888fdf564547d568427d0
parent5354fe2f45e44dfa829dbb055ef118ddb64674b7 (diff)
downloadchef-69b9bed127edd0cf38bac6a53eba6122888a2cb4.tar.gz
lets try to be a bit nicer to future debuggers
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--spec/functional/resource/apt_package_spec.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/spec/functional/resource/apt_package_spec.rb b/spec/functional/resource/apt_package_spec.rb
index 4fd39d2d47..06a93d22d9 100644
--- a/spec/functional/resource/apt_package_spec.rb
+++ b/spec/functional/resource/apt_package_spec.rb
@@ -92,6 +92,10 @@ metadata = { unix_only: true,
arch: "x86_64" # test packages are 64bit
}
+class INeedSomeGlobalState
+ attr_accessor :alreadyfailed
+end
+
describe Chef::Resource::AptPackage, metadata do
include Chef::Mixin::ShellOut
@@ -103,7 +107,21 @@ describe Chef::Resource::AptPackage, metadata do
# Disable mixlib-shellout live streams
Chef::Log.level = :warn
start_apt_server
- enable_testing_apt_source rescue nil # important: ignore errors so the before all does not get re-run on failures
+ begin
+ enable_testing_apt_source
+ rescue
+ # if the apt-get update fails, then this before will run on every example until
+ # it succeeds (turning it into before(:each)). we have been seeing rate liming problems
+ # which this behavior only makes worse. so we only want to fail the first time, and
+ # swallow the errors the second time (which unfortunately creates cascading errors which
+ # have nothing to do with the problem), but the first time we throw the exception so
+ # that debugging can hopefully proceeed.
+ if INeedSomeGlobalState.alreadyfailed
+ raise
+ else
+ INeedSomeGlobalState.alreadyfailed = true
+ end
+ end
end
after(:all) do