Bug 1715478 - Automated recording for desktop with a list sites r=sparky

Differential Revision: https://phabricator.services.mozilla.com/D117298
This commit is contained in:
Florin Strugariu 2021-07-09 07:12:27 +00:00
parent a9851cca23
commit 2b3375937c
8 changed files with 445 additions and 2 deletions

View File

@ -374,6 +374,7 @@ ARCHIVE_FILES = {
"perftests": [
{"source": buildconfig.topsrcdir, "pattern": "testing/mozbase/**"},
{"source": buildconfig.topsrcdir, "pattern": "testing/condprofile/**"},
{"source": buildconfig.topsrcdir, "pattern": "testing/performance/**"},
{"source": buildconfig.topsrcdir, "pattern": "third_party/python/**"},
{"source": buildconfig.topsrcdir, "pattern": "tools/lint/eslint/**"},
{"source": buildconfig.topsrcdir, "pattern": "**/perftest_*.js"},

View File

@ -37,7 +37,7 @@ class Hooks(MachLogger):
_LOADED_MODULES[path] = hook_module
self._hooks = _LOADED_MODULES[path]
else:
raise IOError(str(hook_module))
raise IOError("Could not find hook module. %s" % str(hook_module))
def cleanup(self):
if self.tmp_dir is None:

View File

@ -140,7 +140,11 @@ class ProxyRunner(Layer):
else:
command.extend(["--tool=%s" % "mitmproxy"])
# XXX See bug 1712337, we need a single point where we can get the binary used from
command.extend(["--binary=%s" % self.get_arg("browsertime-binary")])
# this is required to make it work localy
binary = self.get_arg("browsertime-binary")
if binary is None:
binary = self.mach_cmd.get_binary_path()
command.extend(["--binary=%s" % binary])
if self.get_arg("mode") == "record":
output = self.get_arg("output")

View File

@ -12,6 +12,7 @@ PACKAGE_VERSION = "0.2"
deps = [
"regex",
"jsonschema",
"attr",
"mozlog >= 6.0",
"mozdevice >= 4.0.0",
"mozproxy",

View File

@ -234,3 +234,26 @@ perfstats:
--browsertime-iterations 10
--hooks testing/performance/hooks_perfstats.py
testing/performance/perftest_perfstats.js
record-websites:
description: Run mozperftest to record desktop websites
platform: linux1804-64/opt
require-build:
linux1804-64/opt: build-linux64/opt
treeherder:
symbol: perftest(rec)
attributes:
cron: false
run-on-projects: []
run:
command: >-
mkdir -p $MOZ_FETCHES_DIR/../artifacts &&
cd $MOZ_FETCHES_DIR &&
python3.8 python/mozperftest/mozperftest/runner.py
--flavor desktop-browser
--browsertime-binary ${MOZ_FETCHES_DIR}/firefox/firefox-bin
--browsertime-geckodriver ${MOZ_FETCHES_DIR}/geckodriver
--proxy
--output $MOZ_FETCHES_DIR/../artifacts
--hooks testing/performance/hooks_recording.py
testing/performance/perftest_record.js

View File

@ -0,0 +1,82 @@
# 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 __future__ import absolute_import
import json
import platform
from pathlib import Path
from mozperftest.test.browsertime import add_options, add_option
options = [
("pageCompleteWaitTime", "10000"),
]
next_site = None
RECORDING_LIST = Path(Path(__file__).parent, "pageload_sites.json")
def before_iterations(kw):
global next_site
print("Setting up next site to record.")
with RECORDING_LIST.open() as f:
site_list = json.load(f)
# currently can't record websites that require user interactions(Logins)
if kw.get("android"):
site_list = site_list["mobile"]
else:
site_list = site_list["desktop"]
sites = [test_site for test_site in site_list if not test_site.get("login")]
def next_site():
for site in sites:
yield site
next_site = next_site()
# Set the number of test-iterations to the number of builds
kw["test_iterations"] = len(sites)
return kw
def before_runs(env):
global next_site
print("Running before_runs")
add_options(env, options)
if next_site:
test_site = next(next_site)
print("Next site: %s" % test_site)
if env.get_arg("android"):
platform_name = "android"
app_name = env.get_arg("android-app-name").split(".")[-1]
else:
platform_name = platform.system().lower()
app_name = "firefox"
name = [
"mitm6",
platform_name,
"gve" if app_name == "geckoview_example" else app_name,
test_site["name"],
]
recording_file = "%s.zip" % "-".join(name)
env.set_arg("proxy-mode", "record")
env.set_arg(
"proxy-file",
recording_file,
)
add_option(env, "browsertime.url", test_site.get("test_url"), overwrite=True)
add_option(env, "browsertime.screenshot", "true")
add_option(env, "browsertime.testName", test_site.get("name"))
print("Recording %s to file: %s" % (test_site.get("url"), recording_file))

View File

@ -0,0 +1,303 @@
{
"mobile": [
{
"login": false,
"name": "allrecipes",
"test_url": "https://www.allrecipes.com/"
},
{
"login": false,
"name": "amazon",
"test_url": "https://www.amazon.com"
},
{
"login": false,
"name": "amazon-search",
"test_url": "https://www.amazon.com/s/ref=nb_sb_noss_2/139-6317191-5622045?url=search-alias%3Daps&field-keywords=mobile+phone"
},
{
"login": true,
"comment": "not login test but fails to load",
"name": "bbc",
"test_url": "https://www.bbc.com/news/business-47245877"
},
{
"login": false,
"name": "bing",
"test_url": "https://www.bing.com/"
},
{
"login": false,
"name": "bing-search-restaurants",
"test_url": "https://www.bing.com/search?q=restaurants+in+exton+pa+19341"
},
{
"login": false,
"name": "booking",
"test_url": "https://www.booking.com/"
},
{
"login": false,
"name": "cnn",
"test_url": "https://cnn.com"
},
{
"login": false,
"name": "cnn-ampstories",
"test_url": "https://cnn.com/ampstories/us/why-hurricane-michael-is-a-monster-unlike-any-other"
},
{
"login": false,
"name": "ebay-kleinanzeigen",
"test_url": "https://m.ebay-kleinanzeigen.de"
},
{
"login": false,
"name": "ebay-kleinanzeigen-search",
"test_url": "https://m.ebay-kleinanzeigen.de/s-anzeigen/auf-zeit-wg-berlin/zimmer/c199-l3331"
},
{
"login": false,
"name": "espn",
"test_url": "http://www.espn.com/nba/story/_/page/allstarweekend25788027/the-comparison-lebron-james-michael-jordan-their-own-words"
},
{
"login": true,
"name": "facebook",
"test_url": "https://m.facebook.com"
},
{
"login": false,
"name": "facebook-cristiano",
"test_url": "https://m.facebook.com/Cristiano"
},
{
"login": true,
"name": "google",
"test_url": "https://www.google.com"
},
{
"login": false,
"name": "google-maps",
"test_url": "https://www.google.com/maps?force=pwa"
},
{
"login": true,
"name": "google-search-restaurants",
"test_url": "https://www.google.com/search?q=restaurants+near+me"
},
{
"login": false,
"name": "imdb",
"test_url": "https://m.imdb.com/"
},
{
"login": true,
"name": "instagram",
"test_url": "https://www.instagram.com"
},
{
"login": true,
"comment": "not login test but fails to load properly",
"name": "jianshu",
"test_url": "https://www.jianshu.com/"
},
{
"login": false,
"name": "microsoft-support",
"test_url": "https://support.microsoft.com/en-us"
},
{
"login": false,
"name": "reddit",
"test_url": "https://www.reddit.com"
},
{
"login": false,
"name": "stackoverflow",
"test_url": "https://stackoverflow.com/"
},
{
"login": false,
"name": "web-de",
"test_url": "https://web.de/magazine/politik/politologe-glaubt-grossen-koalition-herbst-knallen-33563566"
},
{
"login": false,
"name": "wikipedia",
"test_url": "https://en.m.wikipedia.org/wiki/Main_Page"
},
{
"login": false,
"name": "youtube",
"test_url": "https://m.youtube.com"
},
{
"login": false,
"name": "youtube-watch",
"test_url": "https://www.youtube.com/watch?v=COU5T-Wafa4"
}
],
"desktop": [
{
"login": false,
"name": "amazon",
"test_url": "https://www.amazon.com/s?k=laptop&ref=nb_sb_noss_1"
},
{
"login": true,
"name": "facebook",
"test_url": "https://www.facebook.com"
},
{
"login": true,
"name": "google",
"test_url": "https://www.google.com/search?hl=en&q=barack+obama&cad=h"
},
{
"login": false,
"name": "youtube",
"test_url": "https://www.youtube.com"
},
{
"login": false,
"name": "bing-search",
"test_url": "https://www.bing.com/search?q=barack+obama"
},
{
"login": false,
"name": "buzzfeed",
"test_url": "https://www.buzzfeed.com/"
},
{
"login": false,
"name": "cnn",
"test_url": "https://www.cnn.com/2021/03/22/weather/climate-change-warm-waters-lake-michigan/index.html"
},
{
"login": false,
"name": "ebay",
"test_url": "https://www.ebay.com/"
},
{
"login": false,
"name": "espn",
"test_url": "http://www.espn.com/nba/story/_/page/allstarweekend25788027/the-comparison-lebron-james-michael-jordan-their-own-words"
},
{
"login": false,
"name": "expedia",
"test_url": "https://expedia.com/Hotel-Search?destination=New+York%2C+New+York&latLong=40.756680%2C-73.986470&regionId=178293&startDate=&endDate=&rooms=1&_xpid=11905%7C1&adults=2"
},
{
"login": false,
"name": "fandom",
"test_url": "https://www.fandom.com/articles/fallout-76-will-live-and-die-on-the-creativity-of-its-playerbase"
},
{
"login": false,
"name": "google-docs",
"test_url": "https://docs.google.com/document/d/1US-07msg12slQtI_xchzYxcKlTs6Fp7WqIc6W5GK5M8/edit?usp=sharing"
},
{
"login": true,
"name": "google-mail",
"test_url": "https://mail.google.com/"
},
{
"login": false,
"name": "google-slides",
"test_url": "https://docs.google.com/presentation/d/1Ici0ceWwpFvmIb3EmKeWSq_vAQdmmdFcWqaiLqUkJng/edit?usp=sharing"
},
{
"login": false,
"name": "imdb",
"test_url": "https://www.imdb.com/title/tt0084967/?ref_=nv_sr_2"
},
{
"login": false,
"name": "imgur",
"test_url": "https://imgur.com/gallery/m5tYJL6"
},
{
"login": true,
"name": "instagram",
"test_url": "https://www.instagram.com/"
},
{
"login": true,
"name": "linkedin",
"test_url": "https://www.linkedin.com/in/thommy-harris-hk-385723106/"
},
{
"login": false,
"name": "microsoft",
"test_url": "https://www.microsoft.com/en-us/"
},
{
"login": true,
"name": "netflix",
"test_url": "https://www.netflix.com/title/80117263"
},
{
"login": false,
"name": "nytimes",
"test_url": "https://www.nytimes.com/2020/02/19/opinion/surprise-medical-bill.html"
},
{
"login": true,
"name": "office",
"test_url": "https://office.live.com/start/Word.aspx?omkt=en-US"
},
{
"login": true,
"name": "outlook",
"test_url": "https://outlook.live.com/mail/inbox"
},
{
"login": true,
"name": "paypal",
"test_url": "https://www.paypal.com/myaccount/summary/"
},
{
"login": true,
"name": "pinterest",
"test_url": "https://pinterest.com/"
},
{
"login": false,
"name": "reddit",
"test_url": "https://www.reddit.com/r/technology/comments/9sqwyh/we_posed_as_100_senators_to_run_ads_on_facebook/"
},
{
"login": true,
"name": "tumblr",
"test_url": "https://www.tumblr.com/dashboard"
},
{
"login": false,
"name": "twitch",
"test_url": "https://www.twitch.tv/videos/326804629"
},
{
"login": true,
"name": "twitter",
"test_url": "https://twitter.com/BarackObama"
},
{
"login": false,
"name": "wikia",
"test_url": "https://marvel.fandom.com/wiki/Black_Panther"
},
{
"login": false,
"name": "wikipedia",
"test_url": "https://en.wikipedia.org/wiki/Barack_Obama"
},
{
"login": true,
"name": "yahoo-mail",
"test_url": "https://mail.yahoo.com/"
}
]
}

View File

@ -0,0 +1,29 @@
/* 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/. */
/* eslint-env node */
"use strict";
async function test(context, commands) {
let rootUrl = context.options.browsertime.url;
let testName = context.options.browsertime.testName;
await commands.measure.start(rootUrl);
commands.screenshot.take(testName);
// Wait for browser to settle
await commands.wait.byTime(1000);
return true;
}
module.exports = {
test,
owner: "Bebe fstrugariu@mozilla.com",
name: "Mozproxy recording generator",
component: "raptor",
description: ` This test generates fresh MozProxy recordings. It iterates through a list of
websites provided in *_sites.json and for each one opens a browser and
records all the associated HTTP traffic`,
usage:
"mach perftest --proxy --hooks testing/raptor/recorder/hooks.py testing/raptor/recorder/perftest_record.js",
};