1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 from __future__
import absolute_import
11 from mozperftest
.test
.browsertime
import add_options
12 from mozperftest
.system
.android
import _ROOT_URL
13 from mozperftest
.utils
import (
16 get_revision_namespace_url
,
20 # We specifically select this URL because:
21 # - we access Mozilla URLs in tests so any connections to Mozilla URLs may re-use
22 # existing connections and have different perf characteristics. We can mostly
23 # avoid this problem by using a non-Mozilla URL
24 # - we authored the site so we can guarantee it doesn't change or change it if
26 # - we're not directing traffic to a site we don't own
27 URL
= "'https://mozilla-mobile.github.io/perf-tools/mozperftest-test-page.html'"
30 ("processStartTime", "true"),
31 ("firefox.disableBrowsertimeExtension", "true"),
32 ("firefox.android.intentArgument", "'-a'"),
33 ("firefox.android.intentArgument", "'android.intent.action.VIEW'"),
34 ("firefox.android.intentArgument", "'-d'"),
35 ("firefox.android.intentArgument", URL
),
38 NIGHTLY_SIM_ROUTE
= "mobile.v2.fenix.nightly-simulation"
39 ROUTE_SUFFIX
= "artifacts/public/build/{architecture}/target.apk"
41 build_generator
= None
44 def before_iterations(kw
):
45 global build_generator
47 install_list
= kw
.get("android_install_apk")
48 if len(install_list
) == 0 or all(
49 ["fenix_nightlysim_multicommit" not in apk
for apk
in install_list
]
54 install_package(kw
["virtualenv"], "gitpython==3.1.0")
57 class _GitProgress(git
.RemoteProgress
):
58 def update(self
, op_code
, cur_count
, max_count
=None, message
=""):
62 # Setup the local fenix github repo
63 print("Cloning fenix repo...")
64 fenix_repo
= git
.Repo
.clone_from(
65 "https://github.com/mozilla-mobile/fenix",
68 progress
=_GitProgress(),
71 # Get the builds to test
73 "arm64-v8a" if "arm64_v8a" in kw
.get("android_install_apk") else "armeabi-v7a"
76 get_revision_namespace_url
, NIGHTLY_SIM_ROUTE
, day
=kw
["test_date"]
78 namespaces
= json_
["namespaces"]
79 revisions
= [namespace
["name"] for namespace
in namespaces
]
82 for revision
in revisions
:
84 commit
= fenix_repo
.commit(revision
)
85 name_rev
= str(commit
.name_rev
)
87 "remotes/origin" not in name_rev
88 or "release" in name_rev
92 "Commit %s is a release-branch commit, it won't be tested."
97 commitdate
= commit
.committed_date
99 print("Commit %s is not from the Fenix master branch" % revision
)
103 get_multi_tasks_url
, NIGHTLY_SIM_ROUTE
, revision
, day
=kw
["test_date"]
105 for task
in json_
["tasks"]:
106 route
= task
["namespace"]
107 task_architecture
= route
.split(".")[-1]
108 if task_architecture
== architecture
:
111 "timestamp": commitdate
,
112 "revision": revision
,
114 "route_suffix": ROUTE_SUFFIX
.format(
115 architecture
=task_architecture
120 # Set the number of test-iterations to the number of builds
121 kw
["test_iterations"] = len(tasks
)
123 def _build_iterator():
125 revision
= task
["revision"]
126 timestamp
= task
["timestamp"]
128 humandate
= time
.ctime(int(timestamp
))
129 print(f
"Testing revision {revision} from {humandate}")
131 download_url
= f
'{_ROOT_URL}{task["route"]}/{task["route_suffix"]}'
132 yield revision
, timestamp
, [download_url
]
134 build_generator
= _build_iterator()
139 def _fetch_json(get_url_function
, *args
, **kwargs
):
140 build_url
= get_url_function(*args
, **kwargs
)
141 tmpfile
= pathlib
.Path(tempfile
.mkdtemp(), "temp.json")
142 download_file(build_url
, tmpfile
)
144 with tmpfile
.open() as f
:
148 def before_runs(env
, **kw
):
149 global build_generator
151 add_options(env
, COMMON_OPTIONS
)
153 revision
, timestamp
, build
= next(build_generator
)
154 env
.set_arg("android-install-apk", build
)
155 env
.set_arg("perfherder-prefix", revision
)
156 env
.set_arg("perfherder-timestamp", timestamp
)