Bug 1575014 - Fix `./mach try --gecko-profile ...`. r=tomprince,ahal
authorNick Alexander <nalexander@mozilla.com>
Wed, 25 Sep 2019 20:18:17 +0000
changeset 494979 6282465f11887659f51e4c590a24fe68614c87db
parent 494978 8a3dbb1b5e0e263709e412112583ca3ad4a2017a
child 494980 264dc83d8cf6f6756556800c3c9703182bb6edb3
push id114131
push userdluca@mozilla.com
push dateThu, 26 Sep 2019 09:47:34 +0000
treeherdermozilla-inbound@1dc1a755079a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstomprince, ahal
bugs1575014
milestone71.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 1575014 - Fix `./mach try --gecko-profile ...`. r=tomprince,ahal An error crept in, resulting in: ``` [task ...] InterpreterError: InterpreterError: infix: [..] expects integer [..] integer ``` At some point, `suite` became a string name and not an object with a string `name` member. However, in the interim, the diversity of `command` structures has made the template approach untenable. Therefore, this commit converts `GeckoProfile` to a `TryConfig`. The existing test clearly wasn't helpful, and it doesn't really map to a `TryConfig` test, so it was removed. Differential Revision: https://phabricator.services.mozilla.com/D41603
taskcluster/taskgraph/decision.py
taskcluster/taskgraph/templates/gecko-profile.yml
taskcluster/taskgraph/test/test_morph.py
taskcluster/taskgraph/transforms/tests.py
tools/tryselect/templates.py
tools/tryselect/test/test_templates.py
--- a/taskcluster/taskgraph/decision.py
+++ b/taskcluster/taskgraph/decision.py
@@ -126,16 +126,17 @@ visual_metrics_jobs_schema = Schema({
         ]
 })
 
 try_task_config_schema = Schema({
     Required('tasks'): [basestring],
     Optional('templates'): {basestring: object},
     Optional('disable-pgo'): bool,
     Optional('browsertime'): bool,
+    Optional('gecko-profile'): bool,
     # Keep in sync with JOB_SCHEMA in taskcluster/docker/visual-metrics/run-visual-metrics.py.
     Optional('visual-metrics-jobs'): visual_metrics_jobs_schema,
     Optional(
         "debian-tests",
         description="Run linux desktop tests on debian 10 (buster)."
         ): bool,
 })
 
