Commit d8c12436 authored by bustamante's avatar bustamante Committed by Commit bot

Update experiment test to only verify /exptest/... are bypassed

The exp_directive test verifies the experiment flag is passed to the
page, by bypassing any request to http://aws1.mdw.la/exptest/... when
the flag --data-reduction-proxy-experiment=test is set.  Which works
as expected.

However the favicon request from http://aws1.mdw.la/favicon.ico won't
be bypassed, causing the test to fail.  To fix the test, I'm adding an
optional url_pattern parameter to the bypass verification, that will
verify only /exptest/ urls are checked.

BUG=488232

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

Cr-Commit-Position: refs/heads/master@{#330644}
parent 4d7a267e
...@@ -288,7 +288,7 @@ class ChromeProxyExpDirective(ChromeProxyValidation): ...@@ -288,7 +288,7 @@ class ChromeProxyExpDirective(ChromeProxyValidation):
options.AppendExtraBrowserArgs('--data-reduction-proxy-experiment=test') options.AppendExtraBrowserArgs('--data-reduction-proxy-experiment=test')
def AddResults(self, tab, results): def AddResults(self, tab, results):
self._metrics.AddResultsForBypass(tab, results) self._metrics.AddResultsForBypass(tab, results, url_pattern='/exptest/')
class ChromeProxyHTTPToDirectFallback(ChromeProxyValidation): class ChromeProxyHTTPToDirectFallback(ChromeProxyValidation):
......
...@@ -261,10 +261,16 @@ class ChromeProxyMetric(network_metrics.NetworkMetric): ...@@ -261,10 +261,16 @@ class ChromeProxyMetric(network_metrics.NetworkMetric):
results.current_page, 'lo_fi_response', 'count', lo_fi_response_count)) results.current_page, 'lo_fi_response', 'count', lo_fi_response_count))
super(ChromeProxyMetric, self).AddResults(tab, results) super(ChromeProxyMetric, self).AddResults(tab, results)
def AddResultsForBypass(self, tab, results): def AddResultsForBypass(self, tab, results, url_pattern=""):
bypass_count = 0 bypass_count = 0
skipped_count = 0
for resp in self.IterResponses(tab): for resp in self.IterResponses(tab):
# Only check the url's that contain the specified pattern.
if url_pattern and url_pattern not in resp.response.url:
skipped_count += 1
continue
if resp.HasChromeProxyViaHeader(): if resp.HasChromeProxyViaHeader():
r = resp.response r = resp.response
raise ChromeProxyMetricException, ( raise ChromeProxyMetricException, (
...@@ -276,8 +282,11 @@ class ChromeProxyMetric(network_metrics.NetworkMetric): ...@@ -276,8 +282,11 @@ class ChromeProxyMetric(network_metrics.NetworkMetric):
raise ChromeProxyMetricException, ( raise ChromeProxyMetricException, (
'Expected at least one response to be bypassed, but zero such ' 'Expected at least one response to be bypassed, but zero such '
'responses were received.') 'responses were received.')
results.AddValue(scalar.ScalarValue( results.AddValue(scalar.ScalarValue(
results.current_page, 'bypass', 'count', bypass_count)) results.current_page, 'bypass', 'count', bypass_count))
results.AddValue(scalar.ScalarValue(
results.current_page, 'skipped', 'count', skipped_count))
def AddResultsForCorsBypass(self, tab, results): def AddResultsForCorsBypass(self, tab, results):
eligible_response_count = 0 eligible_response_count = 0
......
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