summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Rakefile4
-rw-r--r--chef-server-api/app/controllers/nodes.rb3
-rw-r--r--cucumber.yml2
-rw-r--r--features/chef-client/attribute_settings.feature102
-rw-r--r--features/data/cookbooks/attribute_settings/README.rdoc8
-rw-r--r--features/data/cookbooks/attribute_settings/attributes/default.rb2
-rw-r--r--features/data/cookbooks/attribute_settings/default.rb1
-rw-r--r--features/data/cookbooks/attribute_settings/metadata.rb6
-rw-r--r--features/data/cookbooks/attribute_settings/recipes/default.rb21
-rw-r--r--features/data/cookbooks/attribute_settings/recipes/default_in_recipe.rb25
-rw-r--r--features/data/cookbooks/attribute_settings_normal/README.rdoc8
-rw-r--r--features/data/cookbooks/attribute_settings_normal/attributes/.default.rb.swobin0 -> 12288 bytes
-rw-r--r--features/data/cookbooks/attribute_settings_normal/attributes/default.rb2
-rw-r--r--features/data/cookbooks/attribute_settings_normal/default.rb1
-rw-r--r--features/data/cookbooks/attribute_settings_normal/metadata.rb6
-rw-r--r--features/data/cookbooks/attribute_settings_normal/recipes/.default.rb.swobin0 -> 12288 bytes
-rw-r--r--features/data/cookbooks/attribute_settings_normal/recipes/.default_in_recipe.rb.swobin0 -> 12288 bytes
-rw-r--r--features/data/cookbooks/attribute_settings_normal/recipes/default.rb21
-rw-r--r--features/data/cookbooks/attribute_settings_normal/recipes/normal_in_recipe.rb25
-rw-r--r--features/data/cookbooks/attribute_settings_override/README.rdoc8
-rw-r--r--features/data/cookbooks/attribute_settings_override/attributes/default.rb2
-rw-r--r--features/data/cookbooks/attribute_settings_override/default.rb1
-rw-r--r--features/data/cookbooks/attribute_settings_override/metadata.rb6
-rw-r--r--features/data/cookbooks/attribute_settings_override/recipes/default.rb21
-rw-r--r--features/data/cookbooks/attribute_settings_override/recipes/normal_in_recipe.rb25
-rw-r--r--features/steps/fixture_steps.rb16
-rw-r--r--features/steps/node_steps.rb3
27 files changed, 316 insertions, 3 deletions
diff --git a/Rakefile b/Rakefile
index c8a31dc9ce..f2c1a665fa 100644
--- a/Rakefile
+++ b/Rakefile
@@ -386,6 +386,10 @@ namespace :features do
Cucumber::Rake::Task.new(:cookbook_sync) do |t|
t.profile = "client_cookbook_sync"
end
+
+ Cucumber::Rake::Task.new(:attribute_settings) do |t|
+ t.profile = "attribute_settings"
+ end
end
desc "Run cucumber tests for the cookbooks"
diff --git a/chef-server-api/app/controllers/nodes.rb b/chef-server-api/app/controllers/nodes.rb
index 4243d3e2e8..e112f04f8c 100644
--- a/chef-server-api/app/controllers/nodes.rb
+++ b/chef-server-api/app/controllers/nodes.rb
@@ -40,9 +40,6 @@ class ChefServerApi::Nodes < ChefServerApi::Application
raise NotFound, "Cannot load node #{params[:id]}"
end
@node.couchdb_rev = nil
- recipes, default, override = @node.run_list.expand("couchdb")
- @node.default_attrs = default
- @node.override_attrs = override
display @node
end
diff --git a/cucumber.yml b/cucumber.yml
index fc16f6e193..64751600df 100644
--- a/cucumber.yml
+++ b/cucumber.yml
@@ -52,3 +52,5 @@ provider_template: --tags @template --format pretty -r features/steps -r feature
provider_package_macports: --tags @macports --format pretty -r features/steps -r features/support features
provider_package_rubygems: --tags @rubygems --format pretty -r features/steps -r features/support features
lwrp: --tags @lwrp --format pretty -r features/steps -r features/support features
+attribute_settings: --tags @attribute_settings --format pretty -r features/steps -r features/support features
+
diff --git a/features/chef-client/attribute_settings.feature b/features/chef-client/attribute_settings.feature
new file mode 100644
index 0000000000..6e32655c3b
--- /dev/null
+++ b/features/chef-client/attribute_settings.feature
@@ -0,0 +1,102 @@
+@client @attribute_settings
+
+Feature: Set default, normal, and override attributes
+ In order to easily configure similar systems
+ As an Administrator
+ I want to use different kinds of attributes
+
+ Scenario: Set a default attribute in a cookbook attribute file
+ Given a validated node
+ And it includes the recipe 'attribute_settings'
+ When I run the chef-client
+ Then the run should exit '0'
+ Then a file named 'attribute_setting.txt' should contain '1'
+ When the node is retrieved from the API
+ Then the inflated responses key 'attribute_priority_was' should be the integer '1'
+
+ Scenario: Set the default attribute in a role
+ Given a 'role' named 'attribute_settings_default' exists
+ And a validated node
+ And it includes the role 'attribute_settings_default'
+ When I run the chef-client
+ Then the run should exit '0'
+ And a file named 'attribute_setting.txt' should contain '2'
+ When the node is retrieved from the API
+ Then the inflated responses key 'attribute_priority_was' should be the integer '2'
+
+ Scenario: Set the default attribute in a recipe
+ Given a 'role' named 'attribute_settings_default' exists
+ And a validated node
+ And it includes the role 'attribute_settings_default'
+ And it includes the recipe 'attribute_settings::default_in_recipe'
+ When I run the chef-client
+ Then the run should exit '0'
+ And a file named 'attribute_setting.txt' should contain '3'
+ When the node is retrieved from the API
+ Then the inflated responses key 'attribute_priority_was' should be the integer '3'
+
+ Scenario: Set a normal attribute in a cookbook attribute file
+ Given a validated node
+ And it includes the role 'attribute_settings_default'
+ And it includes the recipe 'attribute_settings::default_in_recipe'
+ And it includes the recipe 'attribute_settings_normal'
+ When I run the chef-client
+ Then the run should exit '0'
+ Then a file named 'attribute_setting.txt' should contain '4'
+ When the node is retrieved from the API
+ Then the inflated responses key 'attribute_priority_was' should be the integer '4'
+
+ Scenario: Set a normal attribute in a cookbook recipe
+ Given a validated node
+ And it includes the role 'attribute_settings_default'
+ And it includes the recipe 'attribute_settings::default_in_recipe'
+ And it includes the recipe 'attribute_settings_normal::normal_in_recipe'
+ When I run the chef-client
+ Then the run should exit '0'
+ Then a file named 'attribute_setting.txt' should contain '5'
+ When the node is retrieved from the API
+ Then the inflated responses key 'attribute_priority_was' should be the integer '5'
+
+ Scenario: Set a override attribute in a cookbook attribute file
+ Given a validated node
+ And it includes the role 'attribute_settings_default'
+ And it includes the recipe 'attribute_settings::default_in_recipe'
+ And it includes the recipe 'attribute_settings_normal::normal_in_recipe'
+ And it includes the recipe 'attribute_settings_override'
+ When I run the chef-client
+ Then the run should exit '0'
+ Then a file named 'attribute_setting.txt' should contain '6'
+ When the node is retrieved from the API
+ Then the inflated responses key 'attribute_priority_was' should be the integer '6'
+
+ Scenario: Set the override attribute in a role
+ Given a 'role' named 'attribute_settings_default' exists
+ And a 'role' named 'attribute_settings_override' exists
+ And a validated node
+ And it includes the role 'attribute_settings_default'
+ And it includes the recipe 'attribute_settings::default_in_recipe'
+ And it includes the recipe 'attribute_settings_normal::normal_in_recipe'
+ And it includes the recipe 'attribute_settings_override'
+ And it includes the role 'attribute_settings_override'
+ When I run the chef-client
+ Then the run should exit '0'
+ And a file named 'attribute_setting.txt' should contain '7'
+ When the node is retrieved from the API
+ Then the inflated responses key 'attribute_priority_was' should be the integer '7'
+
+ Scenario: Set the override attribute in a recipe
+ Given a 'role' named 'attribute_settings_default' exists
+ And a 'role' named 'attribute_settings_override' exists
+ And a validated node
+ And it includes the role 'attribute_settings_default'
+ And it includes the recipe 'attribute_settings::default_in_recipe'
+ And it includes the recipe 'attribute_settings_normal::normal_in_recipe'
+ And it includes the recipe 'attribute_settings_override'
+ And it includes the role 'attribute_settings_override'
+ And it includes the recipe 'attribute_settings_override::override_in_recipe'
+ When I run the chef-client
+ Then the run should exit '0'
+ And a file named 'attribute_setting.txt' should contain '8'
+ When the node is retrieved from the API
+ Then the inflated responses key 'attribute_priority_was' should be the integer '8'
+
diff --git a/features/data/cookbooks/attribute_settings/README.rdoc b/features/data/cookbooks/attribute_settings/README.rdoc
new file mode 100644
index 0000000000..8d774805b9
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings/README.rdoc
@@ -0,0 +1,8 @@
+= DESCRIPTION:
+
+= REQUIREMENTS:
+
+= ATTRIBUTES:
+
+= USAGE:
+
diff --git a/features/data/cookbooks/attribute_settings/attributes/default.rb b/features/data/cookbooks/attribute_settings/attributes/default.rb
new file mode 100644
index 0000000000..22b40329cf
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings/attributes/default.rb
@@ -0,0 +1,2 @@
+default[:attribute_priority_was] = 1
+
diff --git a/features/data/cookbooks/attribute_settings/default.rb b/features/data/cookbooks/attribute_settings/default.rb
new file mode 100644
index 0000000000..9ad0bdd8c6
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings/default.rb
@@ -0,0 +1 @@
+default[:attribute_priority_was] = 0
diff --git a/features/data/cookbooks/attribute_settings/metadata.rb b/features/data/cookbooks/attribute_settings/metadata.rb
new file mode 100644
index 0000000000..ed2938fa6d
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings/metadata.rb
@@ -0,0 +1,6 @@
+maintainer "Opscode"
+maintainer_email "do_not_reply@opscode.com"
+license "Apache 2.0"
+description "Installs/Configures attribute_settings"
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
+version "0.1"
diff --git a/features/data/cookbooks/attribute_settings/recipes/default.rb b/features/data/cookbooks/attribute_settings/recipes/default.rb
new file mode 100644
index 0000000000..23aa2e1c51
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings/recipes/default.rb
@@ -0,0 +1,21 @@
+#
+# Cookbook Name:: attribute_settings
+# 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.
+#
+
+execute "echo #{node[:attribute_priority_was]} > #{node[:tmpdir]}/attribute_setting.txt"
+
diff --git a/features/data/cookbooks/attribute_settings/recipes/default_in_recipe.rb b/features/data/cookbooks/attribute_settings/recipes/default_in_recipe.rb
new file mode 100644
index 0000000000..df4fe70f57
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings/recipes/default_in_recipe.rb
@@ -0,0 +1,25 @@
+#
+# Cookbook Name:: attribute_settings
+# 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.
+#
+
+node.default[:attribute_priority_was] = 3
+
+execute "echo #{node[:attribute_priority_was]} > #{node[:tmpdir]}/attribute_setting.txt"
+
+
+
diff --git a/features/data/cookbooks/attribute_settings_normal/README.rdoc b/features/data/cookbooks/attribute_settings_normal/README.rdoc
new file mode 100644
index 0000000000..8d774805b9
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings_normal/README.rdoc
@@ -0,0 +1,8 @@
+= DESCRIPTION:
+
+= REQUIREMENTS:
+
+= ATTRIBUTES:
+
+= USAGE:
+
diff --git a/features/data/cookbooks/attribute_settings_normal/attributes/.default.rb.swo b/features/data/cookbooks/attribute_settings_normal/attributes/.default.rb.swo
new file mode 100644
index 0000000000..fc5d646009
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings_normal/attributes/.default.rb.swo
Binary files differ
diff --git a/features/data/cookbooks/attribute_settings_normal/attributes/default.rb b/features/data/cookbooks/attribute_settings_normal/attributes/default.rb
new file mode 100644
index 0000000000..88d1e0f9e5
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings_normal/attributes/default.rb
@@ -0,0 +1,2 @@
+normal[:attribute_priority_was] = 4
+
diff --git a/features/data/cookbooks/attribute_settings_normal/default.rb b/features/data/cookbooks/attribute_settings_normal/default.rb
new file mode 100644
index 0000000000..9ad0bdd8c6
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings_normal/default.rb
@@ -0,0 +1 @@
+default[:attribute_priority_was] = 0
diff --git a/features/data/cookbooks/attribute_settings_normal/metadata.rb b/features/data/cookbooks/attribute_settings_normal/metadata.rb
new file mode 100644
index 0000000000..ed2938fa6d
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings_normal/metadata.rb
@@ -0,0 +1,6 @@
+maintainer "Opscode"
+maintainer_email "do_not_reply@opscode.com"
+license "Apache 2.0"
+description "Installs/Configures attribute_settings"
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
+version "0.1"
diff --git a/features/data/cookbooks/attribute_settings_normal/recipes/.default.rb.swo b/features/data/cookbooks/attribute_settings_normal/recipes/.default.rb.swo
new file mode 100644
index 0000000000..369e8d73ce
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings_normal/recipes/.default.rb.swo
Binary files differ
diff --git a/features/data/cookbooks/attribute_settings_normal/recipes/.default_in_recipe.rb.swo b/features/data/cookbooks/attribute_settings_normal/recipes/.default_in_recipe.rb.swo
new file mode 100644
index 0000000000..5804d58505
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings_normal/recipes/.default_in_recipe.rb.swo
Binary files differ
diff --git a/features/data/cookbooks/attribute_settings_normal/recipes/default.rb b/features/data/cookbooks/attribute_settings_normal/recipes/default.rb
new file mode 100644
index 0000000000..23aa2e1c51
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings_normal/recipes/default.rb
@@ -0,0 +1,21 @@
+#
+# Cookbook Name:: attribute_settings
+# 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.
+#
+
+execute "echo #{node[:attribute_priority_was]} > #{node[:tmpdir]}/attribute_setting.txt"
+
diff --git a/features/data/cookbooks/attribute_settings_normal/recipes/normal_in_recipe.rb b/features/data/cookbooks/attribute_settings_normal/recipes/normal_in_recipe.rb
new file mode 100644
index 0000000000..a30df1f8c0
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings_normal/recipes/normal_in_recipe.rb
@@ -0,0 +1,25 @@
+#
+# Cookbook Name:: attribute_settings
+# 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.
+#
+
+node.normal[:attribute_priority_was] = 5
+
+execute "echo #{node[:attribute_priority_was]} > #{node[:tmpdir]}/attribute_setting.txt"
+
+
+
diff --git a/features/data/cookbooks/attribute_settings_override/README.rdoc b/features/data/cookbooks/attribute_settings_override/README.rdoc
new file mode 100644
index 0000000000..8d774805b9
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings_override/README.rdoc
@@ -0,0 +1,8 @@
+= DESCRIPTION:
+
+= REQUIREMENTS:
+
+= ATTRIBUTES:
+
+= USAGE:
+
diff --git a/features/data/cookbooks/attribute_settings_override/attributes/default.rb b/features/data/cookbooks/attribute_settings_override/attributes/default.rb
new file mode 100644
index 0000000000..fc7f0c4842
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings_override/attributes/default.rb
@@ -0,0 +1,2 @@
+override[:attribute_priority_was] = 6
+
diff --git a/features/data/cookbooks/attribute_settings_override/default.rb b/features/data/cookbooks/attribute_settings_override/default.rb
new file mode 100644
index 0000000000..9ad0bdd8c6
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings_override/default.rb
@@ -0,0 +1 @@
+default[:attribute_priority_was] = 0
diff --git a/features/data/cookbooks/attribute_settings_override/metadata.rb b/features/data/cookbooks/attribute_settings_override/metadata.rb
new file mode 100644
index 0000000000..ed2938fa6d
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings_override/metadata.rb
@@ -0,0 +1,6 @@
+maintainer "Opscode"
+maintainer_email "do_not_reply@opscode.com"
+license "Apache 2.0"
+description "Installs/Configures attribute_settings"
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
+version "0.1"
diff --git a/features/data/cookbooks/attribute_settings_override/recipes/default.rb b/features/data/cookbooks/attribute_settings_override/recipes/default.rb
new file mode 100644
index 0000000000..23aa2e1c51
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings_override/recipes/default.rb
@@ -0,0 +1,21 @@
+#
+# Cookbook Name:: attribute_settings
+# 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.
+#
+
+execute "echo #{node[:attribute_priority_was]} > #{node[:tmpdir]}/attribute_setting.txt"
+
diff --git a/features/data/cookbooks/attribute_settings_override/recipes/normal_in_recipe.rb b/features/data/cookbooks/attribute_settings_override/recipes/normal_in_recipe.rb
new file mode 100644
index 0000000000..efc8c3f19d
--- /dev/null
+++ b/features/data/cookbooks/attribute_settings_override/recipes/normal_in_recipe.rb
@@ -0,0 +1,25 @@
+#
+# Cookbook Name:: attribute_settings
+# 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.
+#
+
+node.override[:attribute_priority_was] = 8
+
+execute "echo #{node[:attribute_priority_was]} > #{node[:tmpdir]}/attribute_setting.txt"
+
+
+
diff --git a/features/steps/fixture_steps.rb b/features/steps/fixture_steps.rb
index 3319a289ec..9613e4a72f 100644
--- a/features/steps/fixture_steps.rb
+++ b/features/steps/fixture_steps.rb
@@ -96,6 +96,22 @@ Before do
r.description "Non-existent nested role"
r.run_list << "role[not_exist]"
r
+ end,
+ 'attribute_settings_default' => Proc.new do
+ r = Chef::Role.new
+ r.name "attribute_settings_default"
+ r.description "sets a default value"
+ r.run_list("recipe[attribute_settings]")
+ r.default_attributes({ 'attribute_priority_was' => 2 })
+ r
+ end,
+ 'attribute_settings_override' => Proc.new do
+ r = Chef::Role.new
+ r.name "attribute_settings_override"
+ r.description "sets a default value"
+ r.run_list("recipe[attribute_settings_override]")
+ r.override_attributes({ 'attribute_priority_was' => 7 })
+ r
end
},
'node' => {
diff --git a/features/steps/node_steps.rb b/features/steps/node_steps.rb
index 921ad4d22a..b51d664e8c 100644
--- a/features/steps/node_steps.rb
+++ b/features/steps/node_steps.rb
@@ -51,3 +51,6 @@ When /^the node is converged$/ do
client.run
end
+When /^the node is retrieved from the API$/ do
+ self.inflated_response = Chef::Node.load(client.node.name)
+end