diff options
author | Chris Walters <cw@opscode.com> | 2010-10-27 18:06:56 -0700 |
---|---|---|
committer | Chris Walters <cw@opscode.com> | 2010-10-27 18:07:10 -0700 |
commit | e3299d6f332ccbafcc8da6fe38f1c77d25483394 (patch) | |
tree | 927d24b73d3f41aed426332667a2a0ccc8b9fd3c | |
parent | 6ac0f9d4ae9b7c1b2c726804183204b5a219d1bc (diff) | |
download | chef-e3299d6f332ccbafcc8da6fe38f1c77d25483394.tar.gz |
Adding pending test for CHEF-1816: timestamped deploy provider's rollback does not work
-rw-r--r-- | features/data/cookbooks/deploy/recipes/deploy_commit1.rb | 25 | ||||
-rw-r--r-- | features/data/cookbooks/deploy/recipes/deploy_commit2.rb | 25 | ||||
-rw-r--r-- | features/data/cookbooks/deploy/recipes/rollback.rb | 56 | ||||
-rw-r--r-- | features/data/cookbooks/deploy/recipes/rollback_commit2.rb | 24 | ||||
-rw-r--r-- | features/data/test_git_repo.tar.gz | bin | 0 -> 8191 bytes | |||
-rw-r--r-- | features/provider/deploy/deploy.feature | 59 | ||||
-rw-r--r-- | features/steps/deploy_steps.rb | 9 | ||||
-rw-r--r-- | features/steps/node_steps.rb | 11 | ||||
-rw-r--r-- | features/steps/pending_steps.rb | 21 |
9 files changed, 151 insertions, 79 deletions
diff --git a/features/data/cookbooks/deploy/recipes/deploy_commit1.rb b/features/data/cookbooks/deploy/recipes/deploy_commit1.rb new file mode 100644 index 0000000000..f2b28a8874 --- /dev/null +++ b/features/data/cookbooks/deploy/recipes/deploy_commit1.rb @@ -0,0 +1,25 @@ +# +# Cookbook Name:: deploy +# Recipe:: deploy_commit1 +# +# Copyright 2010, 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. +# + +deploy "deploy" do + deploy_to "#{node[:tmpdir]}/deploy" + repo "#{node[:tmpdir]}/test_git_repo" + revision "commit1" + action :deploy +end diff --git a/features/data/cookbooks/deploy/recipes/deploy_commit2.rb b/features/data/cookbooks/deploy/recipes/deploy_commit2.rb new file mode 100644 index 0000000000..87231bb272 --- /dev/null +++ b/features/data/cookbooks/deploy/recipes/deploy_commit2.rb @@ -0,0 +1,25 @@ +# +# Cookbook Name:: deploy +# Recipe:: deploy_commit2 +# +# Copyright 2010, 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. +# + +deploy "deploy" do + deploy_to "#{node[:tmpdir]}/deploy" + repo "#{node[:tmpdir]}/test_git_repo" + revision "commit2" + action :deploy +end diff --git a/features/data/cookbooks/deploy/recipes/rollback.rb b/features/data/cookbooks/deploy/recipes/rollback.rb deleted file mode 100644 index 34ddbecf40..0000000000 --- a/features/data/cookbooks/deploy/recipes/rollback.rb +++ /dev/null @@ -1,56 +0,0 @@ -# -# Cookbook Name:: deploy -# Recipe:: rollback -# -# 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. -# - -%w{ log tmp/pids public/system config sqlite}.each do |dir| - directory "#{node[:tmpdir]}/deploy/shared/#{dir}" do - recursive true - mode "0775" - end -end - -# Use a template instead in real life -file "#{node[:tmpdir]}/deploy/shared/config/database.yml" do - mode "0664" -end - -file "#{node[:tmpdir]}/deploy/shared/sqlite/production.sqlite3" do - mode "0664" -end - -deploy "#{node[:tmpdir]}/deploy" do - repo "file:///#{File.dirname(__FILE__) + "/../../../../../../../"}" - revision "HEAD" - action :deploy - restart_command "touch tmp/restart.txt" -end - -deploy "#{node[:tmpdir]}/deploy" do - repo "file:///#{File.dirname(__FILE__) + "/../../../../../../../"}" - revision "HEAD" - action :deploy - restart_command "touch tmp/restart.txt" -end - -deploy "#{node[:tmpdir]}/deploy" do - repo "file:///#{File.dirname(__FILE__) + "/../../../../../../../"}" - revision "HEAD" - action :rollback - restart_command "touch tmp/restart.txt" -end - diff --git a/features/data/cookbooks/deploy/recipes/rollback_commit2.rb b/features/data/cookbooks/deploy/recipes/rollback_commit2.rb new file mode 100644 index 0000000000..08720964b8 --- /dev/null +++ b/features/data/cookbooks/deploy/recipes/rollback_commit2.rb @@ -0,0 +1,24 @@ +# +# Cookbook Name:: deploy +# Recipe:: rollback_commit2 +# +# Copyright 2010, 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. +# + +deploy "deploy" do + deploy_to "#{node[:tmpdir]}/deploy" + repo "#{node[:tmpdir]}/test_git_repo" + action :rollback +end diff --git a/features/data/test_git_repo.tar.gz b/features/data/test_git_repo.tar.gz Binary files differnew file mode 100644 index 0000000000..8c34c11c10 --- /dev/null +++ b/features/data/test_git_repo.tar.gz diff --git a/features/provider/deploy/deploy.feature b/features/provider/deploy/deploy.feature index fb27813b8a..fcd99b897f 100644 --- a/features/provider/deploy/deploy.feature +++ b/features/provider/deploy/deploy.feature @@ -47,32 +47,45 @@ Feature: Deploy | before_restart.rb | | after_restart.rb | - Scenario: Deploy an app with resources inside the callbacks (embedded recipes) - Given a validated node - And it includes the recipe 'deploy::embedded_recipe_callbacks' - And I have a clone of the rails app in the data/tmp dir - And that I have 'rails' '2.3.4' installed + Scenario: Deploy an app with resources inside the callbacks (embedded recipes) + Given a validated node + And it includes the recipe 'deploy::embedded_recipe_callbacks' + And I have a clone of the rails app in the data/tmp dir + And that I have 'rails' '2.3.4' installed And that I have 'sqlite3-ruby' '1.2.5' installed - When I run the chef-client - Then the run should exit '0' - And a file named 'deploy/current/app/before_symlink_was_here.txt' should exist - And a file named 'deploy/current/tmp/restart.txt' should exist + When I run the chef-client + Then the run should exit '0' + And a file named 'deploy/current/app/before_symlink_was_here.txt' should exist + And a file named 'deploy/current/tmp/restart.txt' should exist - Scenario: Rollback an app - Given a validated node - And it includes the recipe 'deploy::rollback' + @chef-1816 @known_issue + Scenario: Deploy twice and rollback once + Given I haven't yet fixed CHEF-1816, this test should be pending + Given a test git repo in the temp directory + And a validated node + And it includes the recipe 'deploy::deploy_commit1' When I run the chef-client + Then the run should exit '0' Then there should be 'one' release - - - Scenario: Deploy an app twice using the idempotent revision deploy strategy - Given a validated node - And it includes the recipe 'deploy::revision_deploy' - And I have a clone of the rails app in the data/tmp dir - And that I have 'rails' '2.3.4' installed + When I remove 'recipe[deploy::deploy_commit1]' from the node's run list + And I add 'deploy::deploy_commit2' to the node's run list + And I run the chef-client + Then the run should exit '0' + Then there should be 'two' releases + When I remove 'recipe[deploy::deploy_commit2]' from the node's run list + And I add 'deploy::rollback_commit2' to the node's run list + And I run the chef-client + Then the run should exit '0' + Then there should be 'one' release + + Scenario: Deploy an app twice using the idempotent revision deploy strategy + Given a validated node + And it includes the recipe 'deploy::revision_deploy' + And I have a clone of the rails app in the data/tmp dir + And that I have 'rails' '2.3.4' installed And that I have 'sqlite3-ruby' '1.2.5' installed - When I run the chef-client - And I run the chef-client at log level 'info' + When I run the chef-client + And I run the chef-client at log level 'info' Then the run should exit '0' - And there should be 'one' release - And the second chef run should have skipped deployment
\ No newline at end of file + And there should be 'one' release + And the second chef run should have skipped deployment diff --git a/features/steps/deploy_steps.rb b/features/steps/deploy_steps.rb index b10603427f..2a3906f5ad 100644 --- a/features/steps/deploy_steps.rb +++ b/features/steps/deploy_steps.rb @@ -1,3 +1,6 @@ +require 'chef/shell_out' + + # Given /^I have a clone of typo in the data\/tmp dir$/ do # cmd = "git clone #{datadir}/typo.bundle #{tmpdir}/gitrepo/typo" # `#{cmd}` @@ -19,6 +22,12 @@ Given /^that I have '(.*)' '(.*)' installed$/ do |gem_name, version| end end +Given /^a test git repo in the temp directory$/ do + test_git_repo_tarball_filename = "#{datadir}/test_git_repo.tar.gz" + cmd = Chef::ShellOut.new("tar xzvf #{test_git_repo_tarball_filename} -C #{tmpdir}") + cmd.run_command.exitstatus.should == 0 +end + Then /^I should hear about it$/ do puts "==deploy:" puts `ls #{tmpdir}/deploy/` diff --git a/features/steps/node_steps.rb b/features/steps/node_steps.rb index 114137eedc..e697318ce4 100644 --- a/features/steps/node_steps.rb +++ b/features/steps/node_steps.rb @@ -54,6 +54,17 @@ end ### # When ### +When /^I remove '([^']*)' from the node's run list$/ do |run_list_item| + client.node.run_list.remove(run_list_item) + client.node.save +end + +When /^I add '([^']*)' to the node's run list$/ do |run_list_item| + client.node.run_list << run_list_item + client.node.save +end + + When /^the node is converged$/ do client.run end diff --git a/features/steps/pending_steps.rb b/features/steps/pending_steps.rb new file mode 100644 index 0000000000..b97707f36b --- /dev/null +++ b/features/steps/pending_steps.rb @@ -0,0 +1,21 @@ +# +# Author:: Christopher Walters (<cw@opscode.com>) +# Copyright:: Copyright (c) 2010 Opscode, Inc. +# License:: Apache License, Version 2.0 +# +# 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. +# + +When "I haven't yet fixed CHEF-1816, this test should be pending" do + pending "CHEF-1816: Timestamp deploy provider rollback doesn't work" +end |