Bug 1391675 - [tryselect] Add a test for 'mach try fuzzy' and associated task, r?gps draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Mon, 21 Aug 2017 11:52:28 -0400
changeset 650148 af3db0e1ea30c9a18c6554bd81c7d3df839d4106
parent 650147 14eec629a6780985ac3ed409070e8be463b6ed7d
child 727309 bb197ae18f3d85975238b98037f330df5b198b22
push id75282
push userahalberstadt@mozilla.com
push dateMon, 21 Aug 2017 21:25:16 +0000
reviewersgps
bugs1391675
milestone57.0a1
Bug 1391675 - [tryselect] Add a test for 'mach try fuzzy' and associated task, r?gps Basic test to get the ground work laid out. MozReview-Commit-ID: LmjA3Kq7xKN
moz.build
taskcluster/ci/source-test/cram.yml
taskcluster/ci/source-test/kind.yml
taskcluster/docker/lint/system-setup.sh
taskcluster/taskgraph/transforms/task.py
tools/moz.build
tools/tryselect/test/cram.ini
tools/tryselect/test/setup.sh
tools/tryselect/test/test_fuzzy.t
--- a/moz.build
+++ b/moz.build
@@ -59,16 +59,17 @@ if CONFIG['ENABLE_CLANG_PLUGIN']:
     DIRS += ['build/clang-plugin']
 
 DIRS += [
     'config',
     'python',
     'taskcluster',
     'testing/mozbase',
     'third_party/python',
+    'tools',
 ]
 
 if not CONFIG['JS_STANDALONE']:
     # These python manifests are included here so they get picked up without an objdir
     PYTHON_UNITTEST_MANIFESTS += [
         'testing/marionette/harness/marionette_harness/tests/harness_unit/python.ini',
         'testing/mochitest/tests/python/python.ini',
     ]
new file mode 100644
--- /dev/null
+++ b/taskcluster/ci/source-test/cram.yml
@@ -0,0 +1,20 @@
+---
+tryselect:
+    description: tools/tryselect integration tests
+    platform: linux64/opt
+    treeherder:
+        symbol: cram(try)
+        kind: test
+        tier: 2
+    worker-type: aws-provisioner-v1/gecko-t-linux-xlarge
+    worker:
+        docker-image: {in-tree: "lint"}
+        max-run-time: 1800
+    run:
+        using: mach
+        mach: cramtest tools/tryselect
+    when:
+        files-changed:
+            - testing/mach_commands.py
+            - third_party/python/cram/**
+            - tools/tryselect/**
--- a/taskcluster/ci/source-test/kind.yml
+++ b/taskcluster/ci/source-test/kind.yml
@@ -1,30 +1,31 @@
 # 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/.
-
+---
 loader: taskgraph.loader.transform:loader
 
 transforms:
    - taskgraph.transforms.source_test:transforms
    - taskgraph.transforms.job:transforms
    - taskgraph.transforms.task:transforms
 
 jobs-from:
-    - python-tests.yml
-    - mocha.yml
-    - mozlint.yml
-    - doc.yml
-    - webidl.yml
+   - cram.yml
+   - doc.yml
+   - mocha.yml
+   - mozlint.yml
+   - python-tests.yml
+   - webidl.yml
 
 # This is used by run-task based tasks to lookup which build task it
 # should depend on based on its own platform.
 dependent-build-platforms:
-    linux64-asan/opt:
-        label: build-linux64-asan/opt
-        target-name: target.tar.bz2
-    linux64/debug:
-        label: build-linux64/debug
-        target-name: target.tar.bz2
-    linux64.*:
-        label: build-linux64/opt
-        target-name: target.tar.bz2
+   linux64-asan/opt:
+      label: build-linux64-asan/opt
+      target-name: target.tar.bz2
+   linux64/debug:
+      label: build-linux64/debug
+      target-name: target.tar.bz2
+   linux64.*:
+      label: build-linux64/opt
+      target-name: target.tar.bz2
--- a/taskcluster/docker/lint/system-setup.sh
+++ b/taskcluster/docker/lint/system-setup.sh
@@ -48,16 +48,34 @@ cd /build
 . install-node.sh
 
 /build/tooltool.py fetch -m /tmp/eslint.tt
 mv /build/node_modules /build/node_modules_eslint
 /build/tooltool.py fetch -m /tmp/eslint-plugin-mozilla.tt
 mv /build/node_modules /build/node_modules_eslint-plugin-mozilla
 
 ###
+# fzf setup
+###
+
+tooltool_fetch <<EOF
+[
+  {
+    "size": 866160,
+    "visibility": "public",
+    "digest": "9f0ef6bf44b8622bd0e4e8b0b5b5c714c0a2ce4487e6f234e7d4caac458164c521949f4d84b8296274e8bd20966f835e26f6492ba499405d38b620181e82429e",
+    "algorithm": "sha512",
+    "filename": "fzf-0.16.11-linux_amd64.tgz",
+    "unpack": true
+  }
+]
+EOF
+mv fzf /usr/local/bin
+
+###
 # Flake8 Setup
 ###
 
 cd /setup
 
 pip install --require-hashes -r /tmp/flake8_requirements.txt
 
 ###
@@ -65,8 +83,9 @@ pip install --require-hashes -r /tmp/fla
 ###
 
 cd /setup
 
 pip install --require-hashes -r /tmp/tox_requirements.txt
 
 cd /
 rm -rf /setup
+
--- a/taskcluster/taskgraph/transforms/task.py
+++ b/taskcluster/taskgraph/transforms/task.py
@@ -427,16 +427,17 @@ task_description_schema = Schema({
         # "Invalid" is a noop for try and other non-supported branches
         Required('google-play-track'): Any('production', 'beta', 'alpha', 'rollout', 'invalid'),
         Required('dry-run', default=True): bool,
         Optional('rollout-percentage'): int,
     }),
 })
 
 GROUP_NAMES = {
+    'cram': 'Cram tests',
     'mocha': 'Mocha unit tests',
     'py': 'Python unit tests',
     'tc': 'Executed by TaskCluster',
     'tc-e10s': 'Executed by TaskCluster with e10s',
     'tc-Fxfn-l': 'Firefox functional tests (local) executed by TaskCluster',
     'tc-Fxfn-l-e10s': 'Firefox functional tests (local) executed by TaskCluster with e10s',
     'tc-Fxfn-r': 'Firefox functional tests (remote) executed by TaskCluster',
     'tc-Fxfn-r-e10s': 'Firefox functional tests (remote) executed by TaskCluster with e10s',
--- a/tools/moz.build
+++ b/tools/moz.build
@@ -43,8 +43,12 @@ with Files("rewriting/**"):
 with Files("tryselect/**"):
     BUG_COMPONENT = ("Testing", "General")
 
 with Files("update-packaging/**"):
     BUG_COMPONENT = ("Release Engineering", "Other")
 
 SPHINX_TREES['lint'] = 'lint/docs'
 SPHINX_TREES['compare-locales'] = 'compare-locales/docs'
+
+CRAMTEST_MANIFESTS += [
+    'tryselect/test/cram.ini',
+]
new file mode 100644
--- /dev/null
+++ b/tools/tryselect/test/cram.ini
@@ -0,0 +1,1 @@
+[test_fuzzy.t]
new file mode 100644
--- /dev/null
+++ b/tools/tryselect/test/setup.sh
@@ -0,0 +1,22 @@
+export topsrcdir=$TESTDIR/../../../
+export MOZBUILD_STATE_PATH=$TMP/mozbuild
+
+cachedir=$MOZBUILD_STATE_PATH/cache/taskgraph
+mkdir -p $cachedir
+
+cat >> $cachedir/target_task_set << EOF
+test/foo-opt
+test/foo-debug
+build-baz
+EOF
+
+cat >> $cachedir/full_task_set << EOF
+test/foo-opt
+test/foo-debug
+test/bar-opt
+test/bar-debug
+build-baz
+EOF
+
+# set mtime to the future so we don't re-generate tasks
+find $cachedir -type f -exec touch -d "next day" {} +
new file mode 100644
--- /dev/null
+++ b/tools/tryselect/test/test_fuzzy.t
@@ -0,0 +1,23 @@
+  $ . $TESTDIR/setup.sh
+  $ cd $topsrcdir
+
+Test fuzzy selector
+
+  $ ./mach try fuzzy --no-push -q "'foo"
+  Calculated try selector:
+  {
+    "tasks": [
+      "test/foo-debug", 
+      "test/foo-opt"
+    ]
+  }
+  $ ./mach try fuzzy --no-push -q "'bar"
+  no tasks selected
+  $ ./mach try fuzzy --no-push --full -q "'bar"
+  Calculated try selector:
+  {
+    "tasks": [
+      "test/bar-debug", 
+      "test/bar-opt"
+    ]
+  }