Bug 1237987 - Update mulet mochitests to use tester image r=wcosta
authorGregory Arndt <garndt@mozilla.com>
Fri, 08 Jan 2016 11:26:28 -0600
changeset 281030 7c56c933b75b2fd91b23a96ccdf728fabe6181f7
parent 281029 ea55ec4607187e63985252c4201c28b0faafc5ff
child 281031 4974e781925f30371f214d81e262aef0162e3367
push id29926
push userkwierso@gmail.com
push dateFri, 22 Jan 2016 01:10:30 +0000
treeherdermozilla-central@7415cfea5ff3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswcosta
bugs1237987
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1237987 - Update mulet mochitests to use tester image r=wcosta
testing/docker/base-test/Dockerfile
testing/docker/base-test/VERSION
testing/docker/tester/Dockerfile
testing/docker/tester/VERSION
testing/docker/tester/bin/test.sh
testing/taskcluster/scripts/tester/test-mulet.sh
testing/taskcluster/tasks/tests/mulet_mochitests.yml
--- a/testing/docker/base-test/Dockerfile
+++ b/testing/docker/base-test/Dockerfile
@@ -1,15 +1,18 @@
 FROM          quay.io/mozilla/ubuntu:12.04
 MAINTAINER    Jonas Finnemann Jensen <jopsen@gmail.com>
 
 
 COPY sources.list /etc/apt/sources.list
 
 RUN useradd -d /home/worker -s /bin/bash -m worker
+# allow the worker user to access video devices
+RUN usermod -a -G video worker
+
 RUN apt-get update && apt-get install -y --force-yes \
   alsa-base \
   alsa-utils \
   autoconf2.13 \
   bluez-alsa \
   bluez-alsa:i386 \
   bluez-cups \
   bluez-gstreamer \
@@ -106,16 +109,17 @@ RUN apt-get update && apt-get install -y
   ttf-paktype \
   ttf-punjabi-fonts \
   ttf-sazanami-mincho \
   unzip \
   uuid \
   vim \
   wget \
   x11-xserver-utils \
+  x11-utils \
   xvfb \
   yasm \
   zip
 
 ENV NODE_VERSION v4.2.2
 RUN cd /usr/local/ && \
     curl https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-linux-x64.tar.gz | tar -xz --strip-components 1 && \
     node -v
--- a/testing/docker/base-test/VERSION
+++ b/testing/docker/base-test/VERSION
@@ -1,1 +1,1 @@
-0.1.2
+0.1.3
--- a/testing/docker/tester/Dockerfile
+++ b/testing/docker/tester/Dockerfile
@@ -1,9 +1,9 @@
-FROM          taskcluster/base-test:0.1.2
+FROM          taskcluster/base-test:0.1.3
 MAINTAINER    Jonas Finnemann Jensen <jopsen@gmail.com>
 
 # Add utilities and configuration
 COPY           b2g-desktop-config.py         /home/worker/b2g-desktop-config.py
 COPY           dot-config                    /home/worker/.config
 COPY           dot-pulse                     /home/worker/.pulse
 COPY           bin                           /home/worker/bin
 COPY           mozharness_configs            /home/worker/mozharness_configs
