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 datetime | 5 import datetime |
| 6 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 | 8 |
| 9 from integration_tests import network_metrics | 9 from integration_tests import network_metrics |
| 10 from telemetry.core import util | 10 from telemetry.core import util |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 def AddResultsForBypass(self, tab, results): | 346 def AddResultsForBypass(self, tab, results): |
| 347 bypass_count = 0 | 347 bypass_count = 0 |
| 348 for resp in self.IterResponses(tab): | 348 for resp in self.IterResponses(tab): |
| 349 if resp.HasChromeProxyViaHeader(): | 349 if resp.HasChromeProxyViaHeader(): |
| 350 r = resp.response | 350 r = resp.response |
| 351 raise ChromeProxyMetricException, ( | 351 raise ChromeProxyMetricException, ( |
| 352 '%s: Should not have Via header (%s) (refer=%s, status=%d)' % ( | 352 '%s: Should not have Via header (%s) (refer=%s, status=%d)' % ( |
| 353 r.url, r.GetHeader('Via'), r.GetHeader('Referer'), r.status)) | 353 r.url, r.GetHeader('Via'), r.GetHeader('Referer'), r.status)) |
| 354 bypass_count += 1 | 354 bypass_count += 1 |
| 355 | 355 |
| 356 self.VerifyAllProxiesBypassed(tab) | |
|
bolian
2014/12/09 22:06:14
Not verifying this any more?
sclittle
2014/12/09 22:25:21
Not anymore. The only thing this call gains us her
| |
| 357 results.AddValue(scalar.ScalarValue( | 356 results.AddValue(scalar.ScalarValue( |
| 358 results.current_page, 'bypass', 'count', bypass_count)) | 357 results.current_page, 'bypass', 'count', bypass_count)) |
| 359 | 358 |
| 360 def AddResultsForCorsBypass(self, tab, results): | 359 def AddResultsForCorsBypass(self, tab, results): |
| 361 eligible_response_count = 0 | 360 eligible_response_count = 0 |
| 362 bypass_count = 0 | 361 bypass_count = 0 |
| 363 bypasses = {} | 362 bypasses = {} |
| 364 for resp in self.IterResponses(tab): | 363 for resp in self.IterResponses(tab): |
| 365 logging.warn('got a resource %s' % (resp.response.url)) | 364 logging.warn('got a resource %s' % (resp.response.url)) |
| 366 | 365 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 397 | 396 |
| 398 def AddResultsForBlockOnce(self, tab, results): | 397 def AddResultsForBlockOnce(self, tab, results): |
| 399 eligible_response_count = 0 | 398 eligible_response_count = 0 |
| 400 bypass_count = 0 | 399 bypass_count = 0 |
| 401 for resp in self.IterResponses(tab): | 400 for resp in self.IterResponses(tab): |
| 402 if resp.ShouldHaveChromeProxyViaHeader(): | 401 if resp.ShouldHaveChromeProxyViaHeader(): |
| 403 eligible_response_count += 1 | 402 eligible_response_count += 1 |
| 404 if not resp.HasChromeProxyViaHeader(): | 403 if not resp.HasChromeProxyViaHeader(): |
| 405 bypass_count += 1 | 404 bypass_count += 1 |
| 406 | 405 |
| 407 if tab: | |
| 408 info = GetProxyInfoFromNetworkInternals(tab) | |
| 409 if not info['enabled']: | |
| 410 raise ChromeProxyMetricException, ( | |
| 411 'Chrome proxy should be enabled. proxy info: %s' % info) | |
| 412 self.VerifyBadProxies(info['badProxies'], []) | |
| 413 | |
| 414 if eligible_response_count <= 1: | 406 if eligible_response_count <= 1: |
| 415 raise ChromeProxyMetricException, ( | 407 raise ChromeProxyMetricException, ( |
| 416 'There should be more than one DRP eligible response ' | 408 'There should be more than one DRP eligible response ' |
| 417 '(eligible_response_count=%d, bypass_count=%d)\n' % ( | 409 '(eligible_response_count=%d, bypass_count=%d)\n' % ( |
| 418 eligible_response_count, bypass_count)) | 410 eligible_response_count, bypass_count)) |
| 419 elif bypass_count != 1: | 411 elif bypass_count != 1: |
| 420 raise ChromeProxyMetricException, ( | 412 raise ChromeProxyMetricException, ( |
| 421 'Exactly one response should be bypassed. ' | 413 'Exactly one response should be bypassed. ' |
| 422 '(eligible_response_count=%d, bypass_count=%d)\n' % ( | 414 '(eligible_response_count=%d, bypass_count=%d)\n' % ( |
| 423 eligible_response_count, bypass_count)) | 415 eligible_response_count, bypass_count)) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 472 str(bad_proxies), str(expected_bad_proxies))) | 464 str(bad_proxies), str(expected_bad_proxies))) |
| 473 | 465 |
| 474 def AddResultsForHTTPFallback( | 466 def AddResultsForHTTPFallback( |
| 475 self, tab, results, expected_proxies=None, expected_bad_proxies=None): | 467 self, tab, results, expected_proxies=None, expected_bad_proxies=None): |
| 476 if not expected_proxies: | 468 if not expected_proxies: |
| 477 expected_proxies = [self.effective_proxies['fallback'], | 469 expected_proxies = [self.effective_proxies['fallback'], |
| 478 self.effective_proxies['direct']] | 470 self.effective_proxies['direct']] |
| 479 if not expected_bad_proxies: | 471 if not expected_bad_proxies: |
| 480 expected_bad_proxies = [] | 472 expected_bad_proxies = [] |
| 481 | 473 |
| 474 # TODO(sclittle): Remove this dependency on net-internals#proxy once an | |
| 475 # alternative method of verifying that Chrome is on the fallback proxy | |
| 476 # exists. | |
| 482 self.VerifyProxyInfo(tab, expected_proxies, expected_bad_proxies) | 477 self.VerifyProxyInfo(tab, expected_proxies, expected_bad_proxies) |
| 483 results.AddValue(scalar.ScalarValue( | 478 results.AddValue(scalar.ScalarValue( |
| 484 results.current_page, 'http_fallback', 'boolean', True)) | 479 results.current_page, 'http_fallback', 'boolean', True)) |
| 485 | 480 |
| 486 def AddResultsForHTTPToDirectFallback(self, tab, results): | 481 def AddResultsForHTTPToDirectFallback(self, tab, results): |
| 487 self.VerifyAllProxiesBypassed(tab) | 482 bypass_count = 0 |
| 483 for resp in self.IterResponses(tab): | |
| 484 if resp.HasChromeProxyViaHeader(): | |
| 485 r = resp.response | |
| 486 raise ChromeProxyMetricException, ( | |
| 487 'Response for %s should not have via header. ' | |
| 488 'Reponse: status=(%d, %s)\nHeaders:\n %s' % ( | |
| 489 r.url, r.status, r.status_text, r.headers)) | |
| 490 else: | |
| 491 bypass_count += 1 | |
| 492 | |
| 488 results.AddValue(scalar.ScalarValue( | 493 results.AddValue(scalar.ScalarValue( |
| 489 results.current_page, 'direct_fallback', 'boolean', True)) | 494 results.current_page, 'bypass', 'count', bypass_count)) |
|
bolian
2014/12/09 22:06:14
This result, 'bypass', does not match the func nam
sclittle
2014/12/09 22:25:21
Should it match it? This result is the number of b
| |
| 490 | 495 |
| 491 def AddResultsForExplicitBypass(self, tab, results, expected_bad_proxies): | 496 def AddResultsForExplicitBypass(self, tab, results, expected_bad_proxies): |
| 492 """Verify results for an explicit bypass test. | 497 """Verify results for an explicit bypass test. |
| 493 | 498 |
| 494 Args: | 499 Args: |
| 495 tab: the tab for the test. | 500 tab: the tab for the test. |
| 496 results: the results object to add the results values to. | 501 results: the results object to add the results values to. |
| 497 expected_bad_proxies: A list of dictionary objects representing | 502 expected_bad_proxies: A list of dictionary objects representing |
| 498 expected bad proxies and their expected retry time windows. | 503 expected bad proxies and their expected retry time windows. |
| 499 See the definition of VerifyBadProxies for details. | 504 See the definition of VerifyBadProxies for details. |
| 500 """ | 505 """ |
| 501 info = GetProxyInfoFromNetworkInternals(tab) | 506 info = GetProxyInfoFromNetworkInternals(tab) |
| 502 if not 'enabled' in info or not info['enabled']: | 507 if not 'enabled' in info or not info['enabled']: |
| 503 raise ChromeProxyMetricException, ( | 508 raise ChromeProxyMetricException, ( |
| 504 'Chrome proxy should be enabled. proxy info: %s' % info) | 509 'Chrome proxy should be enabled. proxy info: %s' % info) |
| 510 # TODO(sclittle): Remove this dependency on net-internals#proxy once an | |
| 511 # alternative method of verifying that Chrome is on the fallback proxy | |
| 512 # exists. | |
| 505 self.VerifyBadProxies(info['badProxies'], | 513 self.VerifyBadProxies(info['badProxies'], |
| 506 expected_bad_proxies) | 514 expected_bad_proxies) |
| 507 results.AddValue(scalar.ScalarValue( | 515 results.AddValue(scalar.ScalarValue( |
| 508 results.current_page, 'explicit_bypass', 'boolean', True)) | 516 results.current_page, 'explicit_bypass', 'boolean', True)) |
| OLD | NEW |