diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/performance/hooks_android_startup.py | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/performance/hooks_android_startup.py')
-rw-r--r-- | testing/performance/hooks_android_startup.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/testing/performance/hooks_android_startup.py b/testing/performance/hooks_android_startup.py new file mode 100644 index 0000000000..ff79f59b9e --- /dev/null +++ b/testing/performance/hooks_android_startup.py @@ -0,0 +1,50 @@ +# 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 pathlib +from datetime import date, datetime + +import requests +from mozperftest.system.android_startup import ( + BASE_URL_DICT, + KEY_ARCHITECTURE, + KEY_COMMIT, + KEY_DATETIME, + KEY_NAME, + KEY_PRODUCT, + PROD_FOCUS, +) + + +def before_iterations(kw): + product = kw["AndroidStartUp_product"] + download_date = date.today() + architecture = "armeabi-v7a" + + if product == PROD_FOCUS and download_date >= datetime(2021, 11, 5): + product += "-v2" + + nightly_url = BASE_URL_DICT[product + "-latest"].format(architecture=architecture) + filename = f"{product}_nightly_{architecture}.apk" + print("Fetching {}...".format(filename), end="", flush=True) + download_apk_as_date(nightly_url, download_date, filename) + + kw["apk_metadata"] = { + KEY_NAME: filename, + KEY_DATETIME: download_date, + KEY_COMMIT: "", + KEY_ARCHITECTURE: architecture, + KEY_PRODUCT: product, + } + + +def download_apk_as_date(nightly_url, download_date_string, filename): + apk = requests.get(nightly_url) + if apk.status_code != 200: + raise Exception( + f"Something went wrong downloading the apk check to make sure you have entered" + f" a date that is valid and that the apk for the date you have requested(" + f"{download_date_string}) is available and that the URL({nightly_url}) is also " + f"valid" + ) + pathlib.Path(filename).write_bytes(apk.content) |