diff --git a/devstack-vm-gate-wrap.sh b/devstack-vm-gate-wrap.sh index 12f1cdab..c0959189 100755 --- a/devstack-vm-gate-wrap.sh +++ b/devstack-vm-gate-wrap.sh @@ -258,15 +258,15 @@ ip neighbor show echo "Available disk space on this host:" df -h -setup_host &> $WORKSPACE/logs/devstack-gate-setup-host.txt +tsfilter setup_host &> $WORKSPACE/logs/devstack-gate-setup-host.txt if [ "$DEVSTACK_GATE_GRENADE" -eq "1" -o "$DEVSTACK_GATE_GRENADE_FORWARD" -eq "1" ]; then - setup_workspace $GRENADE_NEW_BRANCH $BASE/new &> \ + tsfilter setup_workspace $GRENADE_NEW_BRANCH $BASE/new &> \ $WORKSPACE/logs/devstack-gate-setup-workspace-new.txt - setup_workspace $GRENADE_OLD_BRANCH $BASE/old &> \ + tsfilter setup_workspace $GRENADE_OLD_BRANCH $BASE/old &> \ $WORKSPACE/logs/devstack-gate-setup-workspace-old.txt else - setup_workspace $OVERRIDE_ZUUL_BRANCH $BASE/new &> \ + tsfilter setup_workspace $OVERRIDE_ZUUL_BRANCH $BASE/new &> \ $WORKSPACE/logs/devstack-gate-setup-workspace-new.txt fi @@ -279,7 +279,7 @@ fi # Run pre test hook if we have one if function_exists "pre_test_hook"; then set -o xtrace - pre_test_hook 2>&1 | tee $WORKSPACE/devstack-gate-pre-test-hook.txt + tsfilter pre_test_hook | tee $WORKSPACE/devstack-gate-pre-test-hook.txt sudo mv $WORKSPACE/devstack-gate-pre-test-hook.txt $BASE/logs/ set +o xtrace fi @@ -292,7 +292,7 @@ RETVAL=$GATE_RETVAL # Run post test hook if we have one if [ $GATE_RETVAL -eq 0 ] && function_exists "post_test_hook"; then set -o xtrace -o pipefail - post_test_hook 2>&1 | tee $WORKSPACE/devstack-gate-post-test-hook.txt + tsfilter post_test_hook | tee $WORKSPACE/devstack-gate-post-test-hook.txt RETVAL=$? sudo mv $WORKSPACE/devstack-gate-post-test-hook.txt $BASE/logs/ set +o xtrace +o pipefail @@ -304,7 +304,7 @@ if [ $GATE_RETVAL -eq 137 ] && [ -f $WORKSPACE/gate.pid ] ; then sudo kill -s 9 -${GATEPID} fi -cleanup_host &> $WORKSPACE/devstack-gate-cleanup-host.txt +tsfilter cleanup_host &> $WORKSPACE/devstack-gate-cleanup-host.txt sudo mv $WORKSPACE/devstack-gate-cleanup-host.txt $BASE/logs/ exit $RETVAL diff --git a/functions.sh b/functions.sh index dc706431..9001ea50 100644 --- a/functions.sh +++ b/functions.sh @@ -20,6 +20,19 @@ function function_exists { type $1 2>/dev/null | grep -q 'is a function' } +# awk filter to timestamp the stream, including stderr merging +function tsfilter { + $@ 2>&1 | awk ' + { + cmd ="date +\"%Y-%m-%d %H:%M:%S.%3N | \"" + cmd | getline now + close("date +\"%Y-%m-%d %H:%M:%S.%3N | \"") + sub(/^/, now) + print + fflush() + }' +} + # Attempt to fetch a git ref for a project, if that ref is not empty function git_fetch_at_ref { local project=$1