Commit 0d3d85c5 authored by petrcermak's avatar petrcermak Committed by Commit bot

[system-health] Add support for disabling individual stories on individual platforms

This patch adds support for enabling/disabling individual stories on individual
platforms using the same approaches as for benchmarks:

  1. Disabled/Enabled decorator:

     @decorators.Disabled('win')
     class Story(system_health_story.SystemHealthStory):
        ...

  2. ShouldDisable method:

     class Story(system_health_story.SystemHealthStory):
        ...

        @classmethod
        def ShouldDisable(cls, possible_browser):
          return possible_browser.platform.GetOSName() == 'win'

Note that this patch also enables search:portal:google on all desktop
platforms except for Windows.

BUG=634331
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.perf:android_s5_perf_cq;master.tryserver.chromium.perf:linux_perf_cq;master.tryserver.chromium.perf:mac_retina_perf_cq;master.tryserver.chromium.perf:winx64_10_perf_cq

Review-Url: https://codereview.chromium.org/2228103002
Cr-Commit-Position: refs/heads/master@{#417552}
parent 0a972e9e
......@@ -5,6 +5,8 @@
from page_sets.system_health import platforms
from page_sets.system_health import system_health_story
from telemetry import decorators
class _BrowsingStory(system_health_story.SystemHealthStory):
"""Abstract base class for browsing stories.
......@@ -79,15 +81,15 @@ class _NewsBrowsingStory(_BrowsingStory):
repeat_count=self.MAIN_PAGE_SCROLL_REPEAT)
# TODO(ulan): Enable this story on mobile once it uses less memory and does not
# crash with OOM.
@decorators.Disabled('android')
class CnnStory(_NewsBrowsingStory):
"""The second top website in http://www.alexa.com/topsites/category/News"""
NAME = 'browse:news:cnn'
URL = 'http://edition.cnn.com/'
ITEM_SELECTOR = '.cd__content > h3 > a'
ITEMS_TO_VISIT = 2
# TODO(ulan): Enable this story on mobile once it uses less memory and
# does not crash with OOM.
SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
class FacebookMobileStory(_NewsBrowsingStory):
......@@ -151,14 +153,14 @@ class NytimesDesktopStory(_NewsBrowsingStory):
SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
# Desktop qq.com opens a news item in a separate tab, for which the back button
# does not work. Mobile qq.com is disabled due to crbug.com/627166.
@decorators.Disabled('all')
class QqMobileStory(_NewsBrowsingStory):
NAME = 'browse:news:qq'
URL = 'http://news.qq.com'
# Desktop qq.com opens a news item in a separate tab, for which the back
# button does not work.
# Mobile qq.com is disabled due to crbug.com/627166
ITEM_SELECTOR = '.list .full a'
SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS
SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
class RedditDesktopStory(_NewsBrowsingStory):
......@@ -280,7 +282,7 @@ class YouTubeDesktopStory(_MediaBrowsingStory):
ITEM_SELECTOR_INDEX = 3
class FacebookPhotosMediaStory(_MediaBrowsingStory):
class FacebookPhotosMobileStory(_MediaBrowsingStory):
NAME = 'browse:media:facebook_photos'
URL = (
'https://m.facebook.com/rihanna/photos/a.207477806675.138795.10092511675/10153911739606676/?type=3&source=54&ref=page_internal')
......
......@@ -163,7 +163,7 @@ class LoadRedditMobileStory(_LoadingStory):
SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
class LoadSohuStory(_LoadingStory):
class LoadSohuMobileStory(_LoadingStory):
NAME = 'load:news:sohu'
# Using "https://" leads to missing images and scripts on mobile (due to
# mixed content).
......@@ -389,12 +389,10 @@ class LoadMiniclipStory(_LoadingStory):
NAME = 'load:games:miniclip'
# Using "https://" causes "404 Not Found" during WPR recording.
URL = 'http://www.miniclip.com/games/en/'
# Desktop only (requires Flash).
SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY # Requires Flash.
class LoadAlphabettyStory(_LoadingStory):
NAME = 'load:games:alphabetty'
URL = 'https://king.com/play/alphabetty'
# Desktop only (requires Flash).
SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY # Requires Flash.
......@@ -6,7 +6,10 @@ DESKTOP = 'desktop'
MOBILE = 'mobile'
ALL_PLATFORMS = frozenset({DESKTOP, MOBILE})
# Use the constants below to mark on which platforms the story has WPR
# recordings. To disable a story (e.g. because it crashes or takes too long),
# use @decorators.Disabled instead.
DESKTOP_ONLY = frozenset({DESKTOP})
MOBILE_ONLY = frozenset({MOBILE})
# This is used for disabling a story on all platforms.
NO_PLATFORMS = frozenset()
......@@ -2,15 +2,15 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from page_sets.system_health import platforms
from page_sets.system_health import system_health_story
from telemetry import decorators
@decorators.Disabled('win') # http://crbug.com/642463
class SearchGoogleStory(system_health_story.SystemHealthStory):
NAME = 'search:portal:google'
URL = 'https://www.google.co.uk/'
# Tap simulation doesn't fully work on Windows. http://crbug.com/634343
SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
_SEARCH_BOX_SELECTOR = 'input[aria-label="Search"]'
_RESULT_SELECTOR = '.r > a[href*="wikipedia"]'
......
......@@ -4,7 +4,9 @@
from page_sets.system_health import platforms
from telemetry import decorators
from telemetry.page import page
from telemetry.page import shared_page_state
# Extra wait time after the page has loaded required by the loading metric. We
......@@ -13,6 +15,32 @@ from telemetry.page import page
_WAIT_TIME_AFTER_LOAD = 10
class _SystemHealthSharedState(shared_page_state.SharedPageState):
"""Shared state which enables disabling stories on individual platforms.
This class adds support for enabling/disabling individual stories on
individual platforms using the same approaches as for benchmarks:
1. Disabled/Enabled decorator:
@decorators.Disabled('win')
class Story(system_health_story.SystemHealthStory):
...
2. ShouldDisable method:
class Story(system_health_story.SystemHealthStory):
...
@classmethod
def ShouldDisable(cls, possible_browser):
return possible_browser.platform.GetOSName() == 'win'
"""
def CanRunStory(self, story):
return story.CanRun(self.possible_browser)
class _MetaSystemHealthStory(type):
"""Metaclass for SystemHealthStory."""
......@@ -41,11 +69,28 @@ class SystemHealthStory(page.Page):
def __init__(self, story_set, take_memory_measurement):
case, group, _ = self.NAME.split(':')
super(SystemHealthStory, self).__init__(
page_set=story_set, name=self.NAME, url=self.URL,
shared_page_state_class=_SystemHealthSharedState, page_set=story_set,
name=self.NAME, url=self.URL,
credentials_path='../data/credentials.json',
grouping_keys={'case': case, 'group': group})
self._take_memory_measurement = take_memory_measurement
@classmethod
def CanRun(cls, possible_browser):
if (decorators.ShouldSkip(cls, possible_browser)[0] or
cls.ShouldDisable(possible_browser)):
return False
return True
@classmethod
def ShouldDisable(cls, possible_browser):
"""Override this method to disable a story under specific conditions.
This method is modelled after telemetry.benchmark.Benchmark.ShouldDisable().
"""
del possible_browser
return False
def _Measure(self, action_runner):
if self._take_memory_measurement:
action_runner.MeasureMemory(deterministic_mode=True)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment