Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import base64 | 5 import base64 |
| 6 import logging | 6 import logging |
| 7 import urlparse | 7 import urlparse |
| 8 | 8 |
| 9 from integration_tests import chrome_proxy_metrics as metrics | 9 from integration_tests import chrome_proxy_metrics as metrics |
| 10 from metrics import loading | 10 from metrics import loading |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 class ChromeProxyBypass(ChromeProxyValidation): | 105 class ChromeProxyBypass(ChromeProxyValidation): |
| 106 """Correctness measurement for bypass responses.""" | 106 """Correctness measurement for bypass responses.""" |
| 107 | 107 |
| 108 def __init__(self): | 108 def __init__(self): |
| 109 super(ChromeProxyBypass, self).__init__(restart_after_each_page=True) | 109 super(ChromeProxyBypass, self).__init__(restart_after_each_page=True) |
| 110 | 110 |
| 111 def AddResults(self, tab, results): | 111 def AddResults(self, tab, results): |
| 112 self._metrics.AddResultsForBypass(tab, results) | 112 self._metrics.AddResultsForBypass(tab, results) |
| 113 | 113 |
| 114 | 114 |
| 115 class ChromeProxyFallback(ChromeProxyValidation): | |
| 116 """Correctness measurement for bypass responses.""" | |
|
bengr
2014/10/17 23:24:07
Can you be more specific?
sclittle
2014/10/17 23:42:33
Done.
| |
| 117 | |
| 118 def __init__(self): | |
| 119 super(ChromeProxyFallback, self).__init__(restart_after_each_page=True) | |
| 120 | |
| 121 def AddResults(self, tab, results): | |
| 122 self._metrics.AddResultsForFallback(tab, results) | |
| 123 | |
| 124 | |
| 115 class ChromeProxyCorsBypass(ChromeProxyValidation): | 125 class ChromeProxyCorsBypass(ChromeProxyValidation): |
| 116 """Correctness measurement for bypass responses.""" | 126 """Correctness measurement for bypass responses.""" |
| 117 | 127 |
| 118 def __init__(self): | 128 def __init__(self): |
| 119 super(ChromeProxyCorsBypass, self).__init__(restart_after_each_page=True) | 129 super(ChromeProxyCorsBypass, self).__init__(restart_after_each_page=True) |
| 120 | 130 |
| 121 def ValidateAndMeasurePage(self, page, tab, results): | 131 def ValidateAndMeasurePage(self, page, tab, results): |
| 122 # The test page sets window.xhrRequestCompleted to true when the XHR fetch | 132 # The test page sets window.xhrRequestCompleted to true when the XHR fetch |
| 123 # finishes. | 133 # finishes. |
| 124 tab.WaitForJavaScriptExpression('window.xhrRequestCompleted', 15000) | 134 tab.WaitForJavaScriptExpression('window.xhrRequestCompleted', 15000) |
| 125 super(ChromeProxyCorsBypass, | 135 super(ChromeProxyCorsBypass, |
| 126 self).ValidateAndMeasurePag1Ge(page, tab, results) | 136 self).ValidateAndMeasurePage(page, tab, results) |
| 127 | 137 |
| 128 def AddResults(self, tab, results): | 138 def AddResults(self, tab, results): |
| 129 self._metrics.AddResultsForCorsBypass(tab, results) | 139 self._metrics.AddResultsForCorsBypass(tab, results) |
| 130 | 140 |
| 131 | 141 |
| 132 class ChromeProxyBlockOnce(ChromeProxyValidation): | 142 class ChromeProxyBlockOnce(ChromeProxyValidation): |
| 133 """Correctness measurement for block-once responses.""" | 143 """Correctness measurement for block-once responses.""" |
| 134 | 144 |
| 135 def __init__(self): | 145 def __init__(self): |
| 136 super(ChromeProxyBlockOnce, self).__init__(restart_after_each_page=True) | 146 super(ChromeProxyBlockOnce, self).__init__(restart_after_each_page=True) |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 156 _FAKE_PROXY_AUTH_VALUE = 'aabbccdd3b7579186c1b0620614fdb1f0000ffff' | 166 _FAKE_PROXY_AUTH_VALUE = 'aabbccdd3b7579186c1b0620614fdb1f0000ffff' |
| 157 _TEST_SERVER = 'chromeproxy-test.appspot.com' | 167 _TEST_SERVER = 'chromeproxy-test.appspot.com' |
| 158 _TEST_SERVER_DEFAULT_URL = 'http://' + _TEST_SERVER + '/default' | 168 _TEST_SERVER_DEFAULT_URL = 'http://' + _TEST_SERVER + '/default' |
| 159 | 169 |
| 160 | 170 |
| 161 # We rely on the chromeproxy-test server to facilitate some of the tests. | 171 # We rely on the chromeproxy-test server to facilitate some of the tests. |
| 162 # The test server code is at <TBD location> and runs at _TEST_SERVER | 172 # The test server code is at <TBD location> and runs at _TEST_SERVER |
| 163 # | 173 # |
| 164 # The test server allow request to override response status, headers, and | 174 # The test server allow request to override response status, headers, and |
| 165 # body through query parameters. See GetResponseOverrideURL. | 175 # body through query parameters. See GetResponseOverrideURL. |
| 166 def GetResponseOverrideURL(url, respStatus=0, respHeader="", respBody=""): | 176 def GetResponseOverrideURL(url=_TEST_SERVER_DEFAULT_URL, respStatus=0, |
| 177 respHeader="", respBody=""): | |
| 167 """ Compose the request URL with query parameters to override | 178 """ Compose the request URL with query parameters to override |
| 168 the chromeproxy-test server response. | 179 the chromeproxy-test server response. |
| 169 """ | 180 """ |
| 170 | 181 |
| 171 queries = [] | 182 queries = [] |
| 172 if respStatus > 0: | 183 if respStatus > 0: |
| 173 queries.append('respStatus=%d' % respStatus) | 184 queries.append('respStatus=%d' % respStatus) |
| 174 if respHeader: | 185 if respHeader: |
| 175 queries.append('respHeader=%s' % base64.b64encode(respHeader)) | 186 queries.append('respHeader=%s' % base64.b64encode(respHeader)) |
| 176 if respBody: | 187 if respBody: |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 194 | 205 |
| 195 def __init__(self): | 206 def __init__(self): |
| 196 super(ChromeProxyHTTPFallbackProbeURL, self).__init__() | 207 super(ChromeProxyHTTPFallbackProbeURL, self).__init__() |
| 197 | 208 |
| 198 def CustomizeBrowserOptions(self, options): | 209 def CustomizeBrowserOptions(self, options): |
| 199 super(ChromeProxyHTTPFallbackProbeURL, | 210 super(ChromeProxyHTTPFallbackProbeURL, |
| 200 self).CustomizeBrowserOptions(options) | 211 self).CustomizeBrowserOptions(options) |
| 201 # Use the test server probe URL which returns the response | 212 # Use the test server probe URL which returns the response |
| 202 # body as specified by respBody. | 213 # body as specified by respBody. |
| 203 probe_url = GetResponseOverrideURL( | 214 probe_url = GetResponseOverrideURL( |
| 204 _TEST_SERVER_DEFAULT_URL, | |
| 205 respBody='not OK') | 215 respBody='not OK') |
| 206 options.AppendExtraBrowserArgs( | 216 options.AppendExtraBrowserArgs( |
| 207 '--data-reduction-proxy-probe-url=%s' % probe_url) | 217 '--data-reduction-proxy-probe-url=%s' % probe_url) |
| 208 | 218 |
| 209 def AddResults(self, tab, results): | 219 def AddResults(self, tab, results): |
| 210 self._metrics.AddResultsForHTTPFallback(tab, results) | 220 self._metrics.AddResultsForHTTPFallback(tab, results) |
| 211 | 221 |
| 212 | 222 |
| 213 class ChromeProxyHTTPFallbackViaHeader(ChromeProxyValidation): | 223 class ChromeProxyHTTPFallbackViaHeader(ChromeProxyValidation): |
| 214 """Correctness measurement for proxy fallback. | 224 """Correctness measurement for proxy fallback. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 self._metrics.effective_proxies['proxy'], | 287 self._metrics.effective_proxies['proxy'], |
| 278 self._metrics.effective_proxies['fallback'], | 288 self._metrics.effective_proxies['fallback'], |
| 279 self._metrics.effective_proxies['direct']] | 289 self._metrics.effective_proxies['direct']] |
| 280 bad_proxies = [self._metrics.effective_proxies['proxy']] | 290 bad_proxies = [self._metrics.effective_proxies['proxy']] |
| 281 self._metrics.VerifyProxyInfo(tab, proxies, bad_proxies) | 291 self._metrics.VerifyProxyInfo(tab, proxies, bad_proxies) |
| 282 | 292 |
| 283 def AddResults(self, tab, results): | 293 def AddResults(self, tab, results): |
| 284 self._metrics.AddResultsForHTTPToDirectFallback(tab, results) | 294 self._metrics.AddResultsForHTTPToDirectFallback(tab, results) |
| 285 | 295 |
| 286 | 296 |
| 297 class ChromeProxyExplicitBypass(ChromeProxyValidation): | |
| 298 """Correctness measurement for explicit proxy bypasses. | |
| 299 | |
| 300 In this test, the configured proxy is the chromeproxy-test server which | |
| 301 will send back a response without the expected Via header. Chrome is | |
| 302 expected to use the fallback proxy and add the configured proxy to the | |
| 303 bad proxy list. | |
| 304 """ | |
| 305 | |
| 306 def __init__(self): | |
| 307 super(ChromeProxyExplicitBypass, self).__init__( | |
| 308 restart_after_each_page=True) | |
| 309 | |
| 310 def CustomizeBrowserOptions(self, options): | |
| 311 super(ChromeProxyExplicitBypass, | |
| 312 self).CustomizeBrowserOptions(options) | |
| 313 options.AppendExtraBrowserArgs('--ignore-certificate-errors') | |
| 314 options.AppendExtraBrowserArgs( | |
| 315 '--spdy-proxy-auth-origin=http://%s' % _TEST_SERVER) | |
| 316 options.AppendExtraBrowserArgs( | |
| 317 '--spdy-proxy-auth-value=%s' % _FAKE_PROXY_AUTH_VALUE) | |
| 318 | |
| 319 def AddResults(self, tab, results): | |
| 320 bad_proxies = [{ | |
| 321 'proxy': _TEST_SERVER + ':80', | |
| 322 'retry_seconds_low': self._page.bypass_seconds_low, | |
| 323 'retry_seconds_high': self._page.bypass_seconds_high | |
| 324 }] | |
| 325 if self._page.num_bypassed_proxies == 2: | |
| 326 bad_proxies.append({ | |
| 327 'proxy': self._metrics.effective_proxies['fallback'], | |
| 328 'retry_seconds_low': self._page.bypass_seconds_low, | |
| 329 'retry_seconds_high': self._page.bypass_seconds_high | |
| 330 }) | |
| 331 else: | |
| 332 # Even if the test page only causes the primary proxy to be bypassed, | |
| 333 # Chrome will attempt to fetch the favicon for the test server through | |
| 334 # the data reduction proxy, which will cause a "block=0" bypass. | |
| 335 bad_proxies.append({'proxy': self._metrics.effective_proxies['fallback']}) | |
| 336 | |
| 337 self._metrics.AddResultsForExplicitBypass(tab, results, bad_proxies) | |
| 338 | |
| 339 | |
| 287 class ChromeProxySmoke(ChromeProxyValidation): | 340 class ChromeProxySmoke(ChromeProxyValidation): |
| 288 """Smoke measurement for basic chrome proxy correctness.""" | 341 """Smoke measurement for basic chrome proxy correctness.""" |
| 289 | 342 |
| 290 def __init__(self): | 343 def __init__(self): |
| 291 super(ChromeProxySmoke, self).__init__() | 344 super(ChromeProxySmoke, self).__init__() |
| 292 | 345 |
| 293 def WillNavigateToPage(self, page, tab): | 346 def WillNavigateToPage(self, page, tab): |
| 294 super(ChromeProxySmoke, self).WillNavigateToPage(page, tab) | 347 super(ChromeProxySmoke, self).WillNavigateToPage(page, tab) |
| 295 if page.name == 'safebrowsing': | 348 if page.name == 'safebrowsing': |
| 296 self._expect_timeout = True | 349 self._expect_timeout = True |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 313 ], | 366 ], |
| 314 'bypass': [self._metrics.AddResultsForBypass], | 367 'bypass': [self._metrics.AddResultsForBypass], |
| 315 'safebrowsing': [self._metrics.AddResultsForSafebrowsing], | 368 'safebrowsing': [self._metrics.AddResultsForSafebrowsing], |
| 316 } | 369 } |
| 317 if not self._page.name in page_to_metrics: | 370 if not self._page.name in page_to_metrics: |
| 318 raise page_test.MeasurementFailure( | 371 raise page_test.MeasurementFailure( |
| 319 'Invalid page name (%s) in smoke. Page name must be one of:\n%s' % ( | 372 'Invalid page name (%s) in smoke. Page name must be one of:\n%s' % ( |
| 320 self._page.name, page_to_metrics.keys())) | 373 self._page.name, page_to_metrics.keys())) |
| 321 for add_result in page_to_metrics[self._page.name]: | 374 for add_result in page_to_metrics[self._page.name]: |
| 322 add_result(tab, results) | 375 add_result(tab, results) |
| OLD | NEW |