diff options
author | Serdar Sutay <serdar@opscode.com> | 2014-11-14 15:40:24 -0800 |
---|---|---|
committer | tyler-ball <tyleraball@gmail.com> | 2014-12-17 18:50:10 -0800 |
commit | d20d3aca4e6cc947322c347ba6b7a0f6260576b6 (patch) | |
tree | ca7a7c2501cb705504b1c5d75515e6528ca1648b /lib/chef/audit | |
parent | 221131fa38d77fd3e1cd914fba4dde73b749b78b (diff) | |
download | chef-d20d3aca4e6cc947322c347ba6b7a0f6260576b6.tar.gz |
Make sure we don't close the output_stream after running rspec.
Diffstat (limited to 'lib/chef/audit')
-rw-r--r-- | lib/chef/audit/audit_reporter.rb | 23 | ||||
-rw-r--r-- | lib/chef/audit/rspec_formatter.rb | 19 | ||||
-rw-r--r-- | lib/chef/audit/runner.rb | 1 |
3 files changed, 26 insertions, 17 deletions
diff --git a/lib/chef/audit/audit_reporter.rb b/lib/chef/audit/audit_reporter.rb index b1c9d30bfc..a671ce2221 100644 --- a/lib/chef/audit/audit_reporter.rb +++ b/lib/chef/audit/audit_reporter.rb @@ -53,15 +53,9 @@ class Chef post_auditing_data end - # If the audit phase failed, its because there was some kind of error in the framework - # that runs tests - normal errors are interpreted as EXAMPLE failures and captured. def audit_phase_failed(error) - # The stacktrace information has already been logged elsewhere - Chef::Log.error("Audit Reporter failed - sending error to server with available example information") - ordered_control_groups.each do |name, control_group| - audit_data.add_control_group(control_group) - end - post_auditing_data(error) + # TODO + raise error end def control_group_started(name) @@ -87,16 +81,13 @@ class Chef private - def post_auditing_data(error = nil) + def post_auditing_data if auditing_enabled? - audit_history_url = "controls" - Chef::Log.info("Sending audit report (run-id: #{audit_data.run_id})") + node_name = audit_data.node_name + run_id = audit_data.run_id + audit_history_url = "audits/nodes/#{node_name}/runs/#{run_id}" + Chef::Log.info("Sending audit report (run-id: #{run_id})") run_data = audit_data.to_hash - - if error - run_data[:error] = "#{error.class.to_s}: #{error.message}\n#{error.backtrace.join("\n")}" - end - Chef::Log.debug run_data.inspect compressed_data = encode_gzip(Chef::JSONCompat.to_json(run_data)) Chef::Log.debug("Sending compressed audit data...") diff --git a/lib/chef/audit/rspec_formatter.rb b/lib/chef/audit/rspec_formatter.rb new file mode 100644 index 0000000000..990c1cd780 --- /dev/null +++ b/lib/chef/audit/rspec_formatter.rb @@ -0,0 +1,19 @@ +require 'rspec/core' + +class Chef + class Audit + class RspecFormatter < RSpec::Core::Formatters::DocumentationFormatter + RSpec::Core::Formatters.register self, :close + + # @api public + # + # Invoked at the very end, `close` allows the formatter to clean + # up resources, e.g. open streams, etc. + # + # @param _notification [NullNotification] (Ignored) + def close(_notification) + # Normally Rspec closes the streams it's given. We don't want it for Chef. + end + end + end +end diff --git a/lib/chef/audit/runner.rb b/lib/chef/audit/runner.rb index 4059741359..e20c8b3810 100644 --- a/lib/chef/audit/runner.rb +++ b/lib/chef/audit/runner.rb @@ -71,7 +71,6 @@ class Chef configuration.backtrace_exclusion_patterns.push(Regexp.new("/Users".gsub("/", File::SEPARATOR))) configuration.backtrace_exclusion_patterns.push(Regexp.new("(eval)")) configuration.color = Chef::Config[:color] - configuration.expose_dsl_globally = false add_formatters disable_should_syntax |