Bug 1641971: Pass `mach perftest` options explicitly, rather than inpsect parameters; r=tarek

Differential Revision: https://phabricator.services.mozilla.com/D77548
This commit is contained in:
Tom Prince 2020-06-02 18:23:07 +00:00
Родитель 602da9cdcd
Коммит 11aedca9b2
5 изменённых файлов: 44 добавлений и 29 удалений

Просмотреть файл

@ -53,10 +53,13 @@ class Perftest(MachCommandBase):
continue
perftest_parameters[name] = value
parameters = {"try_options": {"perftest": perftest_parameters}}
try_config = {"tasks": [_TRY_PLATFORMS[platform]]}
parameters["try_task_config"] = try_config
parameters["try_mode"] = "try_task_config"
parameters = {
"try_task_config": {
"tasks": [_TRY_PLATFORMS[platform]],
"perftest-options": perftest_parameters,
},
"try_mode": "try_task_config",
}
task_config = {"parameters": parameters, "version": 2}
push_to_try("perftest", "perftest", try_task_config=task_config)

Просмотреть файл

@ -23,9 +23,10 @@ The --push-to-try flow is:
- run_test() grabs the parameters artifact and converts them into args for
perftest
"""
import sys
import json
import os
import shutil
import sys
HERE = os.path.dirname(__file__)
@ -77,38 +78,20 @@ def _setup_path():
sys.path.insert(0, path)
def _get_params():
"""Fetches the parameters.yml artifact and returns its content.
"""
# XXX - this already exists in taskcluster code
# in a more robust way, but for now let's not depend on it.
import requests
import yaml
root = os.environ.get(
"TASKCLUSTER_ROOT_URL", "https://firefox-ci-tc.services.mozilla.com"
)
# set by require-decision-task-id
tid = os.environ["DECISION_TASK_ID"]
url = root + "/api/queue/v1/task/%s/artifacts/public/parameters.yml" % tid
response = requests.get(url)
return yaml.load(response.text)
def run_tests(mach_cmd, **kwargs):
"""This tests runner can be used directly via main or via Mach.
When the --on-try option is used, the test runner looks for the
`parameters.yml` artifact that contains all options passed by
the used via a ./mach perftest --push-to-try call.
When the --on-try option is used, the test runner looks at the
`PERFTEST_OPTIONS` environment variable that contains all options passed by
the user via a ./mach perftest --push-to-try call.
"""
_setup_path()
on_try = kwargs.pop("on_try", False)
# trying to get the arguments from the task params
if on_try:
params = _get_params()
kwargs.update(params["try_options"]["perftest"])
try_options = json.loads(os.environ['PERFTEST_OPTIONS'])
kwargs.update(try_options)
from mozperftest.utils import build_test_list, install_package
from mozperftest import MachEnvironment, Metadata

Просмотреть файл

@ -9,6 +9,7 @@ kind-dependencies:
- build
transforms:
- taskgraph.transforms.perftest:transforms
- taskgraph.transforms.source_test:transforms
- taskgraph.transforms.job:transforms
- taskgraph.transforms.task:transforms
@ -18,7 +19,6 @@ job-defaults:
treeherder:
kind: other
tier: 3
require-decision-task-id: true
worker:
taskcluster-proxy: true
max-run-time: 3600

Просмотреть файл

@ -128,6 +128,10 @@ try_task_config_schema = Schema({
Optional('disable-pgo'): bool,
Optional('env'): {text_type: text_type},
Optional('gecko-profile'): bool,
Optional(
"perftest-options",
description="Options passed from `mach perftest` to try."
): object,
Optional(
"optimize-strategies",
description="Alternative optimization strategies to use instead of the default. "

Просмотреть файл

@ -0,0 +1,25 @@
# 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/.
"""
This transform passes options from `mach perftest` to the corresponding task.
"""
from __future__ import absolute_import, print_function, unicode_literals
import json
import six
from taskgraph.transforms.base import TransformSequence
transforms = TransformSequence()
@transforms.add
def pass_perftest_options(config, jobs):
for job in jobs:
env = job.setdefault('worker', {}).setdefault('env', {})
env['PERFTEST_OPTIONS'] = six.ensure_text(
json.dumps(config.params["try_task_config"].get('perftest-options'))
)
yield job