From e4c6f48efa90bab940d30118be25e4849c4aea5e Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Mon, 31 Oct 2016 15:15:34 -0600 Subject: [PATCH] Split out puppet logs To improve troubleshooting and readability, let's not have the puppet logs print to the console. This change updates the puppet apply to output the logs to puppet.log which will still be captured and provided in the CI results. When the puppet apply fails, we will grep for warnings and errors from the puppet log and only print those out which should simplify troubleshooting failures. Change-Id: I1084223f805f1960aebb9c5868fdef84ff3667e4 --- copy_logs.sh | 3 +++ functions | 8 ++++++++ run_tests.sh | 6 +++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/copy_logs.sh b/copy_logs.sh index 8f7d234cd..8cd8a70f9 100755 --- a/copy_logs.sh +++ b/copy_logs.sh @@ -55,6 +55,9 @@ done # some commands could fail if service failed to be installed during Puppet runs set +e +# Copy puppet log +cp ${WORKSPACE}/puppet*.log $LOG_DIR + # Archive the project config & logs mkdir $LOG_DIR/etc/ for p in $PROJECTS; do diff --git a/functions b/functions index 2a9cfe1e9..558cd18b6 100644 --- a/functions +++ b/functions @@ -203,3 +203,11 @@ function catch_selinux_alerts() { fi fi } + +function timestamp_puppet_log() { + mv ${WORKSPACE}/puppet.log ${WORKSPACE}/puppet-$(date +%Y%m%d_%H%M%S).log +} + +function catch_puppet_failures() { + grep -iE '(warning|error)' ${WORKSPACE}/puppet.log +} diff --git a/run_tests.sh b/run_tests.sh index f685869dd..a492d17ea 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -22,7 +22,7 @@ export SWAP_SIZE_GB=${SWAP_SIZE_GB:-2} export SCRIPT_DIR=$(cd `dirname $0` && pwd -P) export HIERA_CONFIG=${HIERA_CONFIG:-${SCRIPT_DIR}/hiera/hiera.yaml} export MANAGE_HIERA=${MANAGE_HIERA:-true} -export PUPPET_ARGS="${PUPPET_ARGS} --detailed-exitcodes --color=false --test --trace --hiera_config ${HIERA_CONFIG}" +export PUPPET_ARGS="${PUPPET_ARGS} --detailed-exitcodes --color=false --test --trace --hiera_config ${HIERA_CONFIG} --logdest ${WORKSPACE}/puppet.log" export DISTRO=$(lsb_release -c -s) # NOTE(pabelanger): Setup facter to know about AFS mirror. @@ -152,10 +152,12 @@ RESULT=$? set -e if [ $RESULT -ne 0 ] && [ $RESULT -ne 2 ]; then print_header 'First Puppet run contains errors in catalog.' + catch_puppet_failures print_header 'SELinux Alerts (1st time)' catch_selinux_alerts exit 1 fi +timestamp_puppet_log # Run puppet a second time and assert nothing changes. set +e @@ -165,10 +167,12 @@ RESULT=$? set -e if [ $RESULT -ne 0 ]; then print_header 'Second Puppet run is not idempotent.' + catch_puppet_failures print_header 'SELinux Alerts (2nd time)' catch_selinux_alerts exit 1 fi +timestamp_puppet_log print_header 'Prepare Tempest' # Tempest plugin tests require tempest-lib to be installed