Commit bfe18425 authored by slamm's avatar slamm Committed by Commit bot

Remove one use of PageTest.CanRunForPage.

After this only the startup benchmarks will have a dependency. The goal is to remove CanRunForPage entirely.

session_restore has used CanRunForPage to select one page from the typical_25. The URL is not used because the navigation action is skipped. The only reason it is there is because there is a test when setting up Web Page Replay that the archive has the URL.

BUG=440101

Review URL: https://codereview.chromium.org/808893002

Cr-Commit-Position: refs/heads/master@{#317734}
parent b19dc5bf
...@@ -12,7 +12,17 @@ from telemetry import benchmark ...@@ -12,7 +12,17 @@ from telemetry import benchmark
from telemetry.page import profile_generator from telemetry.page import profile_generator
class _SessionRestoreTest(benchmark.Benchmark): class _SessionRestoreTypical25(benchmark.Benchmark):
"""Base Benchmark class for session restore benchmarks.
A cold start means none of the Chromium files are in the disk cache.
A warm start assumes the OS has already cached much of Chromium's content.
For warm tests, you should repeat the page set to ensure it's cached.
Use Typical25PageSet to match what the SmallProfileCreator uses.
TODO(slamm): Make SmallProfileCreator and this use the same page_set ref.
"""
page_set = page_sets.Typical25PageSet
@classmethod @classmethod
def Name(cls): def Name(cls):
...@@ -20,7 +30,7 @@ class _SessionRestoreTest(benchmark.Benchmark): ...@@ -20,7 +30,7 @@ class _SessionRestoreTest(benchmark.Benchmark):
@classmethod @classmethod
def ProcessCommandLineArgs(cls, parser, args): def ProcessCommandLineArgs(cls, parser, args):
super(_SessionRestoreTest, cls).ProcessCommandLineArgs(parser, args) super(_SessionRestoreTypical25, cls).ProcessCommandLineArgs(parser, args)
profile_type = 'small_profile' profile_type = 'small_profile'
if not args.browser_options.profile_dir: if not args.browser_options.profile_dir:
output_dir = os.path.join(tempfile.gettempdir(), profile_type) output_dir = os.path.join(tempfile.gettempdir(), profile_type)
...@@ -38,6 +48,18 @@ class _SessionRestoreTest(benchmark.Benchmark): ...@@ -38,6 +48,18 @@ class _SessionRestoreTest(benchmark.Benchmark):
small_profile_creator.SmallProfileCreator, profile_type, new_args) small_profile_creator.SmallProfileCreator, profile_type, new_args)
args.browser_options.profile_dir = profile_dir args.browser_options.profile_dir = profile_dir
def CreateUserStorySet(self, _):
"""Return a user story set that only has the first user story.
The session restore measurement skips the navigation step and
only tests session restore by having the browser start-up.
The first user story is used to get WPR set up and hold results.
"""
user_story_set = self.page_set()
for user_story in user_story_set.user_stories[1:]:
user_story_set.RemoveUserStory(user_story)
return user_story_set
def CreatePageTest(self, options): def CreatePageTest(self, options):
is_cold = (self.tag == 'cold') is_cold = (self.tag == 'cold')
return session_restore.SessionRestore(cold=is_cold) return session_restore.SessionRestore(cold=is_cold)
...@@ -47,7 +69,8 @@ class _SessionRestoreTest(benchmark.Benchmark): ...@@ -47,7 +69,8 @@ class _SessionRestoreTest(benchmark.Benchmark):
# crbug.com/325479, crbug.com/381990 # crbug.com/325479, crbug.com/381990
@benchmark.Disabled('android', 'linux', 'reference') @benchmark.Disabled('android', 'linux', 'reference')
class SessionRestoreColdTypical25(_SessionRestoreTest): class SessionRestoreColdTypical25(_SessionRestoreTypical25):
"""Test by clearing system cache and profile before repeats."""
tag = 'cold' tag = 'cold'
options = {'pageset_repeat': 5} options = {'pageset_repeat': 5}
...@@ -58,7 +81,11 @@ class SessionRestoreColdTypical25(_SessionRestoreTest): ...@@ -58,7 +81,11 @@ class SessionRestoreColdTypical25(_SessionRestoreTest):
# crbug.com/325479, crbug.com/381990 # crbug.com/325479, crbug.com/381990
@benchmark.Disabled('android', 'linux', 'reference') @benchmark.Disabled('android', 'linux', 'reference')
class SessionRestoreWarmTypical25(_SessionRestoreTest): class SessionRestoreWarmTypical25(_SessionRestoreTypical25):
"""Test without clearing system cache or profile before repeats.
The first result is discarded.
"""
tag = 'warm' tag = 'warm'
options = {'pageset_repeat': 20} options = {'pageset_repeat': 20}
......
...@@ -42,12 +42,8 @@ class SessionRestore(startup.Startup): ...@@ -42,12 +42,8 @@ class SessionRestore(startup.Startup):
60) 60)
return browser.foreground_tab return browser.foreground_tab
def CanRunForPage(self, page):
# No matter how many pages in the pageset, just perform one test iteration.
return page.page_set.pages.index(page) == 0
def RunNavigateSteps(self, page, tab): def RunNavigateSteps(self, page, tab):
# Overriden so that no page navigation occurs. # Overridden so that no page navigation occurs.
pass pass
def ValidatePageSet(self, page_set): def ValidatePageSet(self, page_set):
......
...@@ -13,7 +13,7 @@ class UserStorySet(object): ...@@ -13,7 +13,7 @@ class UserStorySet(object):
"""A collection of user story. """A collection of user story.
A typical usage of UserStorySet would be to subclass it and then calling A typical usage of UserStorySet would be to subclass it and then calling
AddUserStory for each UserStory.. AddUserStory for each UserStory.
""" """
def __init__(self, archive_data_file='', cloud_storage_bucket=None, def __init__(self, archive_data_file='', cloud_storage_bucket=None,
...@@ -70,9 +70,16 @@ class UserStorySet(object): ...@@ -70,9 +70,16 @@ class UserStorySet(object):
assert isinstance(user_story, user_story_module.UserStory) assert isinstance(user_story, user_story_module.UserStory)
self.user_stories.append(user_story) self.user_stories.append(user_story)
def RemoveUserStory(self, user_story):
"""Removes a UserStory.
Allows the user stories to be filtered.
"""
self.user_stories.remove(user_story)
@classmethod @classmethod
def Name(cls): def Name(cls):
""" Returns the string name of this UserStorySet. """Returns the string name of this UserStorySet.
Note that this should be a classmethod so benchmark_runner script can match Note that this should be a classmethod so benchmark_runner script can match
user story class with its name specified in the run command: user story class with its name specified in the run command:
'Run <User story test name> <User story class name>' 'Run <User story test name> <User story class name>'
...@@ -81,10 +88,10 @@ class UserStorySet(object): ...@@ -81,10 +88,10 @@ class UserStorySet(object):
@classmethod @classmethod
def Description(cls): def Description(cls):
""" Return a string explaining in human-understandable terms what this """Return a string explaining in human-understandable terms what this
user story represents. user story represents.
Note that this should be a classmethod so benchmark_runner script can Note that this should be a classmethod so benchmark_runner script can
display user stories' names along their descriptions in the list commmand. display user stories' names along their descriptions in the list command.
""" """
if cls.__doc__: if cls.__doc__:
return cls.__doc__.splitlines()[0] return cls.__doc__.splitlines()[0]
...@@ -95,7 +102,7 @@ class UserStorySet(object): ...@@ -95,7 +102,7 @@ class UserStorySet(object):
pass pass
def WprFilePathForUserStory(self, story): def WprFilePathForUserStory(self, story):
"""Convenient function to retrive WPR archive file path. """Convenient function to retrieve WPR archive file path.
Args: Args:
user_story: The UserStory to lookup. user_story: The UserStory to lookup.
......
...@@ -5,10 +5,23 @@ ...@@ -5,10 +5,23 @@
import os import os
import unittest import unittest
from telemetry import user_story
from telemetry.user_story import shared_user_story_state
from telemetry.user_story import user_story_set from telemetry.user_story import user_story_set
from telemetry.util import cloud_storage from telemetry.util import cloud_storage
# pylint: disable=abstract-method
class SharedUserStoryStateBar(shared_user_story_state.SharedUserStoryState):
pass
class UserStoryFoo(user_story.UserStory):
def __init__(self, name='', labels=None):
super(UserStoryFoo, self).__init__(
SharedUserStoryStateBar, name, labels)
class UserStorySetFoo(user_story_set.UserStorySet): class UserStorySetFoo(user_story_set.UserStorySet):
""" UserStorySetFoo is a user story created for testing purpose. """ """ UserStorySetFoo is a user story created for testing purpose. """
pass pass
...@@ -46,5 +59,20 @@ class UserStorySetTest(unittest.TestCase): ...@@ -46,5 +59,20 @@ class UserStorySetTest(unittest.TestCase):
cloud_storage_bucket=cloud_storage.INTERNAL_BUCKET) cloud_storage_bucket=cloud_storage.INTERNAL_BUCKET)
self.assertEqual(internal_uss.bucket, cloud_storage.INTERNAL_BUCKET) self.assertEqual(internal_uss.bucket, cloud_storage.INTERNAL_BUCKET)
self.assertRaises(ValueError, user_story_set.UserStorySet, with self.assertRaises(ValueError):
cloud_storage_bucket='garbage_bucket') user_story_set.UserStorySet(cloud_storage_bucket='garbage_bucket')
def testRemoveWithEmptySetRaises(self):
uss = user_story_set.UserStorySet()
foo_story = UserStoryFoo()
with self.assertRaises(ValueError):
uss.RemoveUserStory(foo_story)
def testBasicAddRemove(self):
uss = user_story_set.UserStorySet()
foo_story = UserStoryFoo()
uss.AddUserStory(foo_story)
self.assertEqual([foo_story], uss.user_stories)
uss.RemoveUserStory(foo_story)
self.assertEqual([], uss.user_stories)
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