summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortylercloke <tyler@opscode.com>2012-11-05 17:33:09 -0800
committertylercloke <tyler@opscode.com>2012-11-05 17:33:09 -0800
commit895adb2ce195be8a531c9103a6fdda1ce6ac710e (patch)
treee7c4f588f9f828708f589a8725085a0bd2b99d45
parentc85cb0ecfaeafaa3738ff9950f6fb97db298ae3f (diff)
downloadchef-895adb2ce195be8a531c9103a6fdda1ce6ac710e.tar.gz
Rebased and merged branch immediate-converge-action onto 10-stable from master.
-rw-r--r--chef/lib/chef/mixin/why_run.rb15
-rw-r--r--chef/lib/chef/provider.rb6
-rw-r--r--chef/lib/chef/provider/deploy.rb6
-rw-r--r--chef/lib/chef/provider/remote_directory.rb24
-rw-r--r--chef/spec/unit/provider/deploy/revision_spec.rb6
-rw-r--r--chef/spec/unit/provider/deploy_spec.rb42
-rw-r--r--chef/spec/unit/provider/erl_call_spec.rb2
-rw-r--r--chef/spec/unit/provider/file_spec.rb1
-rw-r--r--chef/spec/unit/provider/git_spec.rb10
-rw-r--r--chef/spec/unit/provider/group/groupadd_spec.rb2
-rw-r--r--chef/spec/unit/provider/package/rubygems_spec.rb18
-rw-r--r--chef/spec/unit/provider/package/yum_spec.rb4
-rw-r--r--chef/spec/unit/provider/remote_directory_spec.rb17
-rw-r--r--chef/spec/unit/provider/route_spec.rb4
-rw-r--r--chef/spec/unit/provider/service_spec.rb4
-rw-r--r--chef/spec/unit/provider/user_spec.rb23
-rw-r--r--chef/spec/unit/provider_spec.rb3
17 files changed, 46 insertions, 141 deletions
diff --git a/chef/lib/chef/mixin/why_run.rb b/chef/lib/chef/mixin/why_run.rb
index 22c58c1e54..788e2fe2bc 100644
--- a/chef/lib/chef/mixin/why_run.rb
+++ b/chef/lib/chef/mixin/why_run.rb
@@ -48,23 +48,16 @@ class Chef
# block/proc that implements the action.
def add_action(descriptions, &block)
@actions << [descriptions, block]
+ if !Chef::Config[:why_run]
+ block.call
+ end
+ events.resource_update_applied(@resource, @action, descriptions)
end
# True if there are no actions to execute.
def empty?
@actions.empty?
end
-
- # Iterate over the actions, and either print the action's message, or
- # run its code block, depending on whether why_run mode is active.
- def converge!
- @actions.each do |descriptions, block|
- if !Chef::Config[:why_run]
- block.call
- end
- events.resource_update_applied(@resource, @action, descriptions)
- end
- end
end
# == ResourceRequirements
diff --git a/chef/lib/chef/provider.rb b/chef/lib/chef/provider.rb
index d392c299c1..6e9c4f5acb 100644
--- a/chef/lib/chef/provider.rb
+++ b/chef/lib/chef/provider.rb
@@ -122,7 +122,8 @@ class Chef
else
send("action_#{@action}")
end
- converge
+
+ set_updated_status
cleanup_after_converge
end
@@ -132,8 +133,7 @@ class Chef
requirements.run(@action)
end
- def converge
- converge_actions.converge!
+ def set_updated_status
if converge_actions.empty? && !@new_resource.updated_by_last_action?
events.resource_up_to_date(@new_resource, @action)
else
diff --git a/chef/lib/chef/provider/deploy.rb b/chef/lib/chef/provider/deploy.rb
index 2920917d11..d05ab73f92 100644
--- a/chef/lib/chef/provider/deploy.rb
+++ b/chef/lib/chef/provider/deploy.rb
@@ -149,12 +149,6 @@ class Chef
def deploy
verify_directories_exist
- # CHEF-3435: We need to create the directories if they don't exist before calling the
- # scm_provider because it expects them to be there in its own assertations
- unless self.converge_actions.empty?
- Chef::Log.info "#{@new_resource} running collected converge_actions before calling scm_provider"
- self.converge_actions.converge!
- end
update_cached_repo # no converge-by - scm provider will dothis
enforce_ownership
copy_cached_repo
diff --git a/chef/lib/chef/provider/remote_directory.rb b/chef/lib/chef/provider/remote_directory.rb
index dee383f763..5b6348980c 100644
--- a/chef/lib/chef/provider/remote_directory.rb
+++ b/chef/lib/chef/provider/remote_directory.rb
@@ -39,22 +39,18 @@ class Chef
name !~ /(?:^|#{Regexp.escape(::File::SEPARATOR)})\.\.?$/
end)
- converge_by("Create managed files in directory") do
- files_to_transfer.each do |cookbook_file_relative_path|
- create_cookbook_file(cookbook_file_relative_path)
- # the file is removed from the purge list
- files_to_purge.delete(::File.join(@new_resource.path, cookbook_file_relative_path))
- # parent directories are also removed from the purge list
- directories=::File.dirname(::File.join(@new_resource.path, cookbook_file_relative_path)).split(::File::SEPARATOR)
- for i in 0..directories.length-1
- files_to_purge.delete(::File.join(directories[0..i]))
- end
- end
- end
- converge_by("Purge unmanaged files from directory") do
- purge_unmanaged_files(files_to_purge)
+ files_to_transfer.each do |cookbook_file_relative_path|
+ create_cookbook_file(cookbook_file_relative_path)
+ # the file is removed from the purge list
+ files_to_purge.delete(::File.join(@new_resource.path, cookbook_file_relative_path))
+ # parent directories are also removed from the purge list
+ directories=::File.dirname(::File.join(@new_resource.path, cookbook_file_relative_path)).split(::File::SEPARATOR)
+ for i in 0..directories.length-1
+ files_to_purge.delete(::File.join(directories[0..i]))
+ end
end
+ purge_unmanaged_files(files_to_purge)
end
def action_create_if_missing
diff --git a/chef/spec/unit/provider/deploy/revision_spec.rb b/chef/spec/unit/provider/deploy/revision_spec.rb
index 396dd09a8e..3287c085d5 100644
--- a/chef/spec/unit/provider/deploy/revision_spec.rb
+++ b/chef/spec/unit/provider/deploy/revision_spec.rb
@@ -55,11 +55,9 @@ describe Chef::Provider::Deploy::Revision do
FileUtils.stub!(:mkdir_p)
@provider.stub!(:run_command).and_return(true)
@provider.copy_cached_repo
- @provider.converge
@provider.stub!(:release_slug).and_return("73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2")
@provider.load_current_resource
@provider.copy_cached_repo
- @provider.converge
second_release = "/my/deploy/dir/releases/73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2"
@provider.all_releases.should == [@expected_release_dir,second_release]
@@ -69,20 +67,16 @@ describe Chef::Provider::Deploy::Revision do
FileUtils.stub!(:mkdir_p)
@provider.stub!(:run_command).and_return(true)
@provider.copy_cached_repo
- @provider.converge
@provider.stub!(:release_slug).and_return("73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2")
@provider.load_current_resource
@provider.copy_cached_repo
- @provider.converge
second_release = "/my/deploy/dir/releases/73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2"
@provider.all_releases.should == [@expected_release_dir,second_release]
@provider.copy_cached_repo
- @provider.converge
@provider.stub!(:release_slug).and_return("8a3195bf3efa246f743c5dfa83683201880f935c")
@provider.load_current_resource
@provider.copy_cached_repo
- @provider.converge
@provider.all_releases.should == [second_release, @expected_release_dir]
end
diff --git a/chef/spec/unit/provider/deploy_spec.rb b/chef/spec/unit/provider/deploy_spec.rb
index 6bcd64fbfb..ebbc6e2823 100644
--- a/chef/spec/unit/provider/deploy_spec.rb
+++ b/chef/spec/unit/provider/deploy_spec.rb
@@ -54,15 +54,11 @@ describe Chef::Provider::Deploy do
end
it "creates deploy_to dir" do
+ ::Dir.should_receive(:chdir).with(@expected_release_dir).exactly(4).times
@provider.stub(:update_cached_repo)
@provider.deploy
end
- it "creates deploy_to dir before calling update_cached_repo (CHEF-3435)" do
- @provider.send(:converge_actions).should_receive(:empty?).and_return(false)
- @provider.should_receive(:update_cached_repo).ordered
- @provider.deploy
- end
end
it "does not create deploy_to dir if it exists" do
@@ -75,10 +71,10 @@ describe Chef::Provider::Deploy do
@provider.stub(:symlink)
@provider.stub(:migrate)
@provider.deploy
- @provider.converge
end
it "ensures the deploy_to dir ownership after the verfication that it exists" do
+ ::Dir.should_receive(:chdir).with(@expected_release_dir).exactly(4).times
@provider.should_receive(:verify_directories_exist).ordered
@provider.should_receive(:enforce_ownership).ordered
@provider.stub(:copy_cached_repo)
@@ -106,7 +102,6 @@ describe Chef::Provider::Deploy do
@provider.should_receive(:callback).with(:after_restart, nil)
@provider.should_receive(:cleanup!)
@provider.deploy
- @provider.converge
end
it "should not deploy if there is already a deploy at release_path, and it is the current release" do
@@ -134,7 +129,6 @@ describe Chef::Provider::Deploy do
@resource.svn_force_export true
@provider.scm_provider.should_receive(:run_action).with(:force_export)
@provider.update_cached_repo
- @provider.converge
end
it "Removes the old release before deploying when force deploying over it" do
@@ -259,7 +253,6 @@ describe Chef::Provider::Deploy do
@runner.should_receive(:converge)
callback_code = Proc.new { :noop }
@provider.callback(:whatevs, callback_code)
- @provider.converge
end
it "loads callback files from the release/ dir if the file exists" do
@@ -268,7 +261,6 @@ describe Chef::Provider::Deploy do
::Dir.should_receive(:chdir).with(@expected_release_dir).and_yield
@provider.should_receive(:from_file).with(foo_callback)
@provider.callback(:foo, "deploy/foo.rb")
- @provider.converge
end
it "raises a runtime error if a callback file is explicitly specified but does not exist" do
@@ -286,7 +278,6 @@ describe Chef::Provider::Deploy do
::Dir.should_receive(:chdir).with(@expected_release_dir).and_yield
@provider.should_receive(:from_file).with(bar_callback)
@provider.callback(:bar, nil)
- @provider.converge
end
it "skips an eval callback if the file doesn't exist" do
@@ -295,7 +286,6 @@ describe Chef::Provider::Deploy do
::Dir.should_receive(:chdir).with(@expected_release_dir).and_yield
@provider.should_not_receive(:from_file)
@provider.callback(:barbaz, nil)
- @provider.converge
end
# CHEF-3449 #converge_by is called in #recipe_eval and must happen in sequence
@@ -326,14 +316,12 @@ describe Chef::Provider::Deploy do
it "syncs the cached copy of the repo" do
@provider.scm_provider.should_receive(:run_action).with(:sync)
@provider.update_cached_repo
- @provider.converge
end
it "makes a copy of the cached repo in releases dir" do
FileUtils.should_receive(:mkdir_p).with("/my/deploy/dir/releases")
@provider.should_receive(:run_command).with({:command => "cp -RPp /my/deploy/dir/shared/cached-copy/. #{@expected_release_dir}"})
@provider.copy_cached_repo
- @provider.converge
end
it "calls the internal callback :release_created when copying the cached repo" do
@@ -341,7 +329,6 @@ describe Chef::Provider::Deploy do
@provider.stub!(:run_command).and_return(true)
@provider.should_receive(:release_created)
@provider.copy_cached_repo
- @provider.converge
end
it "chowns the whole release dir to user and group specified in the resource" do
@@ -349,7 +336,6 @@ describe Chef::Provider::Deploy do
@resource.group "bar"
FileUtils.should_receive(:chown_R).with("foo", "bar", "/my/deploy/dir")
@provider.enforce_ownership
- @provider.converge
end
it "skips the migration when resource.migrate => false but runs symlinks before migration" do
@@ -357,7 +343,6 @@ describe Chef::Provider::Deploy do
@provider.should_not_receive :run_command
@provider.should_receive :run_symlinks_before_migrate
@provider.migrate
- @provider.converge
end
it "links the database.yml and runs resource.migration_command when resource.migrate #=> true" do
@@ -377,7 +362,6 @@ describe Chef::Provider::Deploy do
:log_tag => "deploy[/my/deploy/dir]",
:environment => {"RAILS_ENV"=>"production"})
@provider.migrate
- @provider.converge
end
it "purges the current release's /log /tmp/pids/ and /public/system directories" do
@@ -385,7 +369,6 @@ describe Chef::Provider::Deploy do
FileUtils.should_receive(:rm_rf).with(@expected_release_dir + "/tmp/pids")
FileUtils.should_receive(:rm_rf).with(@expected_release_dir + "/public/system")
@provider.purge_tempfiles_from_current_release
- @provider.converge
end
it "symlinks temporary files and logs from the shared dir into the current release" do
@@ -401,7 +384,6 @@ describe Chef::Provider::Deploy do
FileUtils.should_receive(:ln_sf).with("/my/deploy/dir/shared/config/database.yml", @expected_release_dir + "/config/database.yml")
@provider.should_receive(:enforce_ownership)
@provider.link_tempfiles_to_current_release
- @provider.converge
end
it "symlinks the current release dir into production" do
@@ -409,7 +391,6 @@ describe Chef::Provider::Deploy do
FileUtils.should_receive(:ln_sf).with(@expected_release_dir, "/my/deploy/dir/current")
@provider.should_receive(:enforce_ownership)
@provider.link_current_release_to_production
- @provider.converge
end
context "with a customized app layout" do
@@ -419,14 +400,12 @@ describe Chef::Provider::Deploy do
@resource.create_dirs_before_symlink(%w{baz qux})
@resource.symlinks "foo/bar" => "foo/bar", "baz" => "qux/baz"
@resource.symlink_before_migrate "radiohead/in_rainbows.yml" => "awesome"
- @provider.converge
end
it "purges the purge_before_symlink directories" do
FileUtils.should_receive(:rm_rf).with(@expected_release_dir + "/foo")
FileUtils.should_receive(:rm_rf).with(@expected_release_dir + "/bar")
@provider.purge_tempfiles_from_current_release
- @provider.converge
end
it "symlinks files from the shared directory to the current release directory" do
@@ -439,7 +418,6 @@ describe Chef::Provider::Deploy do
FileUtils.should_receive(:ln_sf).with("/my/deploy/dir/shared/radiohead/in_rainbows.yml", @expected_release_dir + "/awesome")
@provider.should_receive(:enforce_ownership)
@provider.link_tempfiles_to_current_release
- @provider.converge
end
end
@@ -447,14 +425,12 @@ describe Chef::Provider::Deploy do
it "does nothing for restart if restart_command is empty" do
@provider.should_not_receive(:run_command)
@provider.restart
- @provider.converge
end
it "runs the restart command in the current application dir when the resource has a restart_command" do
@resource.restart_command "restartcmd"
@provider.should_receive(:run_command).with(:command => "restartcmd", :cwd => "/my/deploy/dir/current", :log_tag => "deploy[/my/deploy/dir]", :log_level => :debug)
@provider.restart
- @provider.converge
end
it "lists all available releases" do
@@ -474,7 +450,6 @@ describe Chef::Provider::Deploy do
FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/20040200000000")
FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/20040300000000")
@provider.cleanup!
- @provider.converge
end
it "removes all but a certain number of releases when the resource has a keep_releases" do
@@ -486,7 +461,6 @@ describe Chef::Provider::Deploy do
@provider.stub!(:all_releases).and_return(all_releases)
FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/20040100000000")
@provider.cleanup!
- @provider.converge
end
it "fires a callback for :release_deleted when deleting an old release" do
@@ -497,7 +471,6 @@ describe Chef::Provider::Deploy do
FileUtils.stub!(:rm_rf)
@provider.should_receive(:release_deleted).with("/my/deploy/dir/20040300000000")
@provider.cleanup!
- @provider.converge
end
it "puts resource.to_hash in @configuration for backwards compat with capistano-esque deploy hooks" do
@@ -509,7 +482,6 @@ describe Chef::Provider::Deploy do
resource.environment "production"
provider = Chef::Provider::Deploy.new(resource, @run_context)
provider.instance_variable_get(:@configuration)[:environment].should eql("production")
- @provider.converge
end
it "shouldn't give a no method error on migrate if the environment is nil" do
@@ -517,7 +489,7 @@ describe Chef::Provider::Deploy do
@provider.stub!(:run_symlinks_before_migrate)
@provider.stub!(:run_command)
@provider.migrate
- @provider.converge
+
end
context "using inline recipes for callbacks" do
@@ -527,7 +499,6 @@ describe Chef::Provider::Deploy do
recipe_code = Proc.new {snitch = 42}
#@provider.should_receive(:instance_eval).with(&recipe_code)
@provider.callback(:whateverz, recipe_code)
- @provider.converge
snitch.should == 42
end
@@ -536,7 +507,6 @@ describe Chef::Provider::Deploy do
::Dir.should_receive(:chdir).with(@expected_release_dir).and_yield
@provider.should_receive(:from_file).with(@expected_release_dir + "/chefz/foobar_callback.rb")
@provider.callback(:whateverz, "chefz/foobar_callback.rb")
- @provider.converge
end
it "instance_evals a block/proc for restart command" do
@@ -544,7 +514,6 @@ describe Chef::Provider::Deploy do
restart_cmd = Proc.new {snitch = 42}
@resource.restart(&restart_cmd)
@provider.restart
- @provider.converge
snitch.should == 42
end
@@ -554,7 +523,6 @@ describe Chef::Provider::Deploy do
it "defines sudo as a forwarder to execute" do
@provider.should_receive(:execute).with("the moon, fool")
@provider.sudo("the moon, fool")
- @provider.converge
end
it "defines run as a forwarder to execute, setting the user, group, cwd and environment to new_resource.user" do
@@ -583,7 +551,7 @@ describe Chef::Provider::Deploy do
end
}.twice
@provider.run("iGoToHell4this")
- @provider.converge
+
end
it "defines run as a forwarder to execute, setting cwd and environment but not override" do
@@ -594,7 +562,6 @@ describe Chef::Provider::Deploy do
mock_execution.should_receive(:cwd).with(no_args()).and_return("/some/value")
mock_execution.should_receive(:environment).with(no_args()).and_return({})
@provider.run("iGoToHell4this")
- @provider.converge
end
@@ -615,7 +582,6 @@ describe Chef::Provider::Deploy do
runner.should_receive(:converge)
#
@provider.callback(:phony, callback_code)
- @provider.converge
snitch.should be_an_instance_of(Chef::Resource::Execute)
snitch.user.should == "tehCat"
end
diff --git a/chef/spec/unit/provider/erl_call_spec.rb b/chef/spec/unit/provider/erl_call_spec.rb
index df7910424b..fa85b6cda7 100644
--- a/chef/spec/unit/provider/erl_call_spec.rb
+++ b/chef/spec/unit/provider/erl_call_spec.rb
@@ -60,7 +60,6 @@ describe Chef::Provider::ErlCall do
Process.should_receive(:wait).with(@pid)
@provider.action_run
- @provider.converge
@stdin.string.should == "#{@new_resource.code}\n"
end
@@ -78,7 +77,6 @@ describe Chef::Provider::ErlCall do
Process.should_receive(:wait).with(@pid)
@provider.action_run
- @provider.converge
@stdin.string.should == "#{@new_resource.code}\n"
end
diff --git a/chef/spec/unit/provider/file_spec.rb b/chef/spec/unit/provider/file_spec.rb
index 28d2aac2b5..9f5ad3a8f8 100644
--- a/chef/spec/unit/provider/file_spec.rb
+++ b/chef/spec/unit/provider/file_spec.rb
@@ -176,7 +176,6 @@ describe Chef::Provider::File do
@provider.should_receive(:backup)
File.should_receive(:open).with(@provider.new_resource.path, "w").and_yield(io)
@provider.set_content
- lambda { @provider.send(:converge_actions).converge! }.should_not raise_error
io.string.should == "foobar"
end
diff --git a/chef/spec/unit/provider/git_spec.rb b/chef/spec/unit/provider/git_spec.rb
index bb8208dc27..275b2907ec 100644
--- a/chef/spec/unit/provider/git_spec.rb
+++ b/chef/spec/unit/provider/git_spec.rb
@@ -163,7 +163,6 @@ SHAS
:environment =>{"GIT_SSH"=>"do_it_this_way.sh"}, :log_level => :info, :log_tag => "git[web2.0 app]", :live_stream => STDOUT)
@provider.clone
- @provider.converge
end
it "runs a clone command with escaped destination" do
@@ -174,7 +173,6 @@ SHAS
@provider.should_receive(:shell_out!).with(expected_cmd, :user => "deployNinja",
:environment =>{"GIT_SSH"=>"do_it_this_way.sh"}, :log_level => :info, :log_tag => "git[web2.0 app]", :live_stream => STDOUT)
@provider.clone
- @provider.converge
end
it "compiles a clone command using --depth for shallow cloning" do
@@ -182,7 +180,6 @@ SHAS
expected_cmd = 'git clone --depth 5 git://github.com/opscode/chef.git /my/deploy/dir'
@provider.should_receive(:shell_out!).with(expected_cmd, {:log_level => :info, :log_tag => "git[web2.0 app]", :live_stream => STDOUT})
@provider.clone
- @provider.converge
end
it "compiles a clone command with a remote other than ``origin''" do
@@ -190,14 +187,12 @@ SHAS
expected_cmd = 'git clone -o opscode git://github.com/opscode/chef.git /my/deploy/dir'
@provider.should_receive(:shell_out!).with(expected_cmd, {:log_level => :info, :log_tag => "git[web2.0 app]", :live_stream => STDOUT})
@provider.clone
- @provider.converge
end
it "runs a checkout command with default options" do
expected_cmd = 'git checkout -b deploy d35af14d41ae22b19da05d7d03a0bafc321b244c'
@provider.should_receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", :log_level => :debug, :log_tag => "git[web2.0 app]")
@provider.checkout
- @provider.converge
end
it "runs an enable_submodule command" do
@@ -205,20 +200,17 @@ SHAS
expected_cmd = "git submodule update --init --recursive"
@provider.should_receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", :log_level => :info, :log_tag => "git[web2.0 app]", :live_stream => STDOUT)
@provider.enable_submodules
- @provider.converge
end
it "does nothing for enable_submodules if resource.enable_submodules #=> false" do
@provider.should_not_receive(:shell_out!)
@provider.enable_submodules
- @provider.converge
end
it "runs a sync command with default options" do
expected_cmd = "git fetch origin && git fetch origin --tags && git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c"
@provider.should_receive(:shell_out!).with(expected_cmd, :cwd=> "/my/deploy/dir", :log_level => :debug, :log_tag => "git[web2.0 app]")
@provider.fetch_updates
- @provider.converge
end
it "runs a sync command with the user and group specified in the resource" do
@@ -228,7 +220,6 @@ SHAS
@provider.should_receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir",
:user => "whois", :group => "thisis", :log_level => :debug, :log_tag => "git[web2.0 app]")
@provider.fetch_updates
- @provider.converge
end
it "configures remote tracking branches when remote is not ``origin''" do
@@ -239,7 +230,6 @@ SHAS
fetch_command = "git fetch opscode && git fetch opscode --tags && git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c"
@provider.should_receive(:shell_out!).with(fetch_command, :cwd => "/my/deploy/dir", :log_level => :debug, :log_tag => "git[web2.0 app]")
@provider.fetch_updates
- @provider.converge
end
it "raises an error if the git clone command would fail because the enclosing directory doesn't exist" do
diff --git a/chef/spec/unit/provider/group/groupadd_spec.rb b/chef/spec/unit/provider/group/groupadd_spec.rb
index f08e14f99b..5e07da59b4 100644
--- a/chef/spec/unit/provider/group/groupadd_spec.rb
+++ b/chef/spec/unit/provider/group/groupadd_spec.rb
@@ -132,7 +132,7 @@ describe Chef::Provider::Group::Groupadd do
describe "modify_group_members" do
it "should raise an error when calling modify_group_members" do
- lambda { @provider.modify_group_members ; @provider.converge }.should raise_error(Chef::Exceptions::Group, "you must override modify_group_members in #{@provider.to_s}")
+ lambda { @provider.modify_group_members }.should raise_error(Chef::Exceptions::Group, "you must override modify_group_members in #{@provider.to_s}")
end
end
diff --git a/chef/spec/unit/provider/package/rubygems_spec.rb b/chef/spec/unit/provider/package/rubygems_spec.rb
index be4c3a99c4..b3b7a030db 100644
--- a/chef/spec/unit/provider/package/rubygems_spec.rb
+++ b/chef/spec/unit/provider/package/rubygems_spec.rb
@@ -439,7 +439,6 @@ describe Chef::Provider::Package::Rubygems do
it "installs the gem via the gems api when no explicit options are used" do
@provider.gem_env.should_receive(:install).with(@gem_dep, :sources => nil)
@provider.action_install.should be_true
- @provider.converge
end
it "installs the gem via the gems api when a remote source is provided" do
@@ -447,14 +446,12 @@ describe Chef::Provider::Package::Rubygems do
sources = ['http://gems.example.org']
@provider.gem_env.should_receive(:install).with(@gem_dep, :sources => sources)
@provider.action_install.should be_true
- @provider.converge
end
it "installs the gem from file via the gems api when no explicit options are used" do
@new_resource.source(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem')
@provider.gem_env.should_receive(:install).with(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem')
@provider.action_install.should be_true
- @provider.converge
end
it "installs the gem from file via the gems api when the package is a path and the source is nil" do
@@ -464,7 +461,6 @@ describe Chef::Provider::Package::Rubygems do
@new_resource.source.should == CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem'
@provider.gem_env.should_receive(:install).with(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem')
@provider.action_install.should be_true
- @provider.converge
end
# this catches 'gem_package "foo"' when "./foo" is a file in the cwd, and instead of installing './foo' it fetches the remote gem
@@ -473,7 +469,6 @@ describe Chef::Provider::Package::Rubygems do
@new_resource.package_name('rspec-core')
@provider.gem_env.should_receive(:install).with(@gem_dep, :sources => nil)
@provider.action_install.should be_true
- @provider.converge
end
it "installs the gem by shelling out when options are provided as a String" do
@@ -481,14 +476,12 @@ describe Chef::Provider::Package::Rubygems do
expected ="gem install rspec-core -q --no-rdoc --no-ri -v \"#{@spec_version}\" -i /alt/install/location"
@provider.should_receive(:shell_out!).with(expected, :env => nil)
@provider.action_install.should be_true
- @provider.converge
end
it "installs the gem via the gems api when options are given as a Hash" do
@new_resource.options(:install_dir => '/alt/install/location')
@provider.gem_env.should_receive(:install).with(@gem_dep, :sources => nil, :install_dir => '/alt/install/location')
@provider.action_install.should be_true
- @provider.converge
end
describe "at a specific version" do
@@ -499,7 +492,6 @@ describe Chef::Provider::Package::Rubygems do
it "installs the gem via the gems api" do
@provider.gem_env.should_receive(:install).with(@gem_dep, :sources => nil)
@provider.action_install.should be_true
- @provider.converge
end
end
describe "at version specified with comparison operator" do
@@ -509,7 +501,6 @@ describe Chef::Provider::Package::Rubygems do
@provider.gem_env.should_not_receive(:install)
@provider.action_install
- @provider.converge
end
it "allows user to specify gem version with fuzzy operator" do
@@ -518,7 +509,6 @@ describe Chef::Provider::Package::Rubygems do
@provider.gem_env.should_not_receive(:install)
@provider.action_install
- @provider.converge
end
end
end
@@ -528,7 +518,6 @@ describe Chef::Provider::Package::Rubygems do
@new_resource.gem_binary('/usr/weird/bin/gem')
@provider.should_receive(:shell_out!).with("/usr/weird/bin/gem install rspec-core -q --no-rdoc --no-ri -v \"#{@spec_version}\"", :env=>nil)
@provider.action_install.should be_true
- @provider.converge
end
it "installs the gem from file by shelling out to gem install" do
@@ -537,7 +526,6 @@ describe Chef::Provider::Package::Rubygems do
@new_resource.version('>= 0')
@provider.should_receive(:shell_out!).with("/usr/weird/bin/gem install #{CHEF_SPEC_DATA}/gems/chef-integration-test-0.1.0.gem -q --no-rdoc --no-ri -v \">= 0\"", :env=>nil)
@provider.action_install.should be_true
- @provider.converge
end
it "installs the gem from file by shelling out to gem install when the package is a path and the source is nil" do
@@ -549,7 +537,6 @@ describe Chef::Provider::Package::Rubygems do
@new_resource.source.should == CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem'
@provider.should_receive(:shell_out!).with("/usr/weird/bin/gem install #{CHEF_SPEC_DATA}/gems/chef-integration-test-0.1.0.gem -q --no-rdoc --no-ri -v \">= 0\"", :env=>nil)
@provider.action_install.should be_true
- @provider.converge
end
end
@@ -572,7 +559,6 @@ describe Chef::Provider::Package::Rubygems do
# the behavior we're testing:
@provider.gem_env.should_receive(:uninstall).with('rspec', nil)
@provider.action_remove
- @provider.converge
end
it "uninstalls via the api when options are given as a Hash" do
@@ -583,21 +569,18 @@ describe Chef::Provider::Package::Rubygems do
@new_resource.options(:install_dir => '/alt/install/location')
@provider.gem_env.should_receive(:uninstall).with('rspec', nil, :install_dir => '/alt/install/location')
@provider.action_remove
- @provider.converge
end
it "uninstalls via the gem command when options are given as a String" do
@new_resource.options('-i /alt/install/location')
@provider.should_receive(:shell_out!).with("gem uninstall rspec -q -x -I -a -i /alt/install/location", :env=>nil)
@provider.action_remove
- @provider.converge
end
it "uninstalls a specific version of a gem when a version is provided" do
@new_resource.version('1.2.3')
@provider.gem_env.should_receive(:uninstall).with('rspec', '1.2.3')
@provider.action_remove
- @provider.converge
end
end
@@ -606,7 +589,6 @@ describe Chef::Provider::Package::Rubygems do
@new_resource.gem_binary('/usr/weird/bin/gem')
@provider.should_receive(:shell_out!).with("/usr/weird/bin/gem uninstall rspec -q -x -I -a", :env=>nil)
@provider.action_remove
- @provider.converge
end
end
end
diff --git a/chef/spec/unit/provider/package/yum_spec.rb b/chef/spec/unit/provider/package/yum_spec.rb
index 0002ec39f3..4b890b1549 100644
--- a/chef/spec/unit/provider/package/yum_spec.rb
+++ b/chef/spec/unit/provider/package/yum_spec.rb
@@ -504,7 +504,6 @@ describe Chef::Provider::Package::Yum do
"11"
)
@provider.action_upgrade
- @provider.converge
end
it "should call action_upgrade in the parent if the candidate version is nil" do
@@ -513,7 +512,6 @@ describe Chef::Provider::Package::Yum do
@provider.candidate_version = nil
@provider.should_not_receive(:upgrade_package)
@provider.action_upgrade
- @provider.converge
end
it "should call action_upgrade in the parent if the candidate is newer" do
@@ -525,7 +523,6 @@ describe Chef::Provider::Package::Yum do
"11"
)
@provider.action_upgrade
- @provider.converge
end
it "should not call action_upgrade in the parent if the candidate is older" do
@@ -535,7 +532,6 @@ describe Chef::Provider::Package::Yum do
@provider.candidate_version = '11'
@provider.should_not_receive(:upgrade_package)
@provider.action_upgrade
- @provider.converge
end
end
diff --git a/chef/spec/unit/provider/remote_directory_spec.rb b/chef/spec/unit/provider/remote_directory_spec.rb
index 3a7838edc5..444d7584e8 100644
--- a/chef/spec/unit/provider/remote_directory_spec.rb
+++ b/chef/spec/unit/provider/remote_directory_spec.rb
@@ -42,7 +42,6 @@ describe Chef::Provider::RemoteDirectory do
@node = Chef::Node.new
@cookbook_collection = Chef::CookbookCollection.new(Chef::CookbookLoader.new(@cookbook_repo))
-
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
@@ -50,6 +49,21 @@ describe Chef::Provider::RemoteDirectory do
@provider.current_resource = @resource.clone
end
+ describe "when the contents of the directory changed on the first run and not on the second run" do
+ before do
+ @resource_second_run = @resource.clone
+ @provider_second_run = Chef::Provider::RemoteDirectory.new(@resource_second_run, @run_context)
+ @provider.run_action(:create)
+ @provider_second_run.run_action(:create)
+ end
+ it "identifies that the state has changed the after first run" do
+ @provider_second_run.new_resource.updated_by_last_action? == true
+ end
+ it "identifies that the state has not changed after the second run" do
+ @provider_second_run.new_resource.updated_by_last_action? == false
+ end
+ end
+
describe "when access control is configured on the resource" do
before do
@resource.mode "0750"
@@ -91,7 +105,6 @@ describe Chef::Provider::RemoteDirectory do
before do
@node[:platform] = :just_testing
@node[:platform_version] = :just_testing
-
@destination_dir = Dir.mktmpdir << "/remote_directory_test"
@resource.path(@destination_dir)
end
diff --git a/chef/spec/unit/provider/route_spec.rb b/chef/spec/unit/provider/route_spec.rb
index 61c7b8e508..8b98f29add 100644
--- a/chef/spec/unit/provider/route_spec.rb
+++ b/chef/spec/unit/provider/route_spec.rb
@@ -204,15 +204,12 @@ describe Chef::Provider::Route do
File.should_receive(:new).with("/etc/sysconfig/network-scripts/route-eth0", "w").and_return(route_file)
#Chef::Log.should_receive(:debug).with("route[10.0.0.10] writing route.eth0\n10.0.0.10 via 10.0.0.9\n")
@run_context.resource_collection << @new_resource
-
@provider.generate_config
- @provider.converge
end
end
it "should put all routes for a device in a route config file" do
@node[:platform] = 'centos'
-
route_file = StringIO.new
File.should_receive(:new).and_return(route_file)
@run_context.resource_collection << Chef::Resource::Route.new('192.168.1.0/24 via 192.168.0.1')
@@ -220,7 +217,6 @@ describe Chef::Provider::Route do
@run_context.resource_collection << Chef::Resource::Route.new('192.168.3.0/24 via 192.168.0.1')
@provider.generate_config
- @provider.converge
route_file.string.split("\n").should have(3).items
route_file.string.should match(/^192.168.1.0\/24 via 192.168.0.1$/)
route_file.string.should match(/^192.168.2.0\/24 via 192.168.0.1$/)
diff --git a/chef/spec/unit/provider/service_spec.rb b/chef/spec/unit/provider/service_spec.rb
index d25d7cf735..6b2b758f21 100644
--- a/chef/spec/unit/provider/service_spec.rb
+++ b/chef/spec/unit/provider/service_spec.rb
@@ -36,7 +36,7 @@ describe Chef::Provider::Service do
@current_resource.enabled(false)
@provider.should_receive(:enable_service).and_return(true)
@provider.action_enable
- @provider.converge
+ @provider.set_updated_status
@provider.new_resource.should be_updated
end
@@ -44,7 +44,7 @@ describe Chef::Provider::Service do
@current_resource.enabled(true)
@provider.should_not_receive(:enable_service)
@provider.action_enable
- @provider.converge
+ @provider.set_updated_status
@provider.new_resource.should_not be_updated
end
end
diff --git a/chef/spec/unit/provider/user_spec.rb b/chef/spec/unit/provider/user_spec.rb
index 4066ffd7fe..9c4e2847f7 100644
--- a/chef/spec/unit/provider/user_spec.rb
+++ b/chef/spec/unit/provider/user_spec.rb
@@ -250,7 +250,7 @@ describe Chef::Provider::User do
@provider.user_exists = false
@provider.should_receive(:create_user).and_return(true)
@provider.action_create
- @provider.converge
+ @provider.set_updated_status
@new_resource.should be_updated
end
@@ -259,7 +259,6 @@ describe Chef::Provider::User do
@provider.stub!(:compare_user).and_return(true)
@provider.should_receive(:manage_user).and_return(true)
@provider.action_create
- @provider.converge
end
it "should set the the new_resources updated flag when it creates the user if we call manage_user" do
@@ -267,7 +266,7 @@ describe Chef::Provider::User do
@provider.stub!(:compare_user).and_return(true)
@provider.stub!(:manage_user).and_return(true)
@provider.action_create
- @provider.converge
+ @provider.set_updated_status
@new_resource.should be_updated
end
end
@@ -281,21 +280,19 @@ describe Chef::Provider::User do
@provider.user_exists = false
@provider.should_not_receive(:remove_user)
@provider.action_remove
- @provider.converge
end
it "should call remove_user if the user exists" do
@provider.user_exists = true
@provider.should_receive(:remove_user)
@provider.action_remove
- @provider.converge
end
it "should set the new_resources updated flag to true if the user is removed" do
@provider.user_exists = true
@provider.should_receive(:remove_user)
@provider.action_remove
- @provider.converge
+ @provider.set_updated_status
@new_resource.should be_updated
end
end
@@ -320,14 +317,13 @@ describe Chef::Provider::User do
@provider.should_receive(:compare_user).and_return(true)
@provider.should_receive(:manage_user).and_return(true)
@provider.action_manage
- @provider.converge
end
it "should set the new resources updated flag to true if manage_user is called" do
@provider.stub!(:compare_user).and_return(true)
@provider.stub!(:manage_user).and_return(true)
@provider.action_manage
- @provider.converge
+ @provider.set_updated_status
@new_resource.should be_updated
end
@@ -335,14 +331,12 @@ describe Chef::Provider::User do
@provider.user_exists = false
@provider.should_not_receive(:manage_user)
@provider.action_manage
- @provider.converge
end
it "should not run manage_user if the user exists but has no differing attributes" do
@provider.should_receive(:compare_user).and_return(false)
@provider.should_not_receive(:manage_user)
@provider.action_manage
- @provider.converge
end
end
@@ -366,14 +360,13 @@ describe Chef::Provider::User do
@provider.should_receive(:compare_user).and_return(true)
@provider.should_receive(:manage_user).and_return(true)
@provider.action_modify
- @provider.converge
end
it "should set the new resources updated flag to true if manage_user is called" do
@provider.stub!(:compare_user).and_return(true)
@provider.stub!(:manage_user).and_return(true)
@provider.action_modify
- @provider.converge
+ @provider.set_updated_status
@new_resource.should be_updated
end
@@ -381,7 +374,6 @@ describe Chef::Provider::User do
@provider.should_receive(:compare_user).and_return(false)
@provider.should_not_receive(:manage_user)
@provider.action_modify
- @provider.converge
end
it "should raise a Chef::Exceptions::User if the user doesn't exist" do
@@ -399,14 +391,13 @@ describe Chef::Provider::User do
@provider.stub!(:check_lock).and_return(false)
@provider.should_receive(:lock_user).and_return(true)
@provider.action_lock
- @provider.converge
end
it "should set the new resources updated flag to true if lock_user is called" do
@provider.stub!(:check_lock).and_return(false)
@provider.should_receive(:lock_user)
@provider.action_lock
- @provider.converge
+ @provider.set_updated_status
@new_resource.should be_updated
end
@@ -439,7 +430,7 @@ describe Chef::Provider::User do
@provider.stub!(:check_lock).and_return(true)
@provider.should_receive(:unlock_user).and_return(true)
@provider.action_unlock
- @provider.converge
+ @provider.set_updated_status
@new_resource.should be_updated
end
diff --git a/chef/spec/unit/provider_spec.rb b/chef/spec/unit/provider_spec.rb
index b0edf492ab..ec0af03d47 100644
--- a/chef/spec/unit/provider_spec.rb
+++ b/chef/spec/unit/provider_spec.rb
@@ -82,7 +82,6 @@ describe Chef::Provider do
temporary_collection = nil
snitch = Proc.new {temporary_collection = @run_context.resource_collection}
@provider.send(:recipe_eval, &snitch)
- @provider.converge
temporary_collection.should be_an_instance_of(Chef::ResourceCollection)
@provider.run_context.instance_variable_get(:@resource_collection).should == "doesn't matter what this is"
end
@@ -93,7 +92,6 @@ describe Chef::Provider do
Chef::RunContext.stub!(:new).and_raise("not supposed to happen")
snitch = Proc.new {temporary_collection = @run_context.resource_collection}
@provider.send(:recipe_eval, &snitch)
- @provider.converge
end
context "when no converge actions are queued" do
@@ -103,7 +101,6 @@ describe Chef::Provider do
end
it "does not mark the new resource as updated" do
- @provider.converge
@resource.should_not be_updated
@resource.should_not be_updated_by_last_action
end