Bug 1642615 - Renamed the browser layer to test r=sparky
authorTarek Ziadé <tarek@mozilla.com>
Thu, 04 Jun 2020 18:31:54 +0000
changeset 534151 2b6e363687b77f74c1935a6cd9078de6cb3bf38a
parent 534150 372774f9407214a19b57666c518e2cb06c83d81a
child 534152 be1f54c6e5ec28cca1eb7d1c1bd7802774618c75
push id118172
push usergmierz2@outlook.com
push dateFri, 05 Jun 2020 14:48:40 +0000
treeherderautoland@be1f54c6e5ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssparky
bugs1642615
milestone79.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 1642615 - Renamed the browser layer to test r=sparky This patch renames the browser layer to test, since it could be something else than a browser Differential Revision: https://phabricator.services.mozilla.com/D78016
python/mozperftest/mozperftest/argparser.py
python/mozperftest/mozperftest/browser/__init__.py
python/mozperftest/mozperftest/browser/browsertime/__init__.py
python/mozperftest/mozperftest/browser/browsertime/package-lock.json
python/mozperftest/mozperftest/browser/browsertime/package.json
python/mozperftest/mozperftest/browser/browsertime/runner.py
python/mozperftest/mozperftest/browser/browsertime/setup.py
python/mozperftest/mozperftest/browser/noderunner.py
python/mozperftest/mozperftest/browser/profile.py
python/mozperftest/mozperftest/environment.py
python/mozperftest/mozperftest/metadata.py
python/mozperftest/mozperftest/system/proxy.py
python/mozperftest/mozperftest/test/__init__.py
python/mozperftest/mozperftest/test/browsertime/__init__.py
python/mozperftest/mozperftest/test/browsertime/package-lock.json
python/mozperftest/mozperftest/test/browsertime/package.json
python/mozperftest/mozperftest/test/browsertime/runner.py
python/mozperftest/mozperftest/test/browsertime/setup.py
python/mozperftest/mozperftest/test/noderunner.py
python/mozperftest/mozperftest/test/profile.py
python/mozperftest/mozperftest/tests/test_browsertime.py
python/mozperftest/mozperftest/tests/test_profile.py
testing/performance/hooks.py
testing/performance/hooks_applink.py
--- a/python/mozperftest/mozperftest/argparser.py
+++ b/python/mozperftest/mozperftest/argparser.py
@@ -11,17 +11,17 @@ try:
     from mozbuild.base import MozbuildObject, MachCommandConditions as conditions
 
     build_obj = MozbuildObject.from_environment(cwd=here)
 except ImportError:
     build_obj = None
     conditions = None
 
 from mozperftest.system import get_layers as system_layers  # noqa
-from mozperftest.browser import get_layers as browser_layers  # noqa
+from mozperftest.test import get_layers as test_layers  # noqa
 from mozperftest.metrics import get_layers as metrics_layers  # noqa
 
 FLAVORS = ["script", "doc"]
 
 
 class Options:
 
     general_args = {
@@ -66,17 +66,17 @@ class Options:
             "default": False,
             "help": "Running the test on try",
         },
     }
 
     args = copy.deepcopy(general_args)
 
 
-for layer in system_layers() + browser_layers() + metrics_layers():
+for layer in system_layers() + test_layers() + metrics_layers():
     if layer.activated:
         # add an option to deactivate it
         option_name = "--no-%s" % layer.name
         option_help = "Deactivates the %s layer" % layer.name
     else:
         option_name = "--%s" % layer.name
         option_help = "Activates the %s layer" % layer.name
 
--- a/python/mozperftest/mozperftest/environment.py
+++ b/python/mozperftest/mozperftest/environment.py
@@ -3,17 +3,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 import copy
 import contextlib
 import importlib
 from pathlib import Path
 import tempfile
 import shutil
 
-from mozperftest.browser import pick_browser
+from mozperftest.test import pick_test
 from mozperftest.system import pick_system
 from mozperftest.metrics import pick_metrics
 from mozperftest.layers import Layers
 from mozperftest.utils import download_file
 
 
 SYSTEM, BROWSER, METRICS = 0, 1, 2
 
