summaryrefslogtreecommitdiff
path: root/features
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2011-03-28 15:07:08 -0700
committerDaniel DeLeo <dan@opscode.com>2011-03-28 15:08:19 -0700
commitca54deb184f79aa61c80845d22bd5c22d199c7ac (patch)
tree5e54a5ad69589d0542fef6064f8b793cb12c0e59 /features
parent78ca2b882ec2895275b318ed642df5602c072cbe (diff)
downloadchef-ca54deb184f79aa61c80845d22bd5c22d199c7ac.tar.gz
fixes for features
Diffstat (limited to 'features')
-rw-r--r--features/chef-client/attribute_settings.feature57
-rw-r--r--features/chef-client/roles.feature6
-rw-r--r--features/steps/cookbook_steps.rb17
-rw-r--r--features/steps/node_steps.rb2
-rw-r--r--features/steps/run_solo.rb6
-rw-r--r--features/support/env.rb4
6 files changed, 54 insertions, 38 deletions
diff --git a/features/chef-client/attribute_settings.feature b/features/chef-client/attribute_settings.feature
index e2c9a6d1c4..018f9511e7 100644
--- a/features/chef-client/attribute_settings.feature
+++ b/features/chef-client/attribute_settings.feature
@@ -1,12 +1,13 @@
@client @attribute_settings
-Feature: Set default, normal, and override attributes
+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
+ I want to use different kinds of attributes
Scenario: Set a default attribute in a cookbook attribute file
- Given a validated node
+ Given I am an administrator
+ And a validated node
And it includes the recipe 'attribute_settings'
When I run the chef-client
Then the run should exit '0'
@@ -14,8 +15,9 @@ 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 role
- Given a 'role' named 'attribute_settings_default' exists
+ Scenario: Set the default attribute in a role
+ Given I am an administrator
+ And 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
@@ -23,9 +25,10 @@ Feature: Set default, normal, and override attributes
And a file named 'attribute_setting.txt' should contain 'came from role\[attribute_settings_default\] default attributes'
When the node is retrieved from the API
Then the inflated responses key 'attribute_priority_was' should match 'came from role\[attribute_settings_default\] default attributes'
-
- Scenario: Set the default attribute in a recipe
- Given a 'role' named 'attribute_settings_default' exists
+
+ Scenario: Set the default attribute in a recipe
+ Given I am an administrator
+ And 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'
@@ -36,7 +39,8 @@ Feature: Set default, normal, and override attributes
Then the inflated responses key 'attribute_priority_was' should match 'came from recipe\[attribute_settings::default_in_recipe\]'
Scenario: Set a normal attribute in a cookbook attribute file
- Given a validated node
+ Given I am an administrator
+ And a validated node
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'
@@ -47,8 +51,9 @@ 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_normal\] attributes'
- Scenario: Set a normal attribute in a cookbook recipe
- Given a validated node
+ Scenario: Set a normal attribute in a cookbook recipe
+ Given I am an administrator
+ And a validated node
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'
@@ -60,7 +65,8 @@ Feature: Set default, normal, and override attributes
Then the inflated responses key 'attribute_priority_was' should match 'came from recipe\[attribute_settings_normal::normal_in_recipe\]'
Scenario: Set an override attribute in a cookbook attribute file
- Given a validated node
+ Given I am an administrator
+ And a validated node
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'
@@ -72,8 +78,9 @@ 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_override\] override attributes'
- Scenario: Set the override attribute in a role
- Given a 'role' named 'attribute_settings_default' exists
+ Scenario: Set the override attribute in a role
+ 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 it includes the role 'attribute_settings_default'
@@ -86,9 +93,10 @@ Feature: Set default, normal, and override attributes
And a file named 'attribute_setting.txt' should contain 'came from role\[attribute_settings_override\] 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
- Given an 'environment' named 'cucumber' exists
+ 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 in the 'cucumber' environment
@@ -102,9 +110,10 @@ Feature: Set default, normal, and override attributes
And a file named 'attribute_setting.txt' should contain 'came from environment cucumber'
When the node is retrieved from the API
Then the inflated responses key 'attribute_priority_was' should match 'came from environment cucumber'
-
- Scenario: Set the override attribute in a recipe
- Given a 'role' named 'attribute_settings_default' exists
+
+ Scenario: Set the override attribute in a recipe
+ 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 it includes the role 'attribute_settings_default'
@@ -119,8 +128,9 @@ 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_override::override_in_recipe\]'
- Scenario: Data is removed from override attribute in a recipe
- Given a 'role' named 'attribute_settings_override' exists
+ Scenario: Data is removed from override attribute in a recipe
+ Given I am an administrator
+ And a 'role' named 'attribute_settings_override' exists
And a validated node
And it includes the role 'attribute_settings_override'
When I run the chef-client
@@ -139,14 +149,15 @@ Feature: Set default, normal, and override attributes
# Test that attributes from JSON are applied before attribute files are applied.
@chef1286
Scenario: Attributes from JSON files are normal attributes applied before attribute files
- Given a validated node
+ Given I am an administrator
+ And a validated node
And it includes the recipe 'attribute_settings_normal'
When I run the chef-client with json attributes
Then the run should exit '0'
Then a file named 'attribute_setting.txt' should contain 'came from recipe\[attribute_settings_normal\] attributes'
When the node is retrieved from the API
Then the inflated responses key 'attribute_priority_was' should match 'came from recipe\[attribute_settings_normal\] attributes'
-
+
@chef1286
Scenario: Attributes from JSON files have higher precedence than defaults
Given a 'role' named 'attribute_settings_default' exists
diff --git a/features/chef-client/roles.feature b/features/chef-client/roles.feature
index e86564c6db..26d8cf885f 100644
--- a/features/chef-client/roles.feature
+++ b/features/chef-client/roles.feature
@@ -5,7 +5,8 @@ Feature: Configure nodes based on their role
I want to define and utilize roles
Scenario: Apply a role to a node
- Given a validated node
+ Given I am an administrator
+ And a validated node
And it includes the role 'role_test'
And a 'role' named 'role_test' exists
When I run the chef-client with '-l debug'
@@ -16,7 +17,8 @@ Feature: Configure nodes based on their role
And a file named 'role_test_ruby_version.txt' should contain '1.\d+.\d+'
Scenario: Apply a role with multiple environment specific run_lists to a node
- Given an 'environment' named 'cucumber' exists
+ Given I am an administrator
+ And an 'environment' named 'cucumber' exists
And a validated node in the 'cucumber' environment
And it includes the role 'role_env_test'
And a 'role' named 'role_env_test' exists
diff --git a/features/steps/cookbook_steps.rb b/features/steps/cookbook_steps.rb
index 3e4e78f9c0..ac629e7b45 100644
--- a/features/steps/cookbook_steps.rb
+++ b/features/steps/cookbook_steps.rb
@@ -110,16 +110,15 @@ end
When "I upload a cookbook named '$name' at version '$version'" do |name, version|
- # This is total crap :(
- Chef::Config[:client_key] = rest.auth_credentials.key_file
- Chef::Config[:node_name] = rest.auth_credentials.client_name
- cookbook = @cookbook_loader_not_uploaded_at_feature_start[name]
- uploader = Chef::CookbookUploader.new(cookbook, [EXTRA_COOKBOOKS], :rest => rest)
- begin
- uploader.upload_cookbook
- rescue Exception => e
- @exception = e
+ call_as_admin do
+ cookbook = @cookbook_loader_not_uploaded_at_feature_start[name]
+ uploader = Chef::CookbookUploader.new(cookbook, [EXTRA_COOKBOOKS], :rest => rest)
+ begin
+ uploader.upload_cookbook
+ rescue Exception => e
+ @exception = e
+ end
end
end
diff --git a/features/steps/node_steps.rb b/features/steps/node_steps.rb
index 13c2dff2dd..5f97044d6f 100644
--- a/features/steps/node_steps.rb
+++ b/features/steps/node_steps.rb
@@ -21,7 +21,7 @@
###
Given /^a validated node$/ do
# client should have cached ohai assigned to it
- client.register
+ client.register(ohai[:fqdn], :client_key => client_key )
client.build_node
client.node.run_list << "integration_setup"
end
diff --git a/features/steps/run_solo.rb b/features/steps/run_solo.rb
index e9157d8bd1..458e80714d 100644
--- a/features/steps/run_solo.rb
+++ b/features/steps/run_solo.rb
@@ -27,10 +27,10 @@ When /^I run chef-solo with the '(.+)' recipe$/ do |recipe_name|
binary_path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'chef', 'bin', 'chef-solo'))
command = "#{binary_path} -c #{config_file} -j #{dna_file}"
- command += " -l debug" if ENV['LOG_LEVEL'] == 'debug'
+ command += " -l debug" if Chef::Log.debug?
# Run it
- puts "Running solo: #{command}" if ENV['LOG_LEVEL'] == 'debug'
+ puts "Running solo: #{command}" if Chef::Log.debug?
status = Chef::Mixin::Command.popen4(command) do |p, i, o, e|
@stdout = o.gets(nil)
@@ -38,7 +38,7 @@ When /^I run chef-solo with the '(.+)' recipe$/ do |recipe_name|
end
@status = status
- print_output if ENV['LOG_LEVEL'] == 'debug'
+ print_output if Chef::Log.debug?
end
diff --git a/features/support/env.rb b/features/support/env.rb
index d29d60776f..d1a45d436d 100644
--- a/features/support/env.rb
+++ b/features/support/env.rb
@@ -196,6 +196,10 @@ module ChefWorld
end
end
+ def client_key
+ File.join(tmpdir, "client.pem")
+ end
+
def rest
@rest ||= Chef::REST.new('http://localhost:4000', nil, nil)
end