Commit b752e88b authored by sclittle's avatar sclittle Committed by Commit bot

Integration test for bypassing the proxy for a single request

This test verifies that the "Chrome-Proxy: block-once" directive for
bypassing the data reduction proxy for just the current request works as
expected.

BUG=404053

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

Cr-Commit-Position: refs/heads/master@{#295197}
parent 365c61ee
...@@ -82,6 +82,12 @@ class ChromeProxyBypass(benchmark.Benchmark): ...@@ -82,6 +82,12 @@ class ChromeProxyBypass(benchmark.Benchmark):
test = measurements.ChromeProxyBypass test = measurements.ChromeProxyBypass
page_set = pagesets.BypassPageSet page_set = pagesets.BypassPageSet
@benchmark.Enabled('android')
class ChromeProxyBlockOnce(benchmark.Benchmark):
tag = 'block_once'
test = measurements.ChromeProxyBlockOnce
page_set = pagesets.BlockOncePageSet
@benchmark.Enabled('android') @benchmark.Enabled('android')
class ChromeProxySafeBrowsing(benchmark.Benchmark): class ChromeProxySafeBrowsing(benchmark.Benchmark):
......
...@@ -112,6 +112,16 @@ class ChromeProxyBypass(ChromeProxyValidation): ...@@ -112,6 +112,16 @@ class ChromeProxyBypass(ChromeProxyValidation):
self._metrics.AddResultsForBypass(tab, results) self._metrics.AddResultsForBypass(tab, results)
class ChromeProxyBlockOnce(ChromeProxyValidation):
"""Correctness measurement for block-once responses."""
def __init__(self):
super(ChromeProxyBlockOnce, self).__init__(restart_after_each_page=True)
def AddResults(self, tab, results):
self._metrics.AddResultsForBlockOnce(tab, results)
class ChromeProxySafebrowsing(ChromeProxyValidation): class ChromeProxySafebrowsing(ChromeProxyValidation):
"""Correctness measurement for safebrowsing.""" """Correctness measurement for safebrowsing."""
......
...@@ -248,6 +248,39 @@ class ChromeProxyMetric(network_metrics.NetworkMetric): ...@@ -248,6 +248,39 @@ class ChromeProxyMetric(network_metrics.NetworkMetric):
results.AddValue(scalar.ScalarValue( results.AddValue(scalar.ScalarValue(
results.current_page, 'bypass', 'count', bypass_count)) results.current_page, 'bypass', 'count', bypass_count))
def AddResultsForBlockOnce(self, tab, results):
eligible_response_count = 0
bypass_count = 0
for resp in self.IterResponses(tab):
if resp.ShouldHaveChromeProxyViaHeader():
eligible_response_count += 1
if not resp.HasChromeProxyViaHeader():
bypass_count += 1
if tab:
info = GetProxyInfoFromNetworkInternals(tab)
if not info['enabled']:
raise ChromeProxyMetricException, (
'Chrome proxy should be enabled. proxy info: %s' % info)
self.VerifyBadProxies(info['badProxies'], [])
if eligible_response_count <= 1:
raise ChromeProxyMetricException, (
'There should be more than one DRP eligible response '
'(eligible_response_count=%d, bypass_count=%d)\n' % (
eligible_response_count, bypass_count))
elif bypass_count != 1:
raise ChromeProxyMetricException, (
'Exactly one response should be bypassed. '
'(eligible_response_count=%d, bypass_count=%d)\n' % (
eligible_response_count, bypass_count))
else:
results.AddValue(scalar.ScalarValue(
results.current_page, 'eligible_responses', 'count',
eligible_response_count))
results.AddValue(scalar.ScalarValue(
results.current_page, 'bypass', 'count', bypass_count))
def AddResultsForSafebrowsing(self, tab, results): def AddResultsForSafebrowsing(self, tab, results):
count = 0 count = 0
safebrowsing_count = 0 safebrowsing_count = 0
......
# Copyright 2014 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.page import page_set as page_set_module
class BlockOncePage(page_module.Page):
def __init__(self, url, page_set):
super(BlockOncePage, self).__init__(url=url, page_set=page_set)
class BlockOncePageSet(page_set_module.PageSet):
""" Chrome proxy test sites """
def __init__(self):
super(BlockOncePageSet, self).__init__()
urls_list = [
'http://check.googlezip.net/blocksingle',
]
for url in urls_list:
self.AddPage(BlockOncePage(url, self))
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