Bug 1285582 - Make sure Xvfb is running for interactive tasks, r=dustin
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Mon, 11 Jul 2016 11:14:46 -0400
changeset 331767 70b5b544b2453f4ca6860f1879784eb56f66e88a
parent 331766 8f1980fa5bee8fe994c59dbb494e8da561c1145c
child 331768 a5eb9b47ea45aa1fbde63e49a5aa75ba207ebc67
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdustin
bugs1285582
milestone50.0a1
Bug 1285582 - Make sure Xvfb is running for interactive tasks, r=dustin Normally we start Xvfb as a background task, then run the tests from the same script. However, in interactive mode we were starting Xvfb, the script would exit, and then we would potentially run tests later on from another script. Unforunately this meant that Xvfb was dying with the first script and tests would fail. This patch runs Xvfb in a screen session so that it will still be available later on when running an interactive shell. MozReview-Commit-ID: EduVyglo2BG
taskcluster/scripts/tester/test-ubuntu1204.sh
--- a/taskcluster/scripts/tester/test-ubuntu1204.sh
+++ b/taskcluster/scripts/tester/test-ubuntu1204.sh
@@ -12,16 +12,17 @@ echo "running as" $(id)
 
 : MOZHARNESS_URL                ${MOZHARNESS_URL}
 : MOZHARNESS_SCRIPT             ${MOZHARNESS_SCRIPT}
 : MOZHARNESS_CONFIG             ${MOZHARNESS_CONFIG}
 : NEED_XVFB                     ${NEED_XVFB:=true}
 : NEED_WINDOW_MANAGER           ${NEED_WINDOW_MANAGER:=false}
 : NEED_PULSEAUDIO               ${NEED_PULSEAUDIO:=false}
 : START_VNC                     ${START_VNC:=false}
+: TASKCLUSTER_INTERACTIVE       ${TASKCLUSTER_INTERACTIVE:=false}
 : WORKSPACE                     ${WORKSPACE:=/home/worker/workspace}
 : mozharness args               "${@}"
 
 set -v
 cd $WORKSPACE
 
 fail() {
     echo # make sure error message is on a new line
@@ -37,20 +38,22 @@ if [[ -z ${MOZHARNESS_CONFIG} ]]; then f
 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
     fi
-    # When you call this script with START_VNC we make sure we
-    # don't kill xvfb so you don't lose your VNC connection
-    if [ -n "$xvfb_pid" ] && [ $START_VNC == false ] ; then
+    # When you call this script with START_VNC or TASKCLUSTER_INTERACTIVE
+    # we make sure we don't kill xvfb so you don't lose your connection
+    xvfb_pid=`pidof Xvfb`
+    if [ -n "$xvfb_pid" ] && [ $START_VNC == false ] && [ $TASKCLUSTER_INTERACTIVE == false ] ; then
         kill $xvfb_pid || true
+        screen -XS xvfb quit || true
     fi
     exit $rv
 }
 trap cleanup EXIT INT
 
 # Unzip the mozharness ZIP file created by the build task
 if ! curl --fail -o mozharness.zip --retry 10 -L $MOZHARNESS_URL; then
     fail "failed to download mozharness zip"
@@ -65,22 +68,21 @@ fi
 
 # start up the pulseaudio daemon.  Note that it's important this occur
 # before the Xvfb startup for ubuntu 12.04, not for 16.04
 if $NEED_PULSEAUDIO; then
     pulseaudio --fail --daemonize --start
     pactl load-module module-null-sink
 fi
 
-# run XVfb in the background, if necessary
+# run Xvfb in the background, if necessary
 if $NEED_XVFB; then
-    Xvfb :0 -nolisten tcp -screen 0 1600x1200x24 \
-       > ~/artifacts/public/xvfb.log 2>&1 &
+    screen -dmS xvfb Xvfb :0 -nolisten tcp -screen 0 1600x1200x24 \
+       > ~/artifacts/public/xvfb.log 2>&1
     export DISPLAY=:0
-    xvfb_pid=$!
     # Only error code 255 matters, because it signifies that no
     # display could be opened. As long as we can open the display
     # tests should work. We'll retry a few times with a sleep before
     # failing.
     retry_count=0
     max_retries=2
     xvfb_test=0
     until [ $retry_count -gt $max_retries ]; do
@@ -141,13 +143,13 @@ echo -e "#!/usr/bin/env bash
 # the current working directory, see bug 1279237
 cd $WORKSPACE
 cmd=\"python2.7 $WORKSPACE/${MOZHARNESS_SCRIPT} ${config_cmds} ${@} \${@}\"
 echo \"Running: \${cmd}\"
 exec \${cmd}" > ${mozharness_bin}
 chmod +x ${mozharness_bin}
 
 # In interactive mode, the user will be prompted with options for what to do.
-if [ "$TASKCLUSTER_INTERACTIVE" != "true" ]; then
+if ! $TASKCLUSTER_INTERACTIVE; then
   # run the given mozharness script and configs, but pass the rest of the
   # arguments in from our own invocation
   ${mozharness_bin};
 fi