| 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 logging | 5 import logging |
| 6 import os | 6 import os |
| 7 import time | 7 import time |
| 8 | 8 |
| 9 from common import chrome_proxy_metrics | 9 from common import chrome_proxy_metrics |
| 10 from common import network_metrics | 10 from common import network_metrics |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 'Expected 1 pingback success and no failures, but ' | 865 'Expected 1 pingback success and no failures, but ' |
| 866 'there were %d succesful pingbacks and %d failed pingback attempts' | 866 'there were %d succesful pingbacks and %d failed pingback attempts' |
| 867 % (succeeded, count - succeeded)) | 867 % (succeeded, count - succeeded)) |
| 868 results.AddValue(scalar.ScalarValue( | 868 results.AddValue(scalar.ScalarValue( |
| 869 results.current_page, 'attempted', 'count', attempted)) | 869 results.current_page, 'attempted', 'count', attempted)) |
| 870 results.AddValue(scalar.ScalarValue( | 870 results.AddValue(scalar.ScalarValue( |
| 871 results.current_page, 'succeeded_count', 'count', count)) | 871 results.current_page, 'succeeded_count', 'count', count)) |
| 872 results.AddValue(scalar.ScalarValue( | 872 results.AddValue(scalar.ScalarValue( |
| 873 results.current_page, 'succeeded_sum', 'count', succeeded)) | 873 results.current_page, 'succeeded_sum', 'count', succeeded)) |
| 874 | 874 |
| 875 def AddResultsForClientBypassOnTimeout(self, tab, results): |
| 876 bypass_count = 0 |
| 877 tab.WaitForDocumentReadyStateToBeComplete(timeout=30) |
| 878 for resp in self.IterResponses(tab): |
| 879 if resp.HasChromeProxyViaHeader(): |
| 880 r = resp.response |
| 881 raise ChromeProxyMetricException, ( |
| 882 'Response for %s should not have via header after proxy timeout.\n' |
| 883 'Reponse: status=(%d, %s)\nHeaders:\n %s' % ( |
| 884 r.url, r.status, r.status_text, r.headers)) |
| 885 else: |
| 886 bypass_count += 1 |
| 887 if bypass_count == 0: |
| 888 raise ChromeProxyMetricException('No pages were tested!') |
| 889 results.AddValue(scalar.ScalarValue( |
| 890 results.current_page, 'bypass', 'count', bypass_count)) |
| 891 |
| 875 PROXIED = 'proxied' | 892 PROXIED = 'proxied' |
| 876 DIRECT = 'direct' | 893 DIRECT = 'direct' |
| 877 | 894 |
| 878 | 895 |
| 879 class ChromeProxyVideoMetric(network_metrics.NetworkMetric): | 896 class ChromeProxyVideoMetric(network_metrics.NetworkMetric): |
| 880 """Metrics for video pages. | 897 """Metrics for video pages. |
| 881 | 898 |
| 882 Wraps the video metrics produced by videowrapper.js, such as the video | 899 Wraps the video metrics produced by videowrapper.js, such as the video |
| 883 duration and size in pixels. Also checks a few basic HTTP response headers | 900 duration and size in pixels. Also checks a few basic HTTP response headers |
| 884 such as Content-Type and Content-Length in the video responses. | 901 such as Content-Type and Content-Length in the video responses. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 except KeyError: | 1014 except KeyError: |
| 998 raise ChromeProxyMetricException, 'No metrics found' | 1015 raise ChromeProxyMetricException, 'No metrics found' |
| 999 | 1016 |
| 1000 # Returns whether |url| is a block-once test URL. Data Reduction Proxy has been | 1017 # Returns whether |url| is a block-once test URL. Data Reduction Proxy has been |
| 1001 # configured to always return block-once for these URLs. | 1018 # configured to always return block-once for these URLs. |
| 1002 def IsTestUrlForBlockOnce(url): | 1019 def IsTestUrlForBlockOnce(url): |
| 1003 return (url == 'http://check.googlezip.net/blocksingle/' or | 1020 return (url == 'http://check.googlezip.net/blocksingle/' or |
| 1004 url == ('http://chromeproxy-test.appspot.com/default?respBody=T0s=' | 1021 url == ('http://chromeproxy-test.appspot.com/default?respBody=T0s=' |
| 1005 '&respHeader=eyJBY2Nlc3MtQ29udHJvbC1BbGxvdy1PcmlnaW4iOlsiKiJ' | 1022 '&respHeader=eyJBY2Nlc3MtQ29udHJvbC1BbGxvdy1PcmlnaW4iOlsiKiJ' |
| 1006 'dfQ==&respStatus=200&flywheelAction=block-once')) | 1023 'dfQ==&respStatus=200&flywheelAction=block-once')) |
| OLD | NEW |