| 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 AddResultsForBypassOnTimeout(self, tab, results): |
| 876 bypass_count = 0 |
| 877 # Wait maximum of 120 seconds for test to complete. Should complete soon |
| 878 # after 90 second test server delay in case of failure, and much sooner in |
| 879 # case of success. |
| 880 tab.WaitForDocumentReadyStateToBeComplete(timeout=120) |
| 881 for resp in self.IterResponses(tab): |
| 882 if resp.HasChromeProxyViaHeader() and not resp.response.url.endswith( |
| 883 'favicon.ico'): |
| 884 r = resp.response |
| 885 raise ChromeProxyMetricException, ( |
| 886 'Response for %s should not have via header after HTTP timeout.\n' |
| 887 'Reponse: status=(%d)\nHeaders:\n %s' % ( |
| 888 r.url, r.status, r.headers)) |
| 889 elif not resp.response.url.endswith('favicon.ico'): |
| 890 bypass_count += 1 |
| 891 if bypass_count == 0: |
| 892 raise ChromeProxyMetricException('No pages were tested!') |
| 893 results.AddValue(scalar.ScalarValue( |
| 894 results.current_page, 'bypass', 'count', bypass_count)) |
| 895 |
| 875 PROXIED = 'proxied' | 896 PROXIED = 'proxied' |
| 876 DIRECT = 'direct' | 897 DIRECT = 'direct' |
| 877 | 898 |
| 878 | 899 |
| 879 class ChromeProxyVideoMetric(network_metrics.NetworkMetric): | 900 class ChromeProxyVideoMetric(network_metrics.NetworkMetric): |
| 880 """Metrics for video pages. | 901 """Metrics for video pages. |
| 881 | 902 |
| 882 Wraps the video metrics produced by videowrapper.js, such as the video | 903 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 | 904 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. | 905 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: | 1018 except KeyError: |
| 998 raise ChromeProxyMetricException, 'No metrics found' | 1019 raise ChromeProxyMetricException, 'No metrics found' |
| 999 | 1020 |
| 1000 # Returns whether |url| is a block-once test URL. Data Reduction Proxy has been | 1021 # Returns whether |url| is a block-once test URL. Data Reduction Proxy has been |
| 1001 # configured to always return block-once for these URLs. | 1022 # configured to always return block-once for these URLs. |
| 1002 def IsTestUrlForBlockOnce(url): | 1023 def IsTestUrlForBlockOnce(url): |
| 1003 return (url == 'http://check.googlezip.net/blocksingle/' or | 1024 return (url == 'http://check.googlezip.net/blocksingle/' or |
| 1004 url == ('http://chromeproxy-test.appspot.com/default?respBody=T0s=' | 1025 url == ('http://chromeproxy-test.appspot.com/default?respBody=T0s=' |
| 1005 '&respHeader=eyJBY2Nlc3MtQ29udHJvbC1BbGxvdy1PcmlnaW4iOlsiKiJ' | 1026 '&respHeader=eyJBY2Nlc3MtQ29udHJvbC1BbGxvdy1PcmlnaW4iOlsiKiJ' |
| 1006 'dfQ==&respStatus=200&flywheelAction=block-once')) | 1027 'dfQ==&respStatus=200&flywheelAction=block-once')) |
| OLD | NEW |