Chromium Code Reviews| Index: tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py |
| diff --git a/tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py b/tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py |
| index ee756192ee29968c9c5c94d6f6b2f95f83de2ff6..c106c18cd825ba46d996facb4ffe225c760f7e1f 100644 |
| --- a/tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py |
| +++ b/tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py |
| @@ -18,9 +18,11 @@ class ChromeProxyLatency(page_test.PageTest): |
| def __init__(self, *args, **kwargs): |
| super(ChromeProxyLatency, self).__init__(*args, **kwargs) |
| self._metrics = metrics.ChromeProxyMetric() |
| + self._enable_proxy = True |
| def CustomizeBrowserOptions(self, options): |
| - options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth') |
| + if self._enable_proxy: |
| + options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth') |
| def WillNavigateToPage(self, page, tab): |
| tab.ClearCache(force=True) |
| @@ -31,14 +33,23 @@ class ChromeProxyLatency(page_test.PageTest): |
| self._metrics.AddResultsForLatency(tab, results) |
| +class ChromeProxyLatencyDirect(ChromeProxyLatency): |
| + """Direct fetch latency measurement.""" |
| + def __init__(self, *args, **kwargs): |
| + super(ChromeProxyLatencyDirect, self).__init__(*args, **kwargs) |
| + self._enable_proxy = False |
| + |
| + |
| class ChromeProxyDataSaving(page_test.PageTest): |
| """Chrome proxy data saving measurement.""" |
| def __init__(self, *args, **kwargs): |
| super(ChromeProxyDataSaving, self).__init__(*args, **kwargs) |
| self._metrics = metrics.ChromeProxyMetric() |
| + self._enable_proxy = True |
| def CustomizeBrowserOptions(self, options): |
| - options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth') |
| + if self._enable_proxy: |
| + options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth') |
| def WillNavigateToPage(self, page, tab): |
| tab.ClearCache(force=True) |
| @@ -51,6 +62,13 @@ class ChromeProxyDataSaving(page_test.PageTest): |
| self._metrics.AddResultsForDataSaving(tab, results) |
| +class ChromeProxyDataSavingDirect(ChromeProxyDataSaving): |
| + """Direct fetch data saving measurement.""" |
| + def __init__(self, *args, **kwargs): |
| + super(ChromeProxyDataSavingDirect, self).__init__(*args, **kwargs) |
| + self._enable_proxy = False |
| + |
| + |
| class ChromeProxyValidation(page_test.PageTest): |
| """Base class for all chrome proxy correctness measurements.""" |
| @@ -389,3 +407,84 @@ class ChromeProxySmoke(ChromeProxyValidation): |
| self._page.name, page_to_metrics.keys())) |
| for add_result in page_to_metrics[self._page.name]: |
| add_result(tab, results) |
| + |
| + |
| +PROXIED = 'proxied' |
|
sclittle
2015/04/11 00:13:02
I think you can just call metrics.PROXIED to use t
Tom Bergan
2015/05/01 23:48:28
Done.
|
| +DIRECT = 'direct' |
| + |
| +class ChromeProxyVideoValidation(page_test.PageTest): |
| + """Measures pages using metrics.ChromeProxyVideoMetric, then compares |
|
sclittle
2015/04/11 00:13:02
See style guide for python classdoc style: https:/
Tom Bergan
2015/05/01 23:48:28
Done.
|
| + the measurements from a direct fetch with measurements from a proxied |
| + fetch. |
| + """ |
| + |
| + def __init__(self): |
| + super(ChromeProxyVideoValidation, self).__init__( |
| + needs_browser_restart_after_each_page=True, |
| + clear_cache_before_each_run=True) |
| + # The type is _allMetrics[url][PROXIED,DIRECT][metricName] = value, |
| + # where (metricName,value) is a metric computed by videowrapper.js. |
| + self._allMetrics = {} |
| + |
| + def CustomizeBrowserOptionsForSinglePage(self, page, options): |
| + if page.use_chrome_proxy: |
| + options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth') |
| + |
| + def DidNavigateToPage(self, page, tab): |
| + self._currMetrics = metrics.ChromeProxyVideoMetric(tab) |
| + self._currMetrics.Start(page, tab) |
| + |
| + def ValidateAndMeasurePage(self, page, tab, results): |
| + assert self._currMetrics |
| + self._currMetrics.Stop(page, tab) |
| + if page.url not in self._allMetrics: |
| + self._allMetrics[page.url] = {} |
| + |
| + # Verify this page. |
| + if page.use_chrome_proxy: |
| + self._currMetrics.AddResultsForProxied(tab, results) |
| + self._allMetrics[page.url][PROXIED] = self._currMetrics.videoMetrics |
| + else: |
| + self._currMetrics.AddResultsForDirect(tab, results) |
| + self._allMetrics[page.url][DIRECT] = self._currMetrics.videoMetrics |
| + self._currMetrics = None |
| + |
| + # Compare proxied and direct results for this url, if they exist. |
| + m = self._allMetrics[page.url] |
| + if PROXIED in m and DIRECT in m: |
| + self._CompareProxiedAndDirectMetrics(page.url, m[PROXIED], m[DIRECT]) |
| + |
| + def _CompareProxiedAndDirectMetrics(self, url, pm, dm): |
| + """ Compares video metrics computed by videowrapper.js for PROXIED and |
|
sclittle
2015/04/11 00:13:02
See style guide for method doc style: https://goog
Tom Bergan
2015/05/01 23:48:28
Done.
|
| + DIRECT pages. Raises ChromeProxyMetricException on failure. |
| + |
| + Arguments: |
| + url: The url for the page being tested. |
| + pm: Metrics when loaded by the Flywheel proxy. |
| + dm: Metrics when loaded directly from the origin server. |
| + """ |
| + def err(s): |
| + raise ChromeProxyMetricException, s |
| + |
| + if not pm['ready']: |
| + err('Proxied page did not load video: %s' % page.url) |
| + if not dm['ready']: |
| + err('Direct page did not load video: %s' % page.url) |
| + |
| + # Compare metrics that should match for PROXIED and DIRECT. |
| + for x in ('video_height', 'video_width', 'video_duration', |
| + 'decoded_frames'): |
| + if x not in pm: |
| + err('Proxied page has no %s: %s' % (x, page.url)) |
| + if x not in dm: |
| + err('Direct page has no %s: %s' % (x, page.url)) |
| + if pm[x] != dm[x]: |
| + err('Mismatch for %s (proxied=%s direct=%s): %s' % |
| + (x, str(pm[x]), str(dm[x]), page.url)) |
| + |
| + # Proxied XOCL should match direct CL. |
| + pxocl = pm['x_original_content_length_header'] |
| + dcl = dm['content_length_header'] |
| + if pxocl != dcl: |
| + err('Mismatch for content length (proxied=%s direct=%s): %s' % |
| + (str(pxocl), str(dcl), page.url)) |