From 6457561b21c17d102b6d7ccec459d0ddc3c1e9a0 Mon Sep 17 00:00:00 2001 From: stephane Date: Wed, 27 Jan 2016 09:04:16 -0800 Subject: [PATCH] Separate log collection into its own script Avoid having too much duplicated stuff by moving log collection into its own script as suggested in https://review.openstack.org/#/c/264366/1/scripts/test-bifrost-venv.sh@80 Change-Id: I2e322fc1f12e270c9407e7320d0d0e8c5452c4af --- scripts/collect-test-info.sh | 21 +++++++++++++++++++++ scripts/test-bifrost-build-images.sh | 20 +++----------------- scripts/test-bifrost.sh | 18 +++--------------- 3 files changed, 27 insertions(+), 32 deletions(-) create mode 100755 scripts/collect-test-info.sh diff --git a/scripts/collect-test-info.sh b/scripts/collect-test-info.sh new file mode 100755 index 000000000..6694a7396 --- /dev/null +++ b/scripts/collect-test-info.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -eux +set -o pipefail + +# Note(TheJulia): If there is a workspace variable, we want to utilize that as +# the preference of where to put logs +SCRIPT_HOME="$(cd "$(dirname "$0")" && pwd)" +LOG_LOCATION="${WORKSPACE:-${SCRIPT_HOME}/..}/logs" + +echo "Making logs directory and collecting logs." +[ -d ${LOG_LOCATION} ] || mkdir -p ${LOG_LOCATION} +sudo cp /var/log/libvirt/baremetal_logs/testvm1_console.log ${LOG_LOCATION} +sudo chown $USER ${LOG_LOCATION}/testvm1_console.log +dmesg &> ${LOG_LOCATION}/dmesg.log +sudo netstat -apn &> ${LOG_LOCATION}/netstat.log +sudo iptables -L -n -v &> ${LOG_LOCATION}/iptables.log +sudo cp /var/log/upstart/ironic-api.log ${LOG_LOCATION}/ +sudo chown $USER ${LOG_LOCATION}/ironic-api.log +sudo cp /var/log/upstart/ironic-conductor.log ${LOG_LOCATION}/ +sudo chown $USER ${LOG_LOCATION}/ironic-conductor.log diff --git a/scripts/test-bifrost-build-images.sh b/scripts/test-bifrost-build-images.sh index 80dad2142..922e7b06a 100755 --- a/scripts/test-bifrost-build-images.sh +++ b/scripts/test-bifrost-build-images.sh @@ -1,9 +1,5 @@ #!/bin/bash -# Note(TheJulia): If there is a workspace variable, we want to utilize that as -# the preference of where to put logs -LOG_LOCATION="${WORKSPACE:-..}/logs" - set -eux set -o pipefail export PYTHONUNBUFFERED=1 @@ -58,17 +54,7 @@ if [ $EXITCODE != 0 ]; then echo "Test failed. See logs folder" echo "****************************" fi -echo "Making logs directory and collecting logs." -mkdir ${LOG_LOCATION} -sudo cp /var/log/libvirt/baremetal_logs/testvm1_console.log ${LOG_LOCATION}/ -sudo chown $USER ${LOG_LOCATION}/testvm1_console.log -dmesg &> ${LOG_LOCATION}/dmesg.log -sudo netstat -apn &> ${LOG_LOCATION}/netstat.log -sudo iptables -L -n -v &> ${LOG_LOCATION}/iptables.log -sudo cp /var/log/upstart/ironic-api.log .${LOG_LOCATION}/ -sudo chown $USER ${LOG_LOCATION}/ironic-api.log -sudo cp /var/log/upstart/ironic-conductor.log ${LOG_LOCATION}/ -sudo chown $USER ${LOG_LOCATION}/ironic-conductor.log -sudo cp /var/log/upstart/ironic-inspector.log ${LOG_LOCATION}/ -sudo chown $USER ${LOG_LOCATION}/ironic-inspector.log + +$SCRIPT_HOME/collect-test-info.sh + exit $EXITCODE diff --git a/scripts/test-bifrost.sh b/scripts/test-bifrost.sh index 79333ec3e..5b437232a 100755 --- a/scripts/test-bifrost.sh +++ b/scripts/test-bifrost.sh @@ -1,9 +1,5 @@ #!/bin/bash -# Note(TheJulia): If there is a workspace variable, we want to utilize that as -# the preference of where to put logs -LOG_LOCATION="${WORKSPACE:-..}/logs" - set -eux set -o pipefail export PYTHONUNBUFFERED=1 @@ -57,15 +53,7 @@ if [ $EXITCODE != 0 ]; then echo "Test failed. See logs folder" echo "****************************" fi -echo "Making logs directory and collecting logs." -mkdir ${LOG_LOCATION} -sudo cp /var/log/libvirt/baremetal_logs/testvm1_console.log ${LOG_LOCATION} -sudo chown $USER ${LOG_LOCATION}/testvm1_console.log -dmesg &> ${LOG_LOCATION}/dmesg.log -sudo netstat -apn &> ${LOG_LOCATION}/netstat.log -sudo iptables -L -n -v &> ${LOG_LOCATION}/iptables.log -sudo cp /var/log/upstart/ironic-api.log ${LOG_LOCATION}/ -sudo chown $USER ${LOG_LOCATION}/ironic-api.log -sudo cp /var/log/upstart/ironic-conductor.log ${LOG_LOCATION}/ -sudo chown $USER ${LOG_LOCATION}/ironic-conductor.log + +$SCRIPT_HOME/collect-test-info.sh + exit $EXITCODE