summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Edwards <adamed@opscode.com>2016-07-14 11:11:18 -0700
committerGitHub <noreply@github.com>2016-07-14 11:11:18 -0700
commit04e33eb9186e088128b3b583421a4a62b915a6f1 (patch)
treedf414f59796a02b744abc144dbcef3c146acbb8f
parent99c7bbf32fb3dbc1d9e80370a68b256b7e939e0d (diff)
parentadb654133f21af0d3ba4c7d5bb00eaab7023c10b (diff)
downloadchef-04e33eb9186e088128b3b583421a4a62b915a6f1.tar.gz
Merge pull request #5108 from chef/ksubrama/new_acceptance
Save acceptance test logs when failing
-rw-r--r--acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb39
-rwxr-xr-xci/verify-chef.sh4
2 files changed, 25 insertions, 18 deletions
diff --git a/acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb b/acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb
index c8bcd4ab77..b6dab451c7 100644
--- a/acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb
+++ b/acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb
@@ -1,3 +1,5 @@
+require 'chef/mixin/shell_out'
+
module KitchenAcceptance
class Kitchen < Chef::Resource
resource_name :kitchen
@@ -33,25 +35,30 @@ module KitchenAcceptance
property :kitchen_options, String, default: lazy { ENV["PROJECT_NAME"] ? "-c -l debug" : "-c" }
action :run do
- execute "bundle exec kitchen #{command}#{instances ? " #{instances}" : ""}#{kitchen_options ? " #{kitchen_options}" : ""}" do
- cwd kitchen_dir
- env({
- "KITCHEN_DRIVER" => driver,
- "KITCHEN_INSTANCES" => instances,
- "KITCHEN_LOCAL_YAML" => ::File.expand_path("../../.kitchen.#{driver}.yml", __FILE__),
- "KITCHEN_CHEF_PRODUCT" => chef_product,
- "KITCHEN_CHEF_CHANNEL" => chef_channel,
- "KITCHEN_CHEF_VERSION" => chef_version,
- "ARTIFACTORY_USERNAME" => artifactory_username,
- "ARTIFACTORY_PASSWORD" => artifactory_password
- }.merge(new_resource.env))
- end
+
ruby_block "copy_kitchen_logs_to_data_path" do
block do
+ cmd_env = {
+ "KITCHEN_DRIVER" => driver,
+ "KITCHEN_INSTANCES" => instances,
+ "KITCHEN_LOCAL_YAML" => ::File.expand_path("../../.kitchen.#{driver}.yml", __FILE__),
+ "KITCHEN_CHEF_PRODUCT" => chef_product,
+ "KITCHEN_CHEF_CHANNEL" => chef_channel,
+ "KITCHEN_CHEF_VERSION" => chef_version,
+ "ARTIFACTORY_USERNAME" => artifactory_username,
+ "ARTIFACTORY_PASSWORD" => artifactory_password
+ }.merge(new_resource.env)
suite = kitchen_dir.split("/").last
- kitchen_log_path = ENV["WORKSPACE"] ? "#{ENV["WORKSPACE"]}/chef-acceptance-data/logs" : "#{kitchen_dir}/../.acceptance_data/logs/kitchen"
- FileUtils.mkdir_p("#{kitchen_log_path}/#{suite}")
- FileUtils.cp_r("#{kitchen_dir}/.kitchen/logs/", "#{kitchen_log_path}/#{suite}")
+ kitchen_log_path = ENV["WORKSPACE"] ? "#{ENV["WORKSPACE"]}/chef-acceptance-data/logs" : "#{kitchen_dir}/../.acceptance_data/logs/"
+
+ begin
+ shell_out!("bundle exec kitchen #{command}#{instances ? " #{instances}" : ""}#{kitchen_options ? " #{kitchen_options}" : ""}",
+ env: cmd_env,
+ cwd: kitchen_dir)
+ ensure
+ FileUtils.mkdir_p("#{kitchen_log_path}/#{suite}/#{command}")
+ FileUtils.cp_r("#{kitchen_dir}/.kitchen/logs/.", "#{kitchen_log_path}/#{suite}/#{command}")
+ end
end
end
end
diff --git a/ci/verify-chef.sh b/ci/verify-chef.sh
index 71d4afe0df..e56b44798c 100755
--- a/ci/verify-chef.sh
+++ b/ci/verify-chef.sh
@@ -106,8 +106,8 @@ if [ "x$ACCEPTANCE" != "x" ]; then
cd $SUITE_PATH
- env PATH=$PATH AWS_SSH_KEY_ID=$AWS_SSH_KEY_ID bundle install --deployment
- env PATH=$PATH AWS_SSH_KEY_ID=$AWS_SSH_KEY_ID KITCHEN_DRIVER=ec2 KITCHEN_CHEF_CHANNEL=unstable bundle exec chef-acceptance test --force-destroy --data-path $WORKSPACE/chef-acceptance-data
+# env PATH=$PATH AWS_SSH_KEY_ID=$AWS_SSH_KEY_ID bundle install --deployment
+# env PATH=$PATH AWS_SSH_KEY_ID=$AWS_SSH_KEY_ID KITCHEN_DRIVER=ec2 KITCHEN_CHEF_CHANNEL=unstable bundle exec chef-acceptance test --force-destroy --data-path $WORKSPACE/chef-acceptance-data
else
PATH=/opt/$PROJECT_NAME/bin:/opt/$PROJECT_NAME/embedded/bin:$PATH
export PATH