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 json |
5 import logging | 6 import logging |
6 import os | 7 import os |
7 import time | 8 import time |
8 | 9 |
9 from common import chrome_proxy_metrics | 10 from common import chrome_proxy_metrics |
10 from common import network_metrics | 11 from common import network_metrics |
11 from common.chrome_proxy_metrics import ChromeProxyMetricException | 12 from common.chrome_proxy_metrics import ChromeProxyMetricException |
12 from telemetry.page import page_test | 13 from telemetry.page import page_test |
13 from telemetry.value import scalar | 14 from telemetry.value import scalar |
14 from telemetry.value import histogram_util | 15 from telemetry.value import histogram_util |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 'Expected 1 pingback success and no failures, but ' | 866 'Expected 1 pingback success and no failures, but ' |
866 'there were %d succesful pingbacks and %d failed pingback attempts' | 867 'there were %d succesful pingbacks and %d failed pingback attempts' |
867 % (succeeded, count - succeeded)) | 868 % (succeeded, count - succeeded)) |
868 results.AddValue(scalar.ScalarValue( | 869 results.AddValue(scalar.ScalarValue( |
869 results.current_page, 'attempted', 'count', attempted)) | 870 results.current_page, 'attempted', 'count', attempted)) |
870 results.AddValue(scalar.ScalarValue( | 871 results.AddValue(scalar.ScalarValue( |
871 results.current_page, 'succeeded_count', 'count', count)) | 872 results.current_page, 'succeeded_count', 'count', count)) |
872 results.AddValue(scalar.ScalarValue( | 873 results.AddValue(scalar.ScalarValue( |
873 results.current_page, 'succeeded_sum', 'count', succeeded)) | 874 results.current_page, 'succeeded_sum', 'count', succeeded)) |
874 | 875 |
| 876 def AddResultsForQuicTransaction(self, tab, results): |
| 877 histogram_type = histogram_util.BROWSER_HISTOGRAM |
| 878 # This histogram should be synchronously created when the Navigate occurs. |
| 879 # Verify that histogram DataReductionProxy.Quic.ProxyStatus has no samples |
| 880 # in bucket >=1. |
| 881 fail_counts_proxy_status = histogram_util.GetHistogramSum( |
| 882 histogram_type, |
| 883 'DataReductionProxy.Quic.ProxyStatus', |
| 884 tab) |
| 885 if fail_counts_proxy_status != 0: |
| 886 raise ChromeProxyMetricException, ( |
| 887 'fail_counts_proxy_status is %d.' % fail_counts_proxy_status) |
| 888 |
| 889 # Verify that histogram DataReductionProxy.Quic.ProxyStatus has at least 1 |
| 890 # sample. This sample must be in bucket 0 (QUIC_PROXY_STATUS_AVAILABLE). |
| 891 success_counts_proxy_status = histogram_util.GetHistogramCount( |
| 892 histogram_type, |
| 893 'DataReductionProxy.Quic.ProxyStatus', |
| 894 tab) |
| 895 if success_counts_proxy_status <= 0: |
| 896 raise ChromeProxyMetricException, ( |
| 897 'success_counts_proxy_status is %d.' % success_counts_proxy_status) |
| 898 |
| 899 # Navigate to one more page to ensure that established QUIC connection |
| 900 # is used for the next request. Give 1 second extra headroom for the QUIC |
| 901 # connection to be established. |
| 902 time.sleep(1) |
| 903 tab.Navigate('http://check.googlezip.net/test.html') |
| 904 |
| 905 proxy_usage_histogram_json = histogram_util.GetHistogram(histogram_type, |
| 906 'Net.QuicAlternativeProxy.Usage', |
| 907 tab) |
| 908 proxy_usage_histogram = json.loads(proxy_usage_histogram_json) |
| 909 |
| 910 # Bucket ALTERNATIVE_PROXY_USAGE_NO_RACE should have at least one sample. |
| 911 if proxy_usage_histogram['buckets'][0]['count'] <= 0: |
| 912 raise ChromeProxyMetricException, ( |
| 913 'Number of samples in ALTERNATIVE_PROXY_USAGE_NO_RACE bucket is %d.' |
| 914 % proxy_usage_histogram['buckets'][0]['count']) |
| 915 |
| 916 results.AddValue(scalar.ScalarValue( |
| 917 results.current_page, 'fail_counts_proxy_status', 'count', |
| 918 fail_counts_proxy_status)) |
| 919 results.AddValue(scalar.ScalarValue( |
| 920 results.current_page, 'success_counts_proxy_status', 'count', |
| 921 success_counts_proxy_status)) |
| 922 |
875 def AddResultsForBypassOnTimeout(self, tab, results): | 923 def AddResultsForBypassOnTimeout(self, tab, results): |
876 bypass_count = 0 | 924 bypass_count = 0 |
877 # Wait maximum of 120 seconds for test to complete. Should complete soon | 925 # 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 | 926 # after 90 second test server delay in case of failure, and much sooner in |
879 # case of success. | 927 # case of success. |
880 tab.WaitForDocumentReadyStateToBeComplete(timeout=120) | 928 tab.WaitForDocumentReadyStateToBeComplete(timeout=120) |
881 for resp in self.IterResponses(tab): | 929 for resp in self.IterResponses(tab): |
882 if resp.HasChromeProxyViaHeader() and not resp.response.url.endswith( | 930 if resp.HasChromeProxyViaHeader() and not resp.response.url.endswith( |
883 'favicon.ico'): | 931 'favicon.ico'): |
884 r = resp.response | 932 r = resp.response |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 except KeyError: | 1085 except KeyError: |
1038 raise ChromeProxyMetricException, 'No metrics found' | 1086 raise ChromeProxyMetricException, 'No metrics found' |
1039 | 1087 |
1040 # Returns whether |url| is a block-once test URL. Data Reduction Proxy has been | 1088 # Returns whether |url| is a block-once test URL. Data Reduction Proxy has been |
1041 # configured to always return block-once for these URLs. | 1089 # configured to always return block-once for these URLs. |
1042 def IsTestUrlForBlockOnce(url): | 1090 def IsTestUrlForBlockOnce(url): |
1043 return (url == 'http://check.googlezip.net/blocksingle/' or | 1091 return (url == 'http://check.googlezip.net/blocksingle/' or |
1044 url == ('http://chromeproxy-test.appspot.com/default?respBody=T0s=' | 1092 url == ('http://chromeproxy-test.appspot.com/default?respBody=T0s=' |
1045 '&respHeader=eyJBY2Nlc3MtQ29udHJvbC1BbGxvdy1PcmlnaW4iOlsiKiJ' | 1093 '&respHeader=eyJBY2Nlc3MtQ29udHJvbC1BbGxvdy1PcmlnaW4iOlsiKiJ' |
1046 'dfQ==&respStatus=200&flywheelAction=block-once')) | 1094 'dfQ==&respStatus=200&flywheelAction=block-once')) |
OLD | NEW |