Bug 1231200: produce treeherder-compatible errors; r?jmaher draft
authorDustin J. Mitchell <dustin@mozilla.com>
Thu, 10 Mar 2016 23:12:29 +0000
changeset 339247 818080f9af2c278ff9d3c637ada5a0fc5eb920a5
parent 338696 948d27968bbd26126d19434e95363fb92cc202ba
child 515953 411b5d919d3c7a66eaa9b2d24f93b80218eea267
push id12686
push userdmitchell@mozilla.com
push dateThu, 10 Mar 2016 23:19:30 +0000
reviewersjmaher
bugs1231200
milestone48.0a1
Bug 1231200: produce treeherder-compatible errors; r?jmaher MozReview-Commit-ID: CO4R2LRa23g
testing/docker/desktop-test/bin/test.sh
testing/taskcluster/scripts/builder/build-linux.sh
testing/taskcluster/scripts/tester/test-linux.sh
--- a/testing/docker/desktop-test/bin/test.sh
+++ b/testing/docker/desktop-test/bin/test.sh
@@ -10,21 +10,29 @@ set -x -e
 # TODO: when bug 1093833 is solved and tasks can run as non-root, reduce this
 # to a simple fail-if-root check
 if [ $(id -u) = 0 ]; then
     chown -R worker:worker /home/worker
     # drop privileges by re-running this script
     exec sudo -E -u worker bash /home/worker/bin/test.sh "${@}"
 fi
 
+fail() {
+    echo # make sure error message is on a new line
+    echo "[test.sh:error]" "${@}"
+    exit 1
+}
+
 ####
 # Now get the test-linux.sh script from the given Gecko tree and run it with
 # the same arguments.
 ####
 
 [ -d $WORKSPACE ] || mkdir -p $WORKSPACE
 cd $WORKSPACE
 
 script=testing/taskcluster/scripts/tester/test-linux.sh
 url=${GECKO_HEAD_REPOSITORY}/raw-file/${GECKO_HEAD_REV}/${script}
-curl --fail -o ./test-linux.sh --retry 10 $url
+if ! curl --fail -o ./test-linux.sh --retry 10 $url; then
+    fail "failed downloading test-linux.sh from ${GECKO_HEAD_REPOSITORY}"
+fi
 chmod +x ./test-linux.sh
 exec ./test-linux.sh "${@}"
--- a/testing/taskcluster/scripts/builder/build-linux.sh
+++ b/testing/taskcluster/scripts/builder/build-linux.sh
@@ -23,31 +23,37 @@ echo "running as" $(id)
 
 : WORKSPACE                     ${WORKSPACE:=/home/worker/workspace}
 
 # some linux variants, e.g. b2gdroid, require gaia
 : CHECKOUT_GAIA                      ${CHECKOUT_GAIA:=false}
 
 set -v
 
+fail() {
+    echo # make sure error message is on a new line
+    echo "[build-linux.sh:error]" "${@}"
+    exit 1
+}
+
 export MOZ_CRASHREPORTER_NO_REPORT=1
 export MOZ_OBJDIR=obj-firefox
 export MOZ_SYMBOLS_EXTRA_BUILDID=linux64
 export TINDERBOX_OUTPUT=1
 
 # use "simple" package names so that they can be hard-coded in the task's
 # extras.locations
 export MOZ_SIMPLE_PACKAGE_NAME=target
 
 # Ensure that in tree libraries can be found
 export LIBRARY_PATH=$LIBRARY_PATH:$WORKSPACE/src/obj-firefox:$WORKSPACE/src/gcc/lib64
 
 # test required parameters are supplied
-if [[ -z ${MOZHARNESS_SCRIPT} ]]; then exit 1; fi
-if [[ -z ${MOZHARNESS_CONFIG} ]]; then exit 1; fi
+if [[ -z ${MOZHARNESS_SCRIPT} ]]; then fail "MOZHARNESS_SCRIPT is not set"; fi
+if [[ -z ${MOZHARNESS_CONFIG} ]]; then fail "MOZHARNESS_CONFIG is not set"; fi
 
 cleanup() {
     local rv=$?
     if [ -n "$xvfb_pid" ]; then
         kill $xvfb_pid || true
     fi
     exit $rv
 }
