Bug 1263815 - retry xvfb startup. r?dustin draft
authorJoel Maher <jmaher@mozilla.com>
Mon, 18 Jul 2016 06:56:06 +0300
changeset 388830 222027217af7c64bf6822a513074954b0f4abf2c
parent 388829 fccc189b56d8809b7258da4f7685ea47fc1493a3
child 525608 da69ff8ac9d453a6d9542546c21c517cacaeb51f
push id23244
push userjmaher@mozilla.com
push dateMon, 18 Jul 2016 03:56:29 +0000
reviewersdustin
bugs1263815
milestone50.0a1
Bug 1263815 - retry xvfb startup. r?dustin MozReview-Commit-ID: 95IDKC1vHPx
taskcluster/scripts/tester/test-linux.sh
--- a/taskcluster/scripts/tester/test-linux.sh
+++ b/taskcluster/scripts/tester/test-linux.sh
@@ -65,40 +65,63 @@ 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
 
-# run XVfb in the background, if necessary
-if $NEED_XVFB; then
+start_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
+    max_retries=5
     xvfb_test=0
     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 fail "xvfb did not start properly"; fi
+    if [ $xvfb_test == 255 ]; then
+        return false
+    else
+        return true
+    fi
+done
+}
+
+# run XVfb in the background, if necessary
+if $NEED_XVFB; then
+    xvfb_retry_count=0
+    xvfb_max_retries=2
+    success=false
+    export DISPLAY=:0
+    until [ $xvfb_retry_count -gt $xvfb_max_retries ]; do
+        success = start_xvfb()
+        if success; then
+            xvfb_retry_count=$(($xvfb_max_retries + 1))
+        else
+            xvfb_retry_count=$(($xvfb_retry_count + 1))
+        fi
+        sleep 10
+    done
+    if [ ! success ]; then
+        fail "Could not start xvfb after ${xvfb_max_retries} attempts"
+    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