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.page import page_test | 10 from telemetry.page import page_test |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 else: | 146 else: |
147 r = resp.response | 147 r = resp.response |
148 raise ChromeProxyMetricException, ( | 148 raise ChromeProxyMetricException, ( |
149 '%s: Via header (%s) is not valid (refer=%s, status=%d)' % ( | 149 '%s: Via header (%s) is not valid (refer=%s, status=%d)' % ( |
150 r.url, r.GetHeader('Via'), r.GetHeader('Referer'), r.status)) | 150 r.url, r.GetHeader('Via'), r.GetHeader('Referer'), r.status)) |
151 results.AddValue(scalar.ScalarValue( | 151 results.AddValue(scalar.ScalarValue( |
152 results.current_page, 'checked_via_header', 'count', via_count)) | 152 results.current_page, 'checked_via_header', 'count', via_count)) |
153 results.AddValue(scalar.ScalarValue( | 153 results.AddValue(scalar.ScalarValue( |
154 results.current_page, 'request_bypassed', 'count', bypass_count)) | 154 results.current_page, 'request_bypassed', 'count', bypass_count)) |
155 | 155 |
| 156 def AddResultsForVersionTest(self, tab, results): |
| 157 for resp in self.IterResponses(tab): |
| 158 if resp.response.status != 200: |
| 159 r = resp.response |
| 160 raise ChromeProxyMetricException, ('%s: Response is not 200: %d' % |
| 161 (r.url, r.status)) |
| 162 if not resp.IsValidByViaHeader(): |
| 163 raise ChromeProxyMetricException, ('%s: Response missing via header') |
| 164 results.AddValue(scalar.ScalarValue( |
| 165 results.current_page, 'version_test', 'count', 1)) |
| 166 |
| 167 |
156 def IsProxyBypassed(self, tab): | 168 def IsProxyBypassed(self, tab): |
157 """ Returns True if all configured proxies are bypassed.""" | 169 """ Returns True if all configured proxies are bypassed.""" |
158 info = GetProxyInfoFromNetworkInternals(tab) | 170 info = GetProxyInfoFromNetworkInternals(tab) |
159 if not info['enabled']: | 171 if not info['enabled']: |
160 raise ChromeProxyMetricException, ( | 172 raise ChromeProxyMetricException, ( |
161 'Chrome proxy should be enabled. proxy info: %s' % info) | 173 'Chrome proxy should be enabled. proxy info: %s' % info) |
162 | 174 |
163 bad_proxies = [str(p['proxy']) for p in info['badProxies']].sort() | 175 bad_proxies = [str(p['proxy']) for p in info['badProxies']].sort() |
164 proxies = [self.effective_proxies['proxy'], | 176 proxies = [self.effective_proxies['proxy'], |
165 self.effective_proxies['fallback']].sort() | 177 self.effective_proxies['fallback']].sort() |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 bad_proxies = [] | 276 bad_proxies = [] |
265 if 'badProxies' in info and info['badProxies']: | 277 if 'badProxies' in info and info['badProxies']: |
266 bad_proxies = [p['proxy'] for p in info['badProxies'] | 278 bad_proxies = [p['proxy'] for p in info['badProxies'] |
267 if 'proxy' in p and p['proxy']] | 279 if 'proxy' in p and p['proxy']] |
268 if bad_proxies != expected_bad_proxies: | 280 if bad_proxies != expected_bad_proxies: |
269 raise ChromeProxyMetricException, ( | 281 raise ChromeProxyMetricException, ( |
270 'Wrong bad proxies (%s). Expect: "%s"' % ( | 282 'Wrong bad proxies (%s). Expect: "%s"' % ( |
271 str(bad_proxies), str(expected_bad_proxies))) | 283 str(bad_proxies), str(expected_bad_proxies))) |
272 results.AddValue(scalar.ScalarValue( | 284 results.AddValue(scalar.ScalarValue( |
273 results.current_page, 'http_fallback', 'boolean', True)) | 285 results.current_page, 'http_fallback', 'boolean', True)) |
OLD | NEW |