Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Side by Side Diff: tools/chrome_proxy/live_tests/chrome_proxy_measurements.py

Issue 1098253004: Move top_20 tests to a separate suite (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import base64
6 import logging
7 import urlparse
8
9 from integration_tests import chrome_proxy_metrics as metrics
sclittle 2015/04/23 01:07:50 IIUC you're actually importing the integration_tes
bustamante 2015/04/23 02:26:09 Yeah, Done.
10 from metrics import loading
11 from telemetry.core import exceptions
12 from telemetry.page import page_test
13
14 class ChromeProxyLatency(page_test.PageTest):
sclittle 2015/04/23 01:07:50 Could these latency and data savings tests be remo
bustamante 2015/04/23 02:26:09 Yeah I think we should remove them, or add a condi
15 """Chrome proxy latency measurement."""
16
17 def __init__(self, *args, **kwargs):
18 super(ChromeProxyLatency, self).__init__(*args, **kwargs)
19 self._metrics = metrics.ChromeProxyMetric()
20
21 def CustomizeBrowserOptions(self, options):
22 options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth')
23
24 def WillNavigateToPage(self, page, tab):
25 tab.ClearCache(force=True)
26
27 def ValidateAndMeasurePage(self, page, tab, results):
28 # Wait for the load event.
29 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300)
30 self._metrics.AddResultsForLatency(tab, results)
31
32
33 class ChromeProxyDataSaving(page_test.PageTest):
34 """Chrome proxy data saving measurement."""
35 def __init__(self, *args, **kwargs):
36 super(ChromeProxyDataSaving, self).__init__(*args, **kwargs)
37 self._metrics = metrics.ChromeProxyMetric()
38
39 def CustomizeBrowserOptions(self, options):
40 options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth')
41
42 def WillNavigateToPage(self, page, tab):
43 tab.ClearCache(force=True)
44 self._metrics.Start(page, tab)
45
46 def ValidateAndMeasurePage(self, page, tab, results):
47 # Wait for the load event.
48 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300)
49 self._metrics.Stop(page, tab)
50 self._metrics.AddResultsForDataSaving(tab, results)
51
52
53 class ChromeProxyValidation(page_test.PageTest):
sclittle 2015/04/23 01:07:50 Maybe this file could import the old measurements.
bustamante 2015/04/23 02:26:09 The header test that used this got removed so we d
54 """Base class for all chrome proxy correctness measurements."""
55
56 # Value of the extra via header. |None| if no extra via header is expected.
57 extra_via_header = None
58
59 def __init__(self, restart_after_each_page=False):
60 super(ChromeProxyValidation, self).__init__(
61 needs_browser_restart_after_each_page=restart_after_each_page)
62 self._metrics = metrics.ChromeProxyMetric()
63 self._page = None
64 # Whether a timeout exception is expected during the test.
65 self._expect_timeout = False
66
67 def CustomizeBrowserOptions(self, options):
68 # Enable the chrome proxy (data reduction proxy).
69 options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth')
70
71 def WillNavigateToPage(self, page, tab):
72 tab.ClearCache(force=True)
73 assert self._metrics
74 self._metrics.Start(page, tab)
75
76 def ValidateAndMeasurePage(self, page, tab, results):
77 self._page = page
78 # Wait for the load event.
79 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300)
80 assert self._metrics
81 self._metrics.Stop(page, tab)
82 if ChromeProxyValidation.extra_via_header:
83 self._metrics.AddResultsForExtraViaHeader(
84 tab, results, ChromeProxyValidation.extra_via_header)
85 self.AddResults(tab, results)
86
87 def AddResults(self, tab, results):
88 raise NotImplementedError
89
90 def StopBrowserAfterPage(self, browser, page): # pylint: disable=W0613
91 if hasattr(page, 'restart_after') and page.restart_after:
92 return True
93 return False
94
95 def RunNavigateSteps(self, page, tab):
96 # The redirect from safebrowsing causes a timeout. Ignore that.
97 try:
98 super(ChromeProxyValidation, self).RunNavigateSteps(page, tab)
99 if self._expect_timeout:
100 raise metrics.ChromeProxyMetricException, (
101 'Timeout was expected, but did not occur')
102 except exceptions.TimeoutException as e:
103 if self._expect_timeout:
104 logging.warning('Navigation timeout on page %s',
105 page.name if page.name else page.url)
106 else:
107 raise e
108
109
110 class ChromeProxyHeaders(ChromeProxyValidation):
sclittle 2015/04/23 01:07:50 Does it really make sense to run the header valida
bustamante 2015/04/23 02:26:09 Yeah I agree, I'll remove the test for now, and la
111 """Correctness measurement for response headers."""
112
113 def __init__(self):
114 super(ChromeProxyHeaders, self).__init__(restart_after_each_page=True)
115
116 def AddResults(self, tab, results):
117 self._metrics.AddResultsForHeaderValidation(tab, results)
118
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698