--- a/testing/docker/tester/VERSION
+++ b/testing/docker/tester/VERSION
@@ -1,1 +1,1 @@
-0.4.5
+0.4.6
new file mode 100644
--- /dev/null
+++ b/testing/docker/tester/bin/test.sh
@@ -0,0 +1,31 @@
+#! /bin/bash -vex
+
+set -x -e
+
+: GECKO_HEAD_REPOSITORY         ${GECKO_HEAD_REPOSITORY:=https://hg.mozilla.org/mozilla-central}
+: GECKO_HEAD_REV                ${GECKO_HEAD_REV:=default}
+: WORKSPACE                     ${WORKSPACE:=/home/worker/workspace}
+
+
+# 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
+
+####
+# 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-mulet.sh
+url=${GECKO_HEAD_REPOSITORY}/raw-file/${GECKO_HEAD_REV}/${script}
+curl --fail -o ./test-mulet.sh --retry 10 $url
+chmod +x ./test-mulet.sh
+exec ./test-mulet.sh "${@}"
+
new file mode 100644
--- /dev/null
+++ b/testing/taskcluster/scripts/tester/test-mulet.sh
@@ -0,0 +1,99 @@
+#! /bin/bash -xe
+
+set -x -e
+
+echo "running as" $(id)
+
+####
+# Taskcluster friendly wrapper for performing fx desktop tests via mozharness.
+####
+
+# Inputs, with defaults
+
+: MOZHARNESS_URL                ${MOZHARNESS_URL}
+: MOZHARNESS_SCRIPT             ${MOZHARNESS_SCRIPT}
+: MOZHARNESS_CONFIG             ${MOZHARNESS_CONFIG}
+: NEED_XVFB                     ${NEED_XVFB:=true}
+: NEED_PULSEAUDIO               ${NEED_PULSEAUDIO:=false}
+: SKIP_MOZHARNESS_RUN           ${SKIP_MOZHARNESS_RUN:=false}
+: WORKSPACE                     ${WORKSPACE:=/home/worker/workspace}
+: mozharness args               "${@}"
+
+set -v
+cd $WORKSPACE
+
+# 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
+
+mkdir -p ~/artifacts/public
+
+cleanup() {
+    if [ -n "$xvfb_pid" ]; then
+        kill $xvfb_pid || true
+    fi
+}
+trap cleanup EXIT INT
+
+# Unzip the mozharness ZIP file created by the build task
+curl --fail -o mozharness.zip --retry 10 -L $MOZHARNESS_URL
+rm -rf mozharness
+unzip -q mozharness.zip
+rm mozharness.zip
+
+if ! [ -d mozharness ]; then
+    echo "mozharness zip did not contain mozharness/"
+    exit 1
+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
+    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
+        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
+
+# support multiple, space delimited, config files
+config_cmds=""
+for cfg in $MOZHARNESS_CONFIG; do
+  config_cmds="${config_cmds} --config-file ${cfg}"
+done
+
+if [ ${SKIP_MOZHARNESS_RUN} == true ]; then
+  # Skipping Mozharness is to allow the developer start the window manager
+  # properly and letting them change the execution of Mozharness without
+  # exiting the container
+  echo "We skipped running Mozharness."
+  echo "Make sure you export DISPLAY=:0 before calling Mozharness."
+  echo "Don't forget to call it with 'sudo -E -u worker'."
+else
+  # run the given mozharness script and configs, but pass the rest of the
+  # arguments in from our own invocation
+  python2.7 $WORKSPACE/${MOZHARNESS_SCRIPT} ${config_cmds} "${@}"
+fi
--- a/testing/taskcluster/tasks/tests/mulet_mochitests.yml
+++ b/testing/taskcluster/tasks/tests/mulet_mochitests.yml
@@ -6,26 +6,28 @@ task:
     name: '[TC] Mulet Mochitests ( {{chunk}} )'
     description: Mulet Mochitest run {{chunk}}
   scopes:
     - 'docker-worker:cache:level-{{level}}-{{project}}-tc-vcs'
     - 'docker-worker:cache:level-{{level}}-{{project}}-dotcache'
     - 'docker-worker:capability:device:loopbackVideo'
     - 'docker-worker:capability:device:loopbackAudio'
   payload:
-    image: '{{#docker_image}}desktop-test{{/docker_image}}'
+    image: '{{#docker_image}}tester{{/docker_image}}'
     cache:
       # So pip installs are cached...
       level-{{level}}-{{project}}-dotcache: /home/worker/.cache
       level-{{level}}-{{project}}-tc-vcs: '/home/worker/.tc-vcs'
     capabilities:
       devices:
         loopbackVideo: true
         loopbackAudio: true
     env:
+      GECKO_HEAD_REPOSITORY: '{{{head_repository}}}'
+      GECKO_HEAD_REV: '{{{head_rev}}}'
       NEED_XVFB: true
       NEED_PULSEAUDIO: true
       MOZHARNESS_SCRIPT: 'mozharness/scripts/desktop_unittest.py'
       MOZHARNESS_CONFIG: >
         mozharness/configs/unittests/linux_unittest.py
         mozharness/configs/remove_executables.py
     command:
       - bash