summaryrefslogtreecommitdiff
path: root/spec/integration
diff options
context:
space:
mode:
authorSteven Murawski <steven.murawski@gmail.com>2017-04-04 17:11:55 -0500
committerGitHub <noreply@github.com>2017-04-04 17:11:55 -0500
commit39d79141dc0b98750a51edab7d05b60c5cc8224a (patch)
treec0f699d7301ba6d821dc13cdeb5735290c73c8b3 /spec/integration
parenta25d5f238b6f4144f16f6df8c44bd1231d02fd3f (diff)
parentd08cbdaad788da3b9b1658717353f939361b3add (diff)
downloadchef-39d79141dc0b98750a51edab7d05b60c5cc8224a.tar.gz
Merge pull request #6001 from chef/smurawski/exit_status_default
Make Standardized Exit Codes The Default Behavior
Diffstat (limited to 'spec/integration')
-rw-r--r--spec/integration/client/exit_code_spec.rb106
1 files changed, 1 insertions, 105 deletions
diff --git a/spec/integration/client/exit_code_spec.rb b/spec/integration/client/exit_code_spec.rb
index 30020f6a3f..4397426723 100644
--- a/spec/integration/client/exit_code_spec.rb
+++ b/spec/integration/client/exit_code_spec.rb
@@ -25,7 +25,7 @@ describe "chef-client" do
let(:critical_env_vars) { %w{PATH RUBYOPT BUNDLE_GEMFILE GEM_PATH}.map { |o| "#{o}=#{ENV[o]}" } .join(" ") }
- when_the_repository "does not have exit_status configured" do
+ when_the_repository "uses RFC 062 defined exit codes" do
def setup_client_rb
file "config/client.rb", <<EOM
@@ -43,110 +43,6 @@ EOM
end
def run_chef_client_and_expect_exit_code(exit_code)
- shell_out!(
- "#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'",
- :cwd => chef_dir,
- :returns => [exit_code])
- end
-
- context "has a cookbook" do
- context "with a library" do
- context "which cannot be loaded" do
- before do
- file "cookbooks/x/recipes/default.rb", ""
- file "cookbooks/x/libraries/error.rb", "require 'does/not/exist'"
- end
-
- it "exits with GENERIC_FAILURE, 1" do
- setup_client_rb
- run_chef_client_and_expect_exit_code 1
- end
- end
- end
-
- context "with an audit recipe" do
- context "which fails" do
- before do
- file "cookbooks/x/recipes/default.rb", <<-RECIPE
-control_group "control group without top level control" do
- it "should fail" do
- expect(2 - 2).to eq(1)
- end
-end
-RECIPE
- end
-
- it "exits with GENERIC_FAILURE, 1" do
- setup_client_rb_with_audit_mode
- run_chef_client_and_expect_exit_code 1
- end
- end
- end
-
- context "with a recipe" do
- context "which throws an error" do
- before { file "cookbooks/x/recipes/default.rb", "raise 'BOOM'" }
-
- it "exits with GENERIC_FAILURE, 1" do
- setup_client_rb
- run_chef_client_and_expect_exit_code 1
- end
- end
-
- context "with a recipe which calls Chef::Application.fatal with a non-RFC exit code" do
- before { file "cookbooks/x/recipes/default.rb", "Chef::Application.fatal!('BOOM', 123)" }
-
- it "exits with the specified exit code" do
- setup_client_rb
- run_chef_client_and_expect_exit_code 123
- end
- end
-
- context "with a recipe which calls Chef::Application.exit with a non-RFC exit code" do
- before { file "cookbooks/x/recipes/default.rb", "Chef::Application.exit!('BOOM', 231)" }
-
- it "exits with the specified exit code" do
- setup_client_rb
- run_chef_client_and_expect_exit_code 231
- end
- end
- end
-
- context "when an attempt to reboot fails (like from the reboot resource)" do
- before do
- file "cookbooks/x/recipes/default.rb", <<EOM
-raise Chef::Exceptions::RebootFailed.new
-EOM
- end
-
- it "exits with GENERIC_FAILURE, 1" do
- setup_client_rb
- run_chef_client_and_expect_exit_code 1
- end
- end
- end
- end
-
- when_the_repository "does has exit_status enabled" do
-
- def setup_client_rb
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-exit_status :enabled
-EOM
- end
-
- def setup_client_rb_with_audit_mode
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-exit_status :enabled
-audit_mode :audit_only
-EOM
- end
-
- def run_chef_client_and_expect_exit_code(exit_code)
shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'",
:cwd => chef_dir,
:returns => [exit_code])