diff options
author | Nuo Yan <nuo@opscode.com> | 2011-04-05 14:46:30 -0700 |
---|---|---|
committer | Nuo Yan <nuo@opscode.com> | 2011-04-05 18:42:47 -0700 |
commit | 95cccfba863a0191bf2f29483ee9cd1e525ef52b (patch) | |
tree | 97f35a5334278a67509a70655a9d9ac109b7efc7 /features | |
parent | 9e562efb6d8319899615bfda6b08b608a5bb8018 (diff) | |
download | chef-95cccfba863a0191bf2f29483ee9cd1e525ef52b.tar.gz |
CHEF-2183 Default and Override Attributes for Environments
Diffstat (limited to 'features')
-rw-r--r-- | features/chef-client/attribute_settings.feature | 45 | ||||
-rw-r--r-- | features/steps/fixture_steps.rb | 10 | ||||
-rw-r--r-- | features/steps/node_steps.rb | 14 |
3 files changed, 48 insertions, 21 deletions
diff --git a/features/chef-client/attribute_settings.feature b/features/chef-client/attribute_settings.feature index 018f9511e7..f0ab6a9705 100644 --- a/features/chef-client/attribute_settings.feature +++ b/features/chef-client/attribute_settings.feature @@ -15,10 +15,22 @@ Feature: Set default, normal, and override attributes When the node is retrieved from the API Then the inflated responses key 'attribute_priority_was' should match 'came from recipe\[attribute_settings\] attributes' + Scenario: Set the default attribute in a environment + Given I am an administrator + And an 'environment' named 'default_attr_test' exists + And a validated node in the 'default_attr_test' environment + And it includes the recipe 'attribute_settings' + When I run the chef-client with '-l debug' + Then the run should exit '0' + And a file named 'attribute_setting.txt' should contain 'came from environment default_attr_test default attributes' + When the node is retrieved from the API + Then the inflated responses key 'attribute_priority_was' should match 'came from environment default_attr_test default attributes' + Scenario: Set the default attribute in a role Given I am an administrator + And an 'environment' named 'default_attr_test' exists And a 'role' named 'attribute_settings_default' exists - And a validated node + And a validated node in the 'default_attr_test' environment And it includes the role 'attribute_settings_default' When I run the chef-client Then the run should exit '0' @@ -28,8 +40,9 @@ Feature: Set default, normal, and override attributes Scenario: Set the default attribute in a recipe Given I am an administrator + And an 'environment' named 'default_attr_test' exists And a 'role' named 'attribute_settings_default' exists - And a validated node + And a validated node in the 'default_attr_test' environment And it includes the role 'attribute_settings_default' And it includes the recipe 'attribute_settings::default_in_recipe' When I run the chef-client @@ -40,7 +53,8 @@ Feature: Set default, normal, and override attributes Scenario: Set a normal attribute in a cookbook attribute file Given I am an administrator - And a validated node + And an 'environment' named 'default_attr_test' exists + And a validated node in the 'default_attr_test' environment And a 'role' named 'attribute_settings_default' exists And it includes the role 'attribute_settings_default' And it includes the recipe 'attribute_settings::default_in_recipe' @@ -53,7 +67,8 @@ Feature: Set default, normal, and override attributes Scenario: Set a normal attribute in a cookbook recipe Given I am an administrator - And a validated node + And an 'environment' named 'default_attr_test' exists + And a validated node in the 'default_attr_test' environment And a 'role' named 'attribute_settings_default' exists And it includes the role 'attribute_settings_default' And it includes the recipe 'attribute_settings::default_in_recipe' @@ -66,7 +81,8 @@ Feature: Set default, normal, and override attributes Scenario: Set an override attribute in a cookbook attribute file Given I am an administrator - And a validated node + And an 'environment' named 'default_attr_test' exists + And a validated node in the 'default_attr_test' environment And a 'role' named 'attribute_settings_default' exists And it includes the role 'attribute_settings_default' And it includes the recipe 'attribute_settings::default_in_recipe' @@ -82,7 +98,8 @@ Feature: Set default, normal, and override attributes Given I am an administrator And a 'role' named 'attribute_settings_default' exists And a 'role' named 'attribute_settings_override' exists - And a validated node + And an 'environment' named 'default_attr_test' exists + And a validated node in the 'default_attr_test' environment 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' @@ -94,7 +111,7 @@ Feature: Set default, normal, and override attributes When the node is retrieved from the API Then the inflated responses key 'attribute_priority_was' should match 'came from role\[attribute_settings_override\] override attributes' - Scenario: Set the attribute in a environment + Scenario: Set the override attribute in a environment Given I am an administrator And an 'environment' named 'cucumber' exists And a 'role' named 'attribute_settings_default' exists @@ -107,15 +124,16 @@ Feature: Set default, normal, and override attributes And it includes the role 'attribute_settings_override' When I run the chef-client with '-l debug' Then the run should exit '0' - And a file named 'attribute_setting.txt' should contain 'came from environment cucumber' + And a file named 'attribute_setting.txt' should contain 'came from environment cucumber override attributes' When the node is retrieved from the API - Then the inflated responses key 'attribute_priority_was' should match 'came from environment cucumber' + Then the inflated responses key 'attribute_priority_was' should match 'came from environment cucumber override attributes' Scenario: Set the override attribute in a recipe Given I am an administrator + And an 'environment' named 'cucumber' exists And a 'role' named 'attribute_settings_default' exists And a 'role' named 'attribute_settings_override' exists - And a validated node + And a validated node in the 'cucumber' environment 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' @@ -130,14 +148,15 @@ Feature: Set default, normal, and override attributes Scenario: Data is removed from override attribute in a recipe Given I am an administrator + And an 'environment' named 'cucumber' exists And a 'role' named 'attribute_settings_override' exists - And a validated node + And a validated node in the 'cucumber' environment 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 'came from role\[attribute_settings_override\] override attributes' + And a file named 'attribute_setting.txt' should contain 'came from environment cucumber override attributes' When the node is retrieved from the API - Then the inflated responses key 'attribute_priority_was' should match 'came from role\[attribute_settings_override\] override attributes' + Then the inflated responses key 'attribute_priority_was' should match 'came from environment cucumber override attributes' Given it includes no recipes And it includes the recipe 'integration_setup' And it includes the recipe 'no_attributes' diff --git a/features/steps/fixture_steps.rb b/features/steps/fixture_steps.rb index 353cff2f5a..b3ef44f85c 100644 --- a/features/steps/fixture_steps.rb +++ b/features/steps/fixture_steps.rb @@ -270,11 +270,19 @@ Before do 'name only' => { :name => 'test_cookbook' } }, 'environment' => { + 'default_attr_test' => Proc.new do + e = Chef::Environment.new + e.name 'default_attr_test' + e.description 'Test default attrs for environments' + e.default_attributes({"attribute_priority_was" => "came from environment default_attr_test default attributes"}) + e + end, 'cucumber' => Proc.new do e = Chef::Environment.new e.name 'cucumber' e.description 'I like to run tests' - e.attributes({"attribute_priority_was" => "came from environment cucumber"}) + e.default_attributes({"attribute_priority_was" => "came from environment cucumber default attributes"}) + e.override_attributes({"attribute_priority_was" => "came from environment cucumber override attributes"}) e end, 'production' => Proc.new do diff --git a/features/steps/node_steps.rb b/features/steps/node_steps.rb index 5f97044d6f..43466df9f6 100644 --- a/features/steps/node_steps.rb +++ b/features/steps/node_steps.rb @@ -6,9 +6,9 @@ # 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. @@ -26,11 +26,11 @@ Given /^a validated node$/ do client.node.run_list << "integration_setup" end -Given /^a validated node in the 'cucumber' environment$/ do +Given /^a validated node in the '(\w+)' environment$/ do |env| # client should have cached ohai assigned to it client.register client.build_node - client.node.chef_environment("cucumber") + client.node.chef_environment(env) client.node.run_list << "integration_setup" end @@ -53,15 +53,15 @@ Given /^it includes the recipe '([^\']+)' at version '([^\']+)'$/ do |recipe, ve client.node.save end -Given /^it includes no recipes$/ do - self.recipe = "" +Given /^it includes no recipes$/ do + self.recipe = "" client.node.run_list.reset! client.node.save end Given /^it includes the role '([^\']+)'$/ do |role| self.recipe = "role[#{role}]" - client.node.run_list << "role[#{role}]" + client.node.run_list << "role[#{role}]" client.node.save end |