summaryrefslogtreecommitdiffstats
path: root/tools/chrome_proxy
diff options
context:
space:
mode:
authormegjablon <megjablon@chromium.org>2016-01-11 15:58:53 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-12 00:00:11 +0000
commit6a9df570651a29b89144ecdb667e712c2018b2ac (patch)
tree784e33d09c0f81a91b3a25677e276fe1e18cbfa4 /tools/chrome_proxy
parent6638b181d6932c55eda534dc84c00f49f961e082 (diff)
downloadchromium_src-6a9df570651a29b89144ecdb667e712c2018b2ac.zip
chromium_src-6a9df570651a29b89144ecdb667e712c2018b2ac.tar.gz
chromium_src-6a9df570651a29b89144ecdb667e712c2018b2ac.tar.bz2
Integration test for Lo-Fi previews
Tests that the q=preview request header is sent and a preview page is served when Lo-Fi previews are enabled. BUG=558629 Review URL: https://codereview.chromium.org/1578863003 Cr-Commit-Position: refs/heads/master@{#368724}
Diffstat (limited to 'tools/chrome_proxy')
-rw-r--r--tools/chrome_proxy/common/chrome_proxy_metrics.py6
-rw-r--r--tools/chrome_proxy/integration_tests/chrome_proxy_benchmark.py11
-rw-r--r--tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py18
-rw-r--r--tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py76
-rw-r--r--tools/chrome_proxy/integration_tests/chrome_proxy_pagesets/lo_fi_preview.py30
5 files changed, 126 insertions, 15 deletions
diff --git a/tools/chrome_proxy/common/chrome_proxy_metrics.py b/tools/chrome_proxy/common/chrome_proxy_metrics.py
index 791d510..076e89b 100644
--- a/tools/chrome_proxy/common/chrome_proxy_metrics.py
+++ b/tools/chrome_proxy/common/chrome_proxy_metrics.py
@@ -103,5 +103,11 @@ class ChromeProxyResponse(network_metrics.HTTPResponse):
def HasChromeProxyLoFiResponse(self):
return self.HasResponseHeader('Chrome-Proxy', "q=low")
+ def HasChromeProxyLoFiPreviewRequest(self):
+ return self.HasRequestHeader('Chrome-Proxy', "q=preview")
+
+ def HasChromeProxyLoFiPreviewResponse(self):
+ return self.HasResponseHeader('Chrome-Proxy', "q=preview")
+
def HasChromeProxyPassThroughRequest(self):
return self.HasRequestHeader('Chrome-Proxy', "pass-through")
diff --git a/tools/chrome_proxy/integration_tests/chrome_proxy_benchmark.py b/tools/chrome_proxy/integration_tests/chrome_proxy_benchmark.py
index 759c94c..e095331 100644
--- a/tools/chrome_proxy/integration_tests/chrome_proxy_benchmark.py
+++ b/tools/chrome_proxy/integration_tests/chrome_proxy_benchmark.py
@@ -41,6 +41,17 @@ class ChromeProxyLoFi(ChromeProxyBenchmark):
return 'chrome_proxy_benchmark.lo_fi.lo_fi'
+@benchmark.Disabled(*WEBVIEW_PLATFORMS)
+class ChromeProxyPreviewLoFi(ChromeProxyBenchmark):
+ tag = 'lo_fi_preview'
+ test = measurements.ChromeProxyLoFiPreview
+ page_set = pagesets.LoFiPreviewStorySet
+
+ @classmethod
+ def Name(cls):
+ return 'chrome_proxy_benchmark.lo_fi_preview.lo_fi_preview'
+
+
class ChromeProxyExpDirective(ChromeProxyBenchmark):
tag = 'exp_directive'
test = measurements.ChromeProxyExpDirective
diff --git a/tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py b/tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py
index 61ebe23..26437a2 100644
--- a/tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py
+++ b/tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py
@@ -300,6 +300,24 @@ class ChromeProxyLoFi(ChromeProxyValidation):
def AddResults(self, tab, results):
self._metrics.AddResultsForLoFi(tab, results)
+class ChromeProxyLoFiPreview(ChromeProxyValidation):
+ """Correctness measurement for Lo-Fi preview in Chrome-Proxy header."""
+
+ def __init__(self):
+ super(ChromeProxyLoFiPreview, self).__init__(
+ restart_after_each_page=True,
+ metrics=metrics.ChromeProxyMetric())
+
+ def CustomizeBrowserOptions(self, options):
+ super(ChromeProxyLoFiPreview, self).CustomizeBrowserOptions(options)
+ options.AppendExtraBrowserArgs(
+ '--data-reduction-proxy-lo-fi=always-on')
+ options.AppendExtraBrowserArgs(
+ '--enable-data-reduction-proxy-lo-fi-preview')
+
+ def AddResults(self, tab, results):
+ self._metrics.AddResultsForLoFiPreview(tab, results)
+
class ChromeProxyExpDirective(ChromeProxyValidation):
"""Correctness measurement for experiment directives in Chrome-Proxy header.
diff --git a/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py b/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py
index 8ec7f81..03b71a2 100644
--- a/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py
+++ b/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py
@@ -109,7 +109,7 @@ class ChromeProxyMetric(network_metrics.NetworkMetric):
results.current_page, 'load_start', 'ms', load_start))
dom_content_loaded_start = (
- float(dom_content_loaded_event_start) - navigation_start)
+ float(dom_content_loaded_event_start) - navigation_start)
results.AddValue(scalar.ScalarValue(
results.current_page, 'dom_content_loaded_start', 'ms',
dom_content_loaded_start))
@@ -275,6 +275,51 @@ class ChromeProxyMetric(network_metrics.NetworkMetric):
results.current_page, 'lo_fi_response', 'count', lo_fi_response_count))
super(ChromeProxyMetric, self).AddResults(tab, results)
+ def AddResultsForLoFiPreview(self, tab, results):
+ lo_fi_request_count = 0
+ lo_fi_preview_request_count = 0
+ lo_fi_preview_response_count = 0
+
+ for resp in self.IterResponses(tab):
+ if 'favicon.ico' in resp.response.url:
+ continue
+ if resp.response.url.startswith('data:'):
+ continue
+
+ if resp.HasChromeProxyLoFiPreviewRequest():
+ lo_fi_preview_request_count += 1
+ elif resp.HasChromeProxyLoFiRequest():
+ lo_fi_request_count += 1
+ else:
+ raise ChromeProxyMetricException, (
+ '%s: LoFi not in request header.' % (resp.response.url))
+
+ if resp.HasChromeProxyLoFiPreviewResponse():
+ lo_fi_preview_response_count += 1
+
+ if lo_fi_preview_request_count == 0:
+ raise ChromeProxyMetricException, (
+ 'Expected at least one LoFi preview request, but zero such requests '
+ 'were sent.')
+ if lo_fi_preview_response_count == 0:
+ raise ChromeProxyMetricException, (
+ 'Expected at least one LoFi preview response, but zero such '
+ 'responses were received.')
+
+ results.AddValue(
+ scalar.ScalarValue(
+ results.current_page, 'lo_fi_preview_request',
+ 'count', lo_fi_preview_request_count))
+ results.AddValue(
+ scalar.ScalarValue(
+ results.current_page, 'lo_fi_request',
+ 'count', lo_fi_request_count))
+ results.AddValue(
+ scalar.ScalarValue(
+ results.current_page, 'lo_fi_preview_response',
+ 'count', lo_fi_preview_response_count))
+ super(ChromeProxyMetric, self).AddResults(tab, results)
+
def AddResultsForPassThrough(self, tab, results):
compressed_count = 0
compressed_size = 0
@@ -307,10 +352,10 @@ class ChromeProxyMetric(network_metrics.NetworkMetric):
'received.' % (compressed_count))
if compressed_size >= pass_through_size:
- raise ChromeProxyMetricException, (
- 'Compressed image is %d bytes and pass-through image is %d. '
- 'Expecting compressed image size to be less than pass-through '
- 'image.' % (compressed_size, pass_through_size))
+ raise ChromeProxyMetricException, (
+ 'Compressed image is %d bytes and pass-through image is %d. '
+ 'Expecting compressed image size to be less than pass-through '
+ 'image.' % (compressed_size, pass_through_size))
results.AddValue(scalar.ScalarValue(
results.current_page, 'compressed', 'count', compressed_count))
@@ -337,7 +382,6 @@ class ChromeProxyMetric(network_metrics.NetworkMetric):
r.url, r.GetHeader('Via'), r.GetHeader('Referer'), r.status))
bypass_count += 1
-
if bypass_count == 0:
raise ChromeProxyMetricException, (
'Expected at least one https response was expected, but zero such '
@@ -409,10 +453,10 @@ class ChromeProxyMetric(network_metrics.NetworkMetric):
for url in bypasses:
if bypasses[url] == 0:
raise ChromeProxyMetricException, (
- '%s: Got a 502 without a subsequent 200' % (url))
+ '%s: Got a 502 without a subsequent 200' % (url))
elif bypasses[url] > 1:
raise ChromeProxyMetricException, (
- '%s: Got a 502 and multiple 200s: %d' % (url, bypasses[url]))
+ '%s: Got a 502 and multiple 200s: %d' % (url, bypasses[url]))
if bypass_count == 0:
raise ChromeProxyMetricException, (
'At least one response should be bypassed. '
@@ -453,8 +497,7 @@ class ChromeProxyMetric(network_metrics.NetworkMetric):
' test URLs. Expected: 2, Actual: ' + str(eligible_response_count))
results.AddValue(scalar.ScalarValue(results.current_page,
- 'eligible_responses', 'count', 2))
-
+ 'eligible_responses', 'count', 2))
def AddResultsForSafebrowsingOn(self, tab, results):
results.AddValue(scalar.ScalarValue(
@@ -521,8 +564,8 @@ class ChromeProxyMetric(network_metrics.NetworkMetric):
raise ChromeProxyMetricException, (
'Response for %s should have come through the fallback proxy.\n'
'Response: remote_port=%s status=(%d, %s)\nHeaders:\n %s' % (
- r.url, str(resp.remote_port), r.status, r.status_text,
- r.headers))
+ r.url, str(resp.remote_port), r.status, r.status_text,
+ r.headers))
else:
via_fallback_count += 1
resp = next(responses, None)
@@ -659,6 +702,7 @@ class ChromeProxyMetric(network_metrics.NetworkMetric):
PROXIED = 'proxied'
DIRECT = 'direct'
+
class ChromeProxyVideoMetric(network_metrics.NetworkMetric):
"""Metrics for video pages.
@@ -750,12 +794,14 @@ class ChromeProxyVideoMetric(network_metrics.NetworkMetric):
err('%s: missing video response' % kind)
# Finally, add all the metrics to the results.
- for (k,v) in self.videoMetrics.iteritems():
+ for (k, v) in self.videoMetrics.iteritems():
k = "%s_%s" % (k, kind)
results.AddValue(scalar.ScalarValue(results.current_page, k, "", v))
+
class ChromeProxyInstrumentedVideoMetric(Metric):
"""Metric for pages instrumented to evaluate video transcoding."""
+
def __init__(self):
super(ChromeProxyInstrumentedVideoMetric, self).__init__()
@@ -766,7 +812,7 @@ class ChromeProxyInstrumentedVideoMetric(Metric):
def AddResults(self, tab, results):
metrics = tab.EvaluateJavaScript('test.metrics')
- for (k,v) in metrics.iteritems():
+ for (k, v) in metrics.iteritems():
results.AddValue(scalar.ScalarValue(results.current_page, k, '', v))
try:
complete = metrics['complete']
@@ -776,7 +822,7 @@ class ChromeProxyInstrumentedVideoMetric(Metric):
if failed:
raise ChromeProxyMetricException, 'failed'
except KeyError:
- raise ChromeProxyMetricException, 'No metrics found'
+ raise ChromeProxyMetricException, 'No metrics found'
# Returns whether |url| is a block-once test URL. Data Reduction Proxy has been
# configured to always return block-once for these URLs.
diff --git a/tools/chrome_proxy/integration_tests/chrome_proxy_pagesets/lo_fi_preview.py b/tools/chrome_proxy/integration_tests/chrome_proxy_pagesets/lo_fi_preview.py
new file mode 100644
index 0000000..61b0071
--- /dev/null
+++ b/tools/chrome_proxy/integration_tests/chrome_proxy_pagesets/lo_fi_preview.py
@@ -0,0 +1,30 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from telemetry.page import page as page_module
+from telemetry import story
+
+
+class LoFiPreviewPage(page_module.Page):
+ """
+ A test page for the chrome proxy Lo-Fi preview tests.
+ Checks that a LoFi preview page is served.
+ """
+
+ def __init__(self, url, page_set):
+ super(LoFiPreviewPage, self).__init__(url=url, page_set=page_set)
+
+
+class LoFiPreviewStorySet(story.StorySet):
+ """ Chrome proxy test sites """
+
+ def __init__(self):
+ super(LoFiPreviewStorySet, self).__init__()
+
+ urls_list = [
+ 'http://check.googlezip.net/test.html',
+ ]
+
+ for url in urls_list:
+ self.AddStory(LoFiPreviewPage(url, self))