@@ -69,18 +75,19 @@ if $NEED_XVFB; then
     until [ $retry_count -gt $max_retries ]; do
         xvinfo || xvfb_test=$?
         if [ $xvfb_test != 255 ]; then
             retry_count=$(($max_retries + 1))
         else
             retry_count=$(($retry_count + 1))
             echo "Failed to start Xvfb, retry: $retry_count"
             sleep 2
-        fi done
-    if [ $xvfb_test == 255 ]; then exit 255; fi
+        fi
+    done
+    if [ $xvfb_test == 255 ]; then fail "xvfb did not start properly"; fi
 fi
 
 # set up mozharness configuration, via command line, env, etc.
 
 debug_flag=""
 if [ 0$DEBUG -ne 0 ]; then
   debug_flag='--debug'
 fi
--- a/testing/taskcluster/scripts/tester/test-linux.sh
+++ b/testing/taskcluster/scripts/tester/test-linux.sh
@@ -19,20 +19,26 @@ echo "running as" $(id)
 : START_VNC                     ${START_VNC:=false}
 : SKIP_MOZHARNESS_RUN           ${SKIP_MOZHARNESS_RUN:=false}
 : WORKSPACE                     ${WORKSPACE:=/home/worker/workspace}
 : mozharness args               "${@}"
 
 set -v
 cd $WORKSPACE
 
+fail() {
+    echo # make sure error message is on a new line
+    echo "[test-linux.sh:error]" "${@}"
+    exit 1
+}
+
 # test required parameters are supplied
-if [[ -z ${MOZHARNESS_URL} ]]; then exit 1; fi
-if [[ -z ${MOZHARNESS_SCRIPT} ]]; then exit 1; fi
-if [[ -z ${MOZHARNESS_CONFIG} ]]; then exit 1; fi
+if [[ -z ${MOZHARNESS_URL} ]]; then fail "MOZHARNESS_URL is not set"; fi
+if [[ -z ${MOZHARNESS_SCRIPT} ]]; then fail "MOZHARNESS_SCRIPT is not set"; fi
+if [[ -z ${MOZHARNESS_CONFIG} ]]; then fail "MOZHARNESS_CONFIG is not set"; fi
 
 mkdir -p ~/artifacts/public
 
 cleanup() {
     local rv=$?
     if [[ -s /home/worker/.xsession-errors ]]; then
       # To share X issues
       cp /home/worker/.xsession-errors ~/artifacts/public/xsession-errors.log
@@ -42,24 +48,25 @@ cleanup() {
     if [ -n "$xvfb_pid" ] && [ $START_VNC == false ] ; then
         kill $xvfb_pid || true
     fi
     exit $rv
 }
 trap cleanup EXIT INT
 
 # Unzip the mozharness ZIP file created by the build task
-curl --fail -o mozharness.zip --retry 10 -L $MOZHARNESS_URL
+if ! curl --fail -o mozharness.zip --retry 10 -L $MOZHARNESS_URL; then
+    fail "failed to download mozharness zip"
+fi
 rm -rf mozharness
 unzip -q mozharness.zip
 rm mozharness.zip
 
 if ! [ -d mozharness ]; then
-    echo "mozharness zip did not contain mozharness/"
-    exit 1
+    fail "mozharness zip did not contain mozharness/"
 fi
 
 # start up the pulseaudio daemon.  Note that it's important this occur
 # before the Xvfb startup.
 if $NEED_PULSEAUDIO; then
     pulseaudio --fail --daemonize --start
     pactl load-module module-null-sink
 fi
@@ -80,18 +87,19 @@ if $NEED_XVFB; then
     until [ $retry_count -gt $max_retries ]; do
         xvinfo || xvfb_test=$?
         if [ $xvfb_test != 255 ]; then
             retry_count=$(($max_retries + 1))
         else
             retry_count=$(($retry_count + 1))
             echo "Failed to start Xvfb, retry: $retry_count"
             sleep 2
-        fi done
-    if [ $xvfb_test == 255 ]; then exit 255; fi
+        fi
+    done
+    if [ $xvfb_test == 255 ]; then fail "xvfb did not start properly"; fi
 fi
 
 if $START_VNC; then
     x11vnc > ~/artifacts/public/x11vnc.log 2>&1 &
 fi
 
 if $NEED_WINDOW_MANAGER; then
     # This is read by xsession to select the window manager