deleted file mode 100644
--- a/taskcluster/taskgraph/templates/gecko-profile.yml
+++ /dev/null
@@ -1,36 +0,0 @@
----
-$if: input && task["extra"]
-then:
-    $if: task.extra["suite"]
-    then:
-        $if: task.extra.suite["name"] in ["talos", "raptor"]
-        then:
-            task:
-                # We can't use mergeDeep as that will append the command below
-                # instead of overwriting the original command.
-                $merge:
-                    - $eval: task
-                    - payload:
-                          $merge:
-                              - $eval: task.payload
-                              - command:
-                                    $if: typeof(task.payload.command[0]) == 'array'
-                                    then:
-                                        # Command is an array of arrays. Assumes the command we want
-                                        # to append --gecko-profile to is the first one. Also assumes
-                                        # that we can't have a space delimited string here (which is
-                                        # the case for now at least).
-                                        - $flatten:
-                                              - $eval: task.payload.command[0]
-                                              - ["--gecko-profile"]
-                                    else:
-                                        $if: len(task.payload.command) == 1
-                                        then:
-                                            # Command is an array with a single space delimited string.
-                                            # This only happens on Windows.
-                                            - "${task.payload.command[0]} --gecko-profile"
-                                        else:
-                                            # Command is an array of strings.
-                                            $flatten:
-                                                - $eval: task.payload.command
-                                                - ["--gecko-profile"]
--- a/taskcluster/taskgraph/test/test_morph.py
+++ b/taskcluster/taskgraph/test/test_morph.py
@@ -112,17 +112,17 @@ TASKS = [
         }
     },
     {
         'kind': 'test',
         'label': 'b',
         'attributes': {},
         'task': {
             'extra': {
-                'suite': {'name': 'talos'},
+                'suite': 'talos',
                 'treeherder': {
                     'group': 'tc',
                     'symbol': 't'
                 }
             },
             'payload': {
                 'env': {
                     'FOO': 'BAR'
@@ -194,39 +194,10 @@ def test_template_rebuild(get_morphed):
     for t in tasks:
         if t.label == 'a':
             assert 'task_duplicates' not in t.attributes
         elif t.label == 'b':
             assert 'task_duplicates' in t.attributes
             assert t.attributes['task_duplicates'] == 4
 
 
-@pytest.mark.parametrize('command', (
-    ['foo --bar'],
-    ['foo', '--bar'],
-    [['foo']],
-    [['foo', '--bar']],
-))
-def test_template_gecko_profile(get_morphed, command):
-    tasks = TASKS[:]
-    for t in tasks:
-        t['task']['payload']['command'] = command
-
-    morphed = get_morphed({
-        'templates': {
-            'gecko-profile': True,
-        }
-    }, tasks)
-
-    for t in morphed.tasks.values():
-        command = t.task['payload']['command']
-        if isinstance(command[0], list):
-            command = command[0]
-        command = ' '.join(command)
-
-        if t.label == 'a':
-            assert not command.endswith('--gecko-profile')
-        elif t.label == 'b':
-            assert command.endswith('--gecko-profile')
-
-
 if __name__ == '__main__':
     main()
--- a/taskcluster/taskgraph/transforms/tests.py
+++ b/taskcluster/taskgraph/transforms/tests.py
@@ -1316,16 +1316,19 @@ def set_retry_exit_status(config, tests)
 
 
 @transforms.add
 def set_profile(config, tests):
     """Set profiling mode for tests."""
     profile = None
     if config.params['try_mode'] == 'try_option_syntax':
         profile = config.params['try_options']['profile']
+    else:
+        profile = config.params['try_task_config'].get('gecko-profile', False)
+
     for test in tests:
         if profile and test['suite'] in ['talos', 'raptor']:
             test['mozharness']['extra-options'].append('--geckoProfile')
         yield test
 
 
 @transforms.add
 def set_tag(config, tests):
--- a/tools/tryselect/templates.py
+++ b/tools/tryselect/templates.py
@@ -188,17 +188,17 @@ class ChemspillPrio(Template):
 
     def context(self, chemspill_prio, **kwargs):
         if chemspill_prio:
             return {
                 'chemspill-prio': {}
             }
 
 
-class GeckoProfile(Template):
+class GeckoProfile(TryConfig):
     arguments = [
         [['--gecko-profile'],
          {'dest': 'profile',
           'action': 'store_true',
           'default': False,
           'help': 'Create and upload a gecko profile during talos/raptor tasks.',
           }],
         # For backwards compatibility
@@ -212,20 +212,21 @@ class GeckoProfile(Template):
         [['--geckoProfile'],
          {'dest': 'profile',
           'action': 'store_true',
           'default': False,
           'help': SUPPRESS,
           }],
     ]
 
-    def context(self, profile, **kwargs):
-        if not profile:
-            return
-        return {'gecko-profile': profile}
+    def try_config(self, profile, **kwargs):
+        if profile:
+            return {
+                'gecko-profile': True,
+            }
 
 
 class Browsertime(TryConfig):
     arguments = [
         [['--browsertime'],
          {'action': 'store_true',
           'help': 'Use browsertime during Raptor tasks.',
           }],
--- a/tools/tryselect/test/test_templates.py
+++ b/tools/tryselect/test/test_templates.py
@@ -35,22 +35,16 @@ TEMPLATE_TESTS = {
         (['invalid/path'], SystemExit),
     ],
     'rebuild': [
         ([], None),
         (['--rebuild', '10'], {'rebuild': 10}),
         (['--rebuild', '1'], SystemExit),
         (['--rebuild', '21'], SystemExit),
     ],
-    'gecko-profile': [
-        ([], None),
-        (['--talos-profile'], {'gecko-profile': True}),
-        (['--geckoProfile'], {'gecko-profile': True}),
-        (['--gecko-profile'], {'gecko-profile': True}),
-    ],
 }
 
 
 @pytest.fixture
 def template_patch_resolver(patch_resolver):
     def inner(paths):
         patch_resolver([], [{'flavor': 'xpcshell', 'srcdir_relpath': path} for path in paths])
     return inner