From 1f3542d5a076d47832bbc6cef8d99e04df419d92 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 6 Mar 2014 23:29:21 +0000 Subject: [PATCH] silence warnings during rspec test runs If we're testing via rspec, we don't need to include any corosync recipes, so we don't need to warn about anything. However if we're *not* testing and we're still using Chef Solo, then pacemaker::default can't possibly work, due to corosync::authkey requiring Chef search. In this case we need to abort. --- recipes/default.rb | 7 ++++++- spec/spec_helper.rb | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/recipes/default.rb b/recipes/default.rb index 5ad3b58..74893f8 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -39,7 +39,12 @@ if node[:pacemaker][:setup_hb_gui] end if Chef::Config[:solo] - ::Chef::Log.warn "Using Chef Solo, you are expected to manually include the corosync default recipe!" + unless ENV['RSPEC_RUNNING'] + Chef::Application.fatal! \ + "pacemaker::default needs corosync::default which uses search, " \ + "but Chef Solo does not support search." + return + end else include_recipe "corosync::default" end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b26a01e..79c8501 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,7 @@ require 'chefspec' +ENV['RSPEC_RUNNING'] = 'true' + RSpec.configure do |config| # config.mock_with :rspec do |mocks| # # This option should be set when all dependencies are being loaded