@@ -23,17 +23,17 @@ class MachEnvironment:
         self._mach_cmd = mach_cmd
         self._mach_args = dict(
             [(self._normalize(key), value) for key, value in kwargs.items()]
         )
         self.layers = []
         # XXX do something with flavors, etc
         if flavor != "script":
             raise NotImplementedError(flavor)
-        for layer in (pick_system, pick_browser, pick_metrics):
+        for layer in (pick_system, pick_test, pick_metrics):
             self.add_layer(layer(self, flavor, mach_cmd))
         self.tmp_dir = tempfile.mkdtemp()
         self._load_hooks()
 
     @contextlib.contextmanager
     def frozen(self):
         self.freeze()
         try:
@@ -84,17 +84,17 @@ class MachEnvironment:
 
     def unfreeze(self):
         self._mach_args = self._saved_mach_args
         self._saved_mach_args = None
 
     def run(self, metadata):
         has_exc_handler = self.has_hook("on_exception")
 
-        # run the system and browser layers
+        # run the system and test layers
         for layer in self.layers[:-1]:
             with layer:
                 try:
                     metadata = layer(metadata)
                 except Exception as e:
                     if has_exc_handler:
                         # if the hook returns True, we abort and return
                         # without error. If it returns False, we continue
--- a/python/mozperftest/mozperftest/metadata.py
+++ b/python/mozperftest/mozperftest/metadata.py
@@ -1,20 +1,21 @@
 # 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 collections import defaultdict
 from mozperftest.utils import MachLogger
 
 
 class Metadata(MachLogger):
     def __init__(self, mach_cmd, env, flavor):
         MachLogger.__init__(self, mach_cmd)
         self._mach_cmd = mach_cmd
         self.flavor = flavor
-        self.browser = {"prefs": {}}
+        self.options = defaultdict(dict)
         self._results = []
         self._output = None
         self._env = env
 
     def run_hook(self, name, **kw):
         # this bypasses layer restrictions on args,
         # which is fine since it's user script
         return self._env.run_hook(name, **kw)
@@ -29,13 +30,13 @@ class Metadata(MachLogger):
         self._results.append(result)
 
     def get_results(self):
         return self._results
 
     def clear_results(self):
         self._results = []
 
-    def update_browser_prefs(self, prefs):
-        self.browser["prefs"].update(prefs)
+    def update_options(self, name, options):
+        self.options[name].update(options)
 
-    def get_browser_prefs(self):
-        return self.browser["prefs"]
+    def get_options(self, name):
+        return self.options[name]
--- a/python/mozperftest/mozperftest/system/proxy.py
+++ b/python/mozperftest/mozperftest/system/proxy.py
@@ -49,15 +49,21 @@ class ProxyRunner(Layer):
             port = str(self.proxy.port)
             prefs = {}
             prefs["network.proxy.type"] = 1
             prefs["network.proxy.http"] = "localhost"
             prefs["network.proxy.http_port"] = port
             prefs["network.proxy.ssl"] = "localhost"
             prefs["network.proxy.ssl_port"] = port
             prefs["network.proxy.no_proxies_on"] = "localhost"
-            metadata.update_browser_prefs(prefs)
+            browser_prefs = metadata.get_options("browser_prefs")
+            if "prefs" in browser_prefs:
+                browser_prefs["prefs"].update(prefs)
+            else:
+                browser_prefs["prefs"] = prefs
+            metadata.update_options("browser_prefs", browser_prefs)
+
         return metadata
 
     def teardown(self):
         if self.proxy is not None:
             self.proxy.stop()
             self.proxy = None
rename from python/mozperftest/mozperftest/browser/__init__.py
rename to python/mozperftest/mozperftest/test/__init__.py
--- a/python/mozperftest/mozperftest/browser/__init__.py
+++ b/python/mozperftest/mozperftest/test/__init__.py
@@ -1,16 +1,16 @@
 # 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 mozperftest.browser.browsertime import BrowsertimeRunner
-from mozperftest.browser.profile import Profile
+from mozperftest.test.browsertime import BrowsertimeRunner
+from mozperftest.test.profile import Profile
 from mozperftest.layers import Layers
 
 
 def get_layers():
     return (Profile, BrowsertimeRunner)
 
 
-def pick_browser(env, flavor, mach_cmd):
+def pick_test(env, flavor, mach_cmd):
     if flavor == "script":
         return Layers(env, mach_cmd, get_layers())
     raise NotImplementedError(flavor)
rename from python/mozperftest/mozperftest/browser/browsertime/__init__.py
rename to python/mozperftest/mozperftest/test/browsertime/__init__.py
--- a/python/mozperftest/mozperftest/browser/browsertime/__init__.py
+++ b/python/mozperftest/mozperftest/test/browsertime/__init__.py
@@ -1,13 +1,13 @@
 # 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 mozperftest.browser.browsertime.runner import BrowsertimeRunner  # noqa
+from mozperftest.test.browsertime.runner import BrowsertimeRunner  # noqa
 
 
 def add_option(env, name, value):
     options = env.get_arg("browsertime-extra-options", "")
     options += ",%s=%s" % (name, value)
     env.set_arg("browsertime-extra-options", options)
 
 
rename from python/mozperftest/mozperftest/browser/browsertime/package-lock.json
rename to python/mozperftest/mozperftest/test/browsertime/package-lock.json
rename from python/mozperftest/mozperftest/browser/browsertime/package.json
rename to python/mozperftest/mozperftest/test/browsertime/package.json
rename from python/mozperftest/mozperftest/browser/browsertime/runner.py
rename to python/mozperftest/mozperftest/test/browsertime/runner.py
--- a/python/mozperftest/mozperftest/browser/browsertime/runner.py
+++ b/python/mozperftest/mozperftest/test/browsertime/runner.py
@@ -7,18 +7,18 @@ import os
 import pathlib
 import sys
 import re
 import shutil
 from pathlib import Path
 
 from mozperftest.scriptinfo import ScriptInfo
 from mozperftest.utils import install_package
-from mozperftest.browser.noderunner import NodeRunner
-from mozperftest.browser.browsertime.setup import (
+from mozperftest.test.noderunner import NodeRunner
+from mozperftest.test.browsertime.setup import (
     system_prerequisites,
     append_system_env,
 )
 
 
 BROWSERTIME_SRC_ROOT = Path(__file__).parent
 PILLOW_VERSION = "6.0.0"
 PYSSIM_VERSION = "0.4"
rename from python/mozperftest/mozperftest/browser/browsertime/setup.py
rename to python/mozperftest/mozperftest/test/browsertime/setup.py
rename from python/mozperftest/mozperftest/browser/noderunner.py
rename to python/mozperftest/mozperftest/test/noderunner.py
rename from python/mozperftest/mozperftest/browser/profile.py
rename to python/mozperftest/mozperftest/test/profile.py
--- a/python/mozperftest/mozperftest/browser/profile.py
+++ b/python/mozperftest/mozperftest/test/profile.py
@@ -38,17 +38,17 @@ class Profile(Layer):
         # XXX we'll use conditioned profiles later
         profile = create_profile(app="firefox")
 
         # mozprofile.Profile.__del__ silently deletes the profile
         # it creates in a non-deterministic time (garbage collected) by
         # calling cleanup. We override this silly behavior here.
         profile.cleanup = self._cleanup
 
-        prefs = metadata.get_browser_prefs()
+        prefs = metadata.get_options("browser_prefs")
 
         if prefs == {}:
             prefs["mozperftest"] = "true"
 
         # apply custom user prefs if any
         user_js = self.get_arg("user-js")
         if user_js is not None:
             self.info("Applying use prefs from %s" % user_js)
--- a/python/mozperftest/mozperftest/tests/test_browsertime.py
+++ b/python/mozperftest/mozperftest/tests/test_browsertime.py
@@ -5,39 +5,39 @@ from unittest import mock
 import shutil
 import string
 import random
 
 import pytest
 
 from mozperftest.tests.support import get_running_env, EXAMPLE_TEST
 from mozperftest.environment import BROWSER
-from mozperftest.browser.browsertime import add_options
-from mozperftest.browser.browsertime.runner import (
+from mozperftest.test.browsertime import add_options
+from mozperftest.test.browsertime.runner import (
     NodeException,
     matches,
     extract_browser_name,
 )
 from mozperftest.utils import silence, temporary_env
 
 
 HERE = os.path.dirname(__file__)
 
 
 def fetch(self, url):
     return os.path.join(HERE, "fetched_artifact.zip")
 
 
-@mock.patch("mozperftest.browser.browsertime.runner.install_package")
+@mock.patch("mozperftest.test.browsertime.runner.install_package")
 @mock.patch(
-    "mozperftest.browser.noderunner.NodeRunner.verify_node_install", new=lambda x: True
+    "mozperftest.test.noderunner.NodeRunner.verify_node_install", new=lambda x: True
 )
 @mock.patch("mozbuild.artifact_cache.ArtifactCache.fetch", new=fetch)
 @mock.patch(
-    "mozperftest.browser.browsertime.runner.BrowsertimeRunner._setup_node_packages",
+    "mozperftest.test.browsertime.runner.BrowsertimeRunner._setup_node_packages",
     new=lambda x, y: None,
 )
 def test_browser(*mocked):
     mach_cmd, metadata, env = get_running_env(
         android=True,
         android_app_name="something",
         browsertime_geckodriver="GECKODRIVER",
         browsertime_iterations=1,
@@ -65,23 +65,23 @@ def test_browser(*mocked):
     assert "--two 2" in cmd
 
     results = metadata.get_results()
     assert len(results) == 1
     assert set(list(results[0].keys())) - set(["name", "results"]) == set()
     assert results[0]["name"] == "Example"
 
 
-@mock.patch("mozperftest.browser.browsertime.runner.install_package")
+@mock.patch("mozperftest.test.browsertime.runner.install_package")
 @mock.patch(
-    "mozperftest.browser.noderunner.NodeRunner.verify_node_install", new=lambda x: True
+    "mozperftest.test.noderunner.NodeRunner.verify_node_install", new=lambda x: True
 )
 @mock.patch("mozbuild.artifact_cache.ArtifactCache.fetch", new=fetch)
 @mock.patch(
-    "mozperftest.browser.browsertime.runner.BrowsertimeRunner._setup_node_packages",
+    "mozperftest.test.browsertime.runner.BrowsertimeRunner._setup_node_packages",
     new=lambda x, y: None,
 )
 def test_browser_failed(*mocked):
     mach_cmd, metadata, env = get_running_env(
         android=True,
         android_app_name="something",
         browsertime_geckodriver="GECKODRIVER",
         browsertime_iterations=1,
@@ -91,23 +91,23 @@ def test_browser_failed(*mocked):
     mach_cmd.run_process.return_value = 1
     browser = env.layers[BROWSER]
     env.set_arg("tests", [EXAMPLE_TEST])
 
     with browser as b, silence(), pytest.raises(NodeException):
         b(metadata)
 
 
-@mock.patch("mozperftest.browser.browsertime.runner.install_package")
+@mock.patch("mozperftest.test.browsertime.runner.install_package")
 @mock.patch(
-    "mozperftest.browser.noderunner.NodeRunner.verify_node_install", new=lambda x: True
+    "mozperftest.test.noderunner.NodeRunner.verify_node_install", new=lambda x: True
 )
 @mock.patch("mozbuild.artifact_cache.ArtifactCache.fetch", new=fetch)
 @mock.patch(
-    "mozperftest.browser.browsertime.runner.BrowsertimeRunner._setup_node_packages",
+    "mozperftest.test.browsertime.runner.BrowsertimeRunner._setup_node_packages",
     new=lambda x, y: None,
 )
 def test_browser_desktop(*mocked):
     mach_cmd, metadata, env = get_running_env(
         browsertime_iterations=1, browsertime_extra_options="one=1,two=2",
     )
     browser = env.layers[BROWSER]
     env.set_arg("tests", [EXAMPLE_TEST])
@@ -135,22 +135,22 @@ def test_add_options():
     mach_cmd, metadata, env = get_running_env()
     options = [("one", 1), ("two", 2)]
     add_options(env, options)
     extra = env.get_arg("browsertime-extra-options")
     assert "one=1" in extra
     assert "two=2" in extra
 
 
-@mock.patch("mozperftest.browser.browsertime.runner.install_package")
+@mock.patch("mozperftest.test.browsertime.runner.install_package")
 @mock.patch(
-    "mozperftest.browser.noderunner.NodeRunner.verify_node_install", new=lambda x: True
+    "mozperftest.test.noderunner.NodeRunner.verify_node_install", new=lambda x: True
 )
 @mock.patch("mozbuild.artifact_cache.ArtifactCache.fetch", new=fetch)
-@mock.patch("mozperftest.browser.browsertime.runner.BrowsertimeRunner.setup_helper")
+@mock.patch("mozperftest.test.browsertime.runner.BrowsertimeRunner.setup_helper")
 def test_install_url(*mocked):
     url = "https://here/tarball/" + "".join(
         [random.choice(string.hexdigits[:-6]) for c in range(40)]
     )
     mach, metadata, env = get_running_env(browsertime_install_url=url)
     browser = env.layers[BROWSER]
     env.set_arg("tests", [EXAMPLE_TEST])
 
@@ -158,23 +158,23 @@ def test_install_url(*mocked):
         with temporary_env(MOZ_AUTOMATION="1"), browser as b, silence():
             b(metadata)
     finally:
         shutil.rmtree(mach._mach_context.state_dir)
 
     assert mach.run_process.call_count == 1
 
 
-@mock.patch("mozperftest.browser.browsertime.runner.install_package")
+@mock.patch("mozperftest.test.browsertime.runner.install_package")
 @mock.patch(
-    "mozperftest.browser.noderunner.NodeRunner.verify_node_install", new=lambda x: True
+    "mozperftest.test.noderunner.NodeRunner.verify_node_install", new=lambda x: True
 )
 @mock.patch("mozbuild.artifact_cache.ArtifactCache.fetch", new=fetch)
 @mock.patch(
-    "mozperftest.browser.browsertime.runner.BrowsertimeRunner._setup_node_packages",
+    "mozperftest.test.browsertime.runner.BrowsertimeRunner._setup_node_packages",
     new=lambda x, y: None,
 )
 def test_install_url_bad(*mocked):
     mach, metadata, env = get_running_env(browsertime_install_url="meh")
     browser = env.layers[BROWSER]
     env.set_arg("tests", [EXAMPLE_TEST])
 
     with pytest.raises(ValueError):
--- a/python/mozperftest/mozperftest/tests/test_profile.py
+++ b/python/mozperftest/mozperftest/tests/test_profile.py
@@ -1,16 +1,16 @@
 #!/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/.
 import os
 import mozunit
 from mozperftest.tests.support import get_running_env
-from mozperftest.browser.profile import Profile
+from mozperftest.test.profile import Profile
 
 
 def test_profile():
     mach_cmd, metadata, env = get_running_env()
 
     with Profile(env, mach_cmd) as profile:
         profile(metadata)
         profile_dir = env.get_arg("profile-directory")
--- a/testing/performance/hooks.py
+++ b/testing/performance/hooks.py
@@ -1,13 +1,13 @@
 # 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/.
 import os
-from mozperftest.browser.browsertime import add_options, add_option
+from mozperftest.test.browsertime import add_options, add_option
 
 
 sites = os.path.join(os.path.dirname(__file__), "sites.txt")
 with open(sites) as f:
     sites = [site for site in f.read().split("\n") if site.strip()]
 
 
 def next_site():
--- a/testing/performance/hooks_applink.py
+++ b/testing/performance/hooks_applink.py
@@ -1,12 +1,12 @@
 # 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 mozperftest.browser.browsertime import add_options
+from mozperftest.test.browsertime import add_options
 
 url = "'https://www.example.com'"
 
 common_options = [("processStartTime", "true"),
                   ("firefox.disableBrowsertimeExtension", "true"),
                   ("firefox.android.intentArgument", "'-a'"),
                   ("firefox.android.intentArgument", "'android.intent.action.VIEW'"),
                   ("firefox.android.intentArgument", "'-d'"),