summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNitz <nitz.raz@gmail.com>2015-03-31 18:12:35 +0300
committerNitz <nitz.raz@gmail.com>2015-08-18 16:27:43 +0300
commitc93f286bb7c187522a1294ea8e52a5aa04273162 (patch)
tree305580570d095556404ee66b12041b0ffbd1a3e0
parentbacb2ff93ccc2e14a0b721988e241a1d07f70795 (diff)
downloadchef-c93f286bb7c187522a1294ea8e52a5aa04273162.tar.gz
Migrated deploy resource to use shell_out instead of run_command
Should help with troubleshooting failed migrations
-rw-r--r--lib/chef/provider/deploy.rb4
-rw-r--r--spec/functional/resource/deploy_revision_spec.rb2
-rw-r--r--spec/unit/provider/deploy_spec.rb10
3 files changed, 8 insertions, 8 deletions
diff --git a/lib/chef/provider/deploy.rb b/lib/chef/provider/deploy.rb
index 6d9b7f4397..77a0410593 100644
--- a/lib/chef/provider/deploy.rb
+++ b/lib/chef/provider/deploy.rb
@@ -201,7 +201,7 @@ class Chef
converge_by("execute migration command #{@new_resource.migration_command}") do
Chef::Log.info "#{@new_resource} migrating #{@new_resource.user} with environment #{env_info}"
- run_command(run_options(:command => @new_resource.migration_command, :cwd=>release_path, :log_level => :info))
+ shell_out!(@new_resource.migration_command,run_options(:cwd=>release_path, :log_level => :info))
end
end
end
@@ -221,7 +221,7 @@ class Chef
else
converge_by("restart app using command #{@new_resource.restart_command}") do
Chef::Log.info("#{@new_resource} restarting app")
- run_command(run_options(:command => @new_resource.restart_command, :cwd => @new_resource.current_path))
+ shell_out!(@new_resource.restart_command,run_options(:cwd=>@new_resource.current_path))
end
end
end
diff --git a/spec/functional/resource/deploy_revision_spec.rb b/spec/functional/resource/deploy_revision_spec.rb
index e5f5341fcd..4bce309a51 100644
--- a/spec/functional/resource/deploy_revision_spec.rb
+++ b/spec/functional/resource/deploy_revision_spec.rb
@@ -819,7 +819,7 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
end
before do
- expect { deploy_that_fails.run_action(:deploy) }.to raise_error(Chef::Exceptions::Exec)
+ expect { deploy_that_fails.run_action(:deploy) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
deploy_to_latest_with_callback_tracking.run_action(:deploy)
end
diff --git a/spec/unit/provider/deploy_spec.rb b/spec/unit/provider/deploy_spec.rb
index f6bb78823f..e6a7125e32 100644
--- a/spec/unit/provider/deploy_spec.rb
+++ b/spec/unit/provider/deploy_spec.rb
@@ -362,7 +362,7 @@ describe Chef::Provider::Deploy do
it "skips the migration when resource.migrate => false but runs symlinks before migration" do
@resource.migrate false
- expect(@provider).not_to receive :run_command
+ expect(@provider).not_to receive :shell_out!
expect(@provider).to receive :run_symlinks_before_migrate
@provider.migrate
end
@@ -378,7 +378,7 @@ describe Chef::Provider::Deploy do
allow(STDOUT).to receive(:tty?).and_return(true)
allow(Chef::Log).to receive(:info?).and_return(true)
- expect(@provider).to receive(:run_command).with(:command => "migration_foo", :cwd => @expected_release_dir,
+ expect(@provider).to receive(:shell_out!).with("migration_foo",:cwd => @expected_release_dir,
:user => "deployNinja", :group => "deployNinjas",
:log_level => :info, :live_stream => STDOUT,
:log_tag => "deploy[/my/deploy/dir]",
@@ -445,13 +445,13 @@ describe Chef::Provider::Deploy do
end
it "does nothing for restart if restart_command is empty" do
- expect(@provider).not_to receive(:run_command)
+ expect(@provider).not_to receive(:shell_out!)
@provider.restart
end
it "runs the restart command in the current application dir when the resource has a restart_command" do
@resource.restart_command "restartcmd"
- expect(@provider).to receive(:run_command).with(:command => "restartcmd", :cwd => "/my/deploy/dir/current", :log_tag => "deploy[/my/deploy/dir]", :log_level => :debug)
+ expect(@provider).to receive(:shell_out!).with("restartcmd", :cwd => "/my/deploy/dir/current", :log_tag => "deploy[/my/deploy/dir]", :log_level => :debug)
@provider.restart
end
@@ -509,7 +509,7 @@ describe Chef::Provider::Deploy do
it "shouldn't give a no method error on migrate if the environment is nil" do
allow(@provider).to receive(:enforce_ownership)
allow(@provider).to receive(:run_symlinks_before_migrate)
- allow(@provider).to receive(:run_command)
+ allow(@provider).to receive(:shell_out!)
@provider.migrate
end