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