Bug 1227367 - Add marionette-harness TaskCluster task; r?dustin
marionette-harness is implemented as a "generic" task and
can be triggered as follows:
try: -p linux64_tc -j marionette-harness -u none -t none
The Marionette harness tests do not depend on a browser build,
they only exercise Python code.
Add option to testing/docker/desktop-build/bin/build.sh to
execute any in-tree script instead of only `build-linux.sh`.
This feature is used to call
testing/taskcluster/scripts/tester/harness-test-linux.sh, which
in turn executes the mozharness script specified in the environment.
MozReview-Commit-ID: H08v8ow4p8q
--- a/testing/docker/desktop-build/bin/build.sh
+++ b/testing/docker/desktop-build/bin/build.sh
@@ -1,29 +1,36 @@
#! /bin/bash -vex
set -x -e -v
+# Relative path to in-tree script
+: JOB_SCRIPT ${JOB_SCRIPT:=testing/taskcluster/scripts/builder/build-linux.sh}
+
+script_args="${@}"
+
# 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
# each of the caches we have mounted are owned by root, so update that ownership
# to 'worker'
for cache in /home/worker/.tc-vcs /home/worker/workspace /home/worker/tooltool-cache; do
if [ -d $cache ]; then
# -R probably isn't necessary forever, but it fixes some poisoned
# caches for now
chown -R worker:worker $cache
fi
done
# ..then drop privileges by re-running this script
- exec su worker /home/worker/bin/build.sh
+ exec su worker -c "/home/worker/bin/build.sh $script_args"
fi
####
# The default build works for any fx_desktop_build based mozharness job:
-# via linux-build.sh
+# via build-linux.sh
####
. $HOME/bin/checkout-sources.sh
-. $WORKSPACE/build/src/testing/taskcluster/scripts/builder/build-linux.sh
+script=$WORKSPACE/build/src/$JOB_SCRIPT
+chmod +x $script
+exec $script $script_args
new file mode 100644
--- /dev/null
+++ b/testing/taskcluster/scripts/tester/harness-test-linux.sh
@@ -0,0 +1,40 @@
+#! /bin/bash -vex
+
+set -x -e
+
+echo "running as" $(id)
+
+####
+# Taskcluster friendly wrapper for running a script in
+# testing/mozharness/scripts in a source checkout (no build).
+# Example use: Python-only harness unit tests
+####
+
+: WORKSPACE ${WORKSPACE:=/home/worker/workspace}
+: SRC_ROOT ${SRC_ROOT:=$WORKSPACE/build/src}
+# These paths should be relative to $SRC_ROOT
+: MOZHARNESS_SCRIPT ${MOZHARNESS_SCRIPT}
+: MOZHARNESS_CONFIG ${MOZHARNESS_CONFIG}
+: mozharness args "${@}"
+
+set -v
+cd $WORKSPACE
+
+fail() {
+ echo # make sure error message is on a new line
+ echo "[harness-test-linux.sh:error]" "${@}"
+ exit 1
+}
+
+if [[ -z ${MOZHARNESS_SCRIPT} ]]; then fail "MOZHARNESS_SCRIPT is not set"; fi
+
+# support multiple, space delimited, config files
+config_cmds=""
+for cfg in $MOZHARNESS_CONFIG; do
+ config_cmds="${config_cmds} --config-file ${SRC_ROOT}/${cfg}"
+done
+
+python2.7 $SRC_ROOT/${MOZHARNESS_SCRIPT} ${config_cmds} "${@}"
+
+
+
--- a/testing/taskcluster/tasks/branches/base_jobs.yml
+++ b/testing/taskcluster/tasks/branches/base_jobs.yml
@@ -311,8 +311,14 @@ tasks:
- 'mobile/android/**/*.xml' # Manifest & android resources
- 'mobile/android/**/build.gradle'
mozharness:
task: tasks/tests/mozharness-gecko.yml
root: true
when:
file_patterns:
- 'testing/mozharness/**'
+ marionette-harness:
+ task: tasks/tests/harness_marionette.yml
+ root: true
+ when:
+ file_patterns:
+ - 'testing/marionette/harness/**'
new file mode 100644
--- /dev/null
+++ b/testing/taskcluster/tasks/harness_test.yml
@@ -0,0 +1,70 @@
+# This is the "base" task which contains the common values all harness
+# unit tests must provide.
+# It's inspired by build.yml, since harness unit tests just depend on
+# checking out the source tree.
+---
+taskId: {{build_slugid}}
+
+task:
+ created: '{{now}}'
+ deadline: '{{#from_now}}24 hours{{/from_now}}'
+ metadata:
+ source: '{{source}}'
+ owner: mozilla-taskcluster-maintenance@mozilla.com
+ tags:
+ createdForUser: {{owner}}
+ workerType: desktop-test-xlarge
+ provisionerId: aws-provisioner-v1
+ schedulerId: task-graph-scheduler
+ routes:
+ - 'index.gecko.v1.{{project}}.revision.linux.{{head_rev}}.{{build_name}}'
+ - 'index.gecko.v1.{{project}}.latest.linux.{{build_name}}'
+ scopes:
+ - 'docker-worker:cache:level-{{level}}-{{project}}-tc-vcs'
+ - 'docker-worker:cache:level-{{level}}-{{project}}-test-workspace'
+ payload:
+ # 30 minutes should be more than enough for harness unit tests
+ maxRunTime: 1800
+ image:
+ type: 'task-image'
+ path: 'public/image.tar'
+ taskId: '{{#task_id_for_image}}desktop-build{{/task_id_for_image}}'
+ cache:
+ # The taskcluster-vcs tooling stores the large clone caches in this
+ # directory and will reuse them for new requests this saves about 20s~
+ # and is the most generic cache possible.
+ level-{{level}}-{{project}}-tc-vcs: '/home/worker/.tc-vcs'
+ level-{{level}}-{{project}}-test-workspace: '/home/worker/workspace'
+ artifacts:
+ 'public/logs/':
+ type: directory
+ path: '/home/worker/workspace/build/upload/logs/'
+ expires: '{{#from_now}}1 year{{/from_now}}'
+ command:
+ - bash
+ - /home/worker/bin/build.sh
+ env:
+ # Common environment variables for checking out gecko
+ GECKO_BASE_REPOSITORY: '{{base_repository}}'
+ GECKO_HEAD_REPOSITORY: '{{head_repository}}'
+ GECKO_HEAD_REV: '{{head_rev}}'
+ GECKO_HEAD_REF: '{{head_ref}}'
+ TOOLTOOL_REPO: 'https://git.mozilla.org/build/tooltool.git'
+ TOOLTOOL_REV: 'master'
+ TOOLS_DISABLE: true
+ MOZ_BUILD_DATE: '{{pushdate}}'
+ MOZ_SCM_LEVEL: '{{level}}'
+
+ extra:
+ # These definitions are expected of build tasks but not used in our case
+ build_product: '{{build_product}}'
+ build_name: '{{build_name}}'
+ build_type: '{{build_type}}'
+ locations:
+ build: null
+ tests: null
+ index:
+ rank: {{pushlog_id}}
+ treeherder:
+ groupSymbol: tc
+ groupName: Submitted by taskcluster
new file mode 100644
--- /dev/null
+++ b/testing/taskcluster/tasks/tests/harness_marionette.yml
@@ -0,0 +1,37 @@
+---
+$inherits:
+ from: 'tasks/harness_test.yml'
+ variables:
+ build_product: 'harness_test'
+ build_name: 'marionette-harness-pytest'
+ build_type: 'opt'
+
+task:
+ metadata:
+ name: '[TC] - Marionette harness unit test'
+ description: 'Marionette harness unit test'
+
+ payload:
+ command:
+ - --tests=testing/marionette/harness/marionette/tests/harness_unit
+ # Avoid overwriting /home/workspace/build/src
+ - --work-dir=mozharness_workspace
+ env:
+ JOB_SCRIPT: 'testing/taskcluster/scripts/tester/harness-test-linux.sh'
+ MOZHARNESS_SCRIPT: >
+ testing/mozharness/scripts/marionette_harness_tests.py
+ artifacts:
+ 'public/logs/':
+ type: directory
+ path: '/home/worker/workspace/mozharness_workspace/upload/logs/'
+ expires: '{{#from_now}}1 year{{/from_now}}'
+ extra:
+ treeherder:
+ symbol: Mn-h
+ tier: 2
+ machine:
+ # see https://github.com/mozilla/treeherder/blob/master/ui/js/values.js
+ platform: linux64
+ treeherderEnv:
+ - production
+ - staging