summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2010-06-24 23:17:57 -0700
committerDaniel DeLeo <dan@opscode.com>2010-06-24 23:17:57 -0700
commit3280bd81445c700093e73487438bb7e6b88ab0ab (patch)
tree2ff353440e756852e5b4fd053b28a72602086ba8
parenta67d264c0c35756532e58722b98bfce2451ff57f (diff)
downloadchef-3280bd81445c700093e73487438bb7e6b88ab0ab.tar.gz
[CHEF-1384] dup constants before changing them
also fix some missing explicit requires
-rw-r--r--chef/lib/chef/client.rb2
-rw-r--r--chef/lib/chef/knife/cookbook_upload.rb2
-rw-r--r--chef/lib/chef/rest.rb1
-rw-r--r--features/data/cookbooks/template/recipes/interval.rb31
-rw-r--r--features/provider/template/template.feature24
-rw-r--r--features/steps/run_client_steps.rb10
6 files changed, 60 insertions, 10 deletions
diff --git a/chef/lib/chef/client.rb b/chef/lib/chef/client.rb
index cd37e49a6a..b8403c1767 100644
--- a/chef/lib/chef/client.rb
+++ b/chef/lib/chef/client.rb
@@ -249,7 +249,7 @@ class Chef
Chef::Log.debug("Synchronizing cookbook #{cookbook.name}")
# files and templates are lazily loaded, and will be done later.
- eager_segments = Array(Chef::CookbookVersion::COOKBOOK_SEGMENTS)
+ eager_segments = Chef::CookbookVersion::COOKBOOK_SEGMENTS.dup
eager_segments.delete(:files)
eager_segments.delete(:templates)
diff --git a/chef/lib/chef/knife/cookbook_upload.rb b/chef/lib/chef/knife/cookbook_upload.rb
index 307e54a35f..38da7483d4 100644
--- a/chef/lib/chef/knife/cookbook_upload.rb
+++ b/chef/lib/chef/knife/cookbook_upload.rb
@@ -20,7 +20,7 @@
require 'rest_client'
require 'chef/knife'
-require 'chef/streaming_cookbook_uploader'
+require 'chef/cookbook_loader'
require 'chef/cache/checksum'
require 'chef/sandbox'
require 'chef/cookbook_version'
diff --git a/chef/lib/chef/rest.rb b/chef/lib/chef/rest.rb
index d4813d12cf..8d6c10fe3d 100644
--- a/chef/lib/chef/rest.rb
+++ b/chef/lib/chef/rest.rb
@@ -24,6 +24,7 @@ require 'net/https'
require 'uri'
require 'json'
require 'tempfile'
+require 'chef/version'
require 'chef/api_client'
require 'chef/rest/auth_credentials'
require 'chef/rest/rest_request'
diff --git a/features/data/cookbooks/template/recipes/interval.rb b/features/data/cookbooks/template/recipes/interval.rb
new file mode 100644
index 0000000000..82608c49e2
--- /dev/null
+++ b/features/data/cookbooks/template/recipes/interval.rb
@@ -0,0 +1,31 @@
+#
+# Cookbook Name:: template
+# Recipe:: default
+#
+# Copyright 2009, Opscode
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+$run_count ||= %w{one two}
+exit!(108) if $run_count.empty?
+
+vars = {:value => $run_count.shift}
+
+Chef::Log.error(:vars => vars.inspect, :RUN_COUNT => $run_count.inspect)
+
+template "#{node[:tmpdir]}/template.txt" do
+ source "template.txt.erb"
+ variables(vars)
+end
+
diff --git a/features/provider/template/template.feature b/features/provider/template/template.feature
index cb59396f01..684f1cc499 100644
--- a/features/provider/template/template.feature
+++ b/features/provider/template/template.feature
@@ -12,12 +12,20 @@ Feature: Templates
And a file named 'template.txt' should contain 'sauce'
Scenario: Render a template accessing the node directly
- Given a validated node
- And it includes the recipe 'template::render_node_attrs'
- When I run the chef-client
- Then the run should exit '0'
- And a file named 'node.txt' should contain 'bawt is fujins bot'
- And a file named 'node.txt' should contain 'cheers!'
-
-
+ Given a validated node
+ And it includes the recipe 'template::render_node_attrs'
+ When I run the chef-client
+ Then the run should exit '0'
+ And a file named 'node.txt' should contain 'bawt is fujins bot'
+ And a file named 'node.txt' should contain 'cheers!'
+# Read the JIRA ticket for the full story, but what we're testing is that the
+# template resource executes correctly the second time it's run in the same
+# chef process
+ @regression @chef_1384
+ Scenario: Render a template twice running as a daemon
+ Given a validated node
+ And it includes the recipe 'template::interval'
+ When I run the chef-client for no more than '30' seconds
+ Then the run should exit '108'
+ And a file named 'template.txt' should contain 'two'
diff --git a/features/steps/run_client_steps.rb b/features/steps/run_client_steps.rb
index 0f74a79d51..ac751f27d7 100644
--- a/features/steps/run_client_steps.rb
+++ b/features/steps/run_client_steps.rb
@@ -16,6 +16,11 @@
# limitations under the License.
#
+require 'chef/shell_out'
+require 'chef/mixin/shell_out'
+
+include Chef::Mixin::ShellOut
+
CHEF_CLIENT = File.join(CHEF_PROJECT_ROOT, "chef", "bin", "chef-client")
###
@@ -33,6 +38,11 @@ When /^I run the chef\-client$/ do
@status = status
end
+When "I run the chef-client for no more than '$timeout' seconds" do |timeout|
+ cmd = shell_out("#{CHEF_CLIENT} -l info -i 1 -s 1 -c #{File.expand_path(File.join(configdir, 'client.rb'))}", :timeout => timeout.to_i)
+ @status = cmd.status
+end
+
When /^I run the chef\-client again$/ do
When "I run the chef-client"
end