Bug 1250904 - Pause interactive jobs before running tests
MozReview-Commit-ID: DzBlVUs9R8I
--- a/testing/docker/desktop-test/Dockerfile
+++ b/testing/docker/desktop-test/Dockerfile
@@ -1,17 +1,16 @@
FROM taskcluster/ubuntu1204-test-upd:0.1.9.20160329211700
MAINTAINER Jonas Finnemann Jensen <jopsen@gmail.com>
# Add utilities and configuration
COPY dot-config /home/worker/.config
COPY dot-pulse /home/worker/.pulse
COPY bin /home/worker/bin
-# This removes the requirement of a developer to call it with bash
-RUN chmod +x bin/test.sh
+RUN chmod +x bin/*
# TODO: remove this when buildbot is gone
COPY buildprops.json /home/worker/buildprops.json
COPY tc-vcs-config.yml /etc/taskcluster-vcs.yml
# TODO: remove
ADD https://raw.githubusercontent.com/taskcluster/buildbot-step/master/buildbot_step /home/worker/bin/buildbot_step
RUN chmod u+x /home/worker/bin/buildbot_step
@@ -58,10 +57,15 @@ EXPOSE 5900
ENV DISPLAY :0
# Disable apport (Ubuntu app crash reporter) to avoid stealing focus from test runs
ADD apport /etc/default/apport
# Disable font antialiasing for now to match releng's setup
ADD fonts.conf /home/worker/.fonts.conf
+# Set up interactive shell
+ADD motd /etc/taskcluster-motd
+ADD taskcluster-interactive-shell /bin/taskcluster-interactive-shell
+RUN chmod +x /bin/taskcluster-interactive-shell
+
# Set a default command useful for debugging
CMD ["/bin/bash", "--login"]
new file mode 100755
--- /dev/null
+++ b/testing/docker/desktop-test/bin/run-wizard
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this,
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import print_function, unicode_literals
+
+import os
+import subprocess
+import sys
+from textwrap import wrap
+
+
+def resume():
+ subprocess.call(['run-mozharness'])
+
+
+def setup():
+ subprocess.call(['run-mozharness', '--no-run-tests'])
+ print("Mozharness has finished downloading the build and "
+ "tests to {}.".format(os.path.join(os.getcwd(), 'build')))
+
+
+def clone():
+ repo = os.environ['GECKO_HEAD_REPOSITORY']
+ rev = os.environ['GECKO_HEAD_REV']
+ clone_path = os.path.expanduser(os.path.join('~', 'gecko'))
+ subprocess.call(['hg', 'clone', '-u', rev, repo, clone_path])
+ print("Finished cloning {} to {} at revision {}.".format(
+ repo, clone_path, rev))
+
+
+def exit():
+ pass
+
+
+OPTIONS = [
+ ('Resume task', resume,
+ "Resume the original task without modification. This can be useful for "
+ "passively monitoring it from another shell."),
+ ('Setup task', setup,
+ "Setup the task (download the application and tests) but don't run the "
+ "tests just yet. The tests can be run later with a custom configuration "
+ "via mach or mozharness."),
+ ('Clone gecko', clone,
+ "Perform a clone of gecko using the task's repo and update it to the "
+ "task's revision."),
+ ('Exit', exit, "Exit this wizard and return to the shell.")
+]
+
+
+def _fmt_options():
+ max_line_len = 60
+ max_name_len = max(len(o[0]) for o in OPTIONS)
+
+ # TODO Pad will be off if there are more than 9 options.
+ pad = ' ' * (max_name_len+6)
+
+ msg = []
+ for i, (name, _, desc) in enumerate(OPTIONS):
+ desc = wrap(desc, width=max_line_len)
+ desc = [desc[0]] + [pad + l for l in desc[1:]]
+
+ optstr = '{}) {} - {}\n'.format(
+ i+1, name.ljust(max_name_len), '\n'.join(desc))
+ msg.append(optstr)
+ msg.append("Select one of the above options: ")
+ return '\n'.join(msg)
+
+
+def wizard():
+ print("This wizard can help you get started with some common debugging "
+ "workflows.\nWhat would you like to do?\n")
+ print(_fmt_options(), end="")
+ choice = None
+ while True:
+ choice = raw_input().decode('utf8')
+ try:
+ choice = int(choice)-1
+ if 0 <= choice < len(OPTIONS):
+ break
+ except ValueError:
+ pass
+
+ print("Must provide an integer from 1-{}:".format(len(OPTIONS)))
+
+ func = OPTIONS[choice][1]
+ ret = func()
+
+ print("Use the 'run-wizard' command to start this wizard again.")
+ return ret
+
+
+if __name__ == '__main__':
+ sys.exit(wizard())
new file mode 100644
--- /dev/null
+++ b/testing/docker/desktop-test/motd
@@ -0,0 +1,5 @@
+Welcome to your taskcluster interactive shell! The regularly scheduled task
+has been paused to give you a chance to set up your debugging environment.
+
+For your convenience, the exact mozharness command needed for this task can
+be invoked using the 'run-mozharness' command.
new file mode 100644
--- /dev/null
+++ b/testing/docker/desktop-test/taskcluster-interactive-shell
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+/home/worker/bin/run-wizard;
+
+SPAWN="$SHELL";
+
+if [ "$SHELL" = "bash" ]; then
+ SPAWN="bash -li";
+fi;
+
+exec $SPAWN;
--- a/testing/taskcluster/scripts/tester/test-linux.sh
+++ b/testing/taskcluster/scripts/tester/test-linux.sh
@@ -12,17 +12,16 @@ 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}
-: 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
@@ -125,23 +124,28 @@ fi
# source it is running; tc-vcs obscures this a little, but we can provide
# it directly.
export MOZ_SOURCE_REPO="${GECKO_HEAD_REPOSITORY}"
export MOZ_SOURCE_CHANGESET="${GECKO_HEAD_REV}"
# support multiple, space delimited, config files
config_cmds=""
for cfg in $MOZHARNESS_CONFIG; do
- config_cmds="${config_cmds} --config-file ${cfg}"
+ config_cmds="${config_cmds} --config-file $WORKSPACE/${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
+mozharness_bin="/home/worker/bin/run-mozharness"
+
+# Save the computed mozharness command to a binary which is useful
+# for interactive mode.
+echo -e "#!/usr/bin/env bash
+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
# 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} "${@}"
+ status=$(${mozharness_bin});
+ exit status
fi