Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py

Issue 558743003: Integration test for bypassing the proxy for a single request (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed block_single integration test to block_once Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 info = GetProxyInfoFromNetworkInternals(tab) 228 info = GetProxyInfoFromNetworkInternals(tab)
229 if not info['enabled']: 229 if not info['enabled']:
230 raise ChromeProxyMetricException, ( 230 raise ChromeProxyMetricException, (
231 'Chrome proxy should be enabled. proxy info: %s' % info) 231 'Chrome proxy should be enabled. proxy info: %s' % info)
232 _, expected_bad_proxies = self.IsProxyBypassed(tab) 232 _, expected_bad_proxies = self.IsProxyBypassed(tab)
233 self.VerifyBadProxies(info['badProxies'], expected_bad_proxies) 233 self.VerifyBadProxies(info['badProxies'], expected_bad_proxies)
234 234
235 results.AddValue(scalar.ScalarValue( 235 results.AddValue(scalar.ScalarValue(
236 results.current_page, 'bypass', 'count', bypass_count)) 236 results.current_page, 'bypass', 'count', bypass_count))
237 237
238 def AddResultsForBlockOnce(self, tab, results):
239 eligible_response_count = 0
240 bypass_count = 0
241 for resp in self.IterResponses(tab):
242 if resp.ShouldHaveChromeProxyViaHeader():
243 eligible_response_count += 1
244 if not resp.HasChromeProxyViaHeader():
245 bypass_count += 1
246
247 if tab:
248 info = GetProxyInfoFromNetworkInternals(tab)
249 if not info['enabled']:
250 raise ChromeProxyMetricException, (
251 'Chrome proxy should be enabled. proxy info: %s' % info)
252 self.VerifyBadProxies(info['badProxies'], [])
253
254 if eligible_response_count <= 1:
255 raise ChromeProxyMetricException, (
256 'There should be more than one DRP eligible response '
257 '(eligible_response_count=%d, bypass_count=%d)\n' % (
258 eligible_response_count, bypass_count))
259 elif bypass_count != 1:
260 raise ChromeProxyMetricException, (
261 'Exactly one response should be bypassed. '
262 '(eligible_response_count=%d, bypass_count=%d)\n' % (
263 eligible_response_count, bypass_count))
264 else:
265 results.AddValue(scalar.ScalarValue(
266 results.current_page, 'eligible_responses', 'count',
267 eligible_response_count))
268 results.AddValue(scalar.ScalarValue(
269 results.current_page, 'bypass', 'count', bypass_count))
270
238 def AddResultsForSafebrowsing(self, tab, results): 271 def AddResultsForSafebrowsing(self, tab, results):
239 count = 0 272 count = 0
240 safebrowsing_count = 0 273 safebrowsing_count = 0
241 for resp in self.IterResponses(tab): 274 for resp in self.IterResponses(tab):
242 count += 1 275 count += 1
243 if resp.IsSafebrowsingResponse(): 276 if resp.IsSafebrowsingResponse():
244 safebrowsing_count += 1 277 safebrowsing_count += 1
245 else: 278 else:
246 r = resp.response 279 r = resp.response
247 raise ChromeProxyMetricException, ( 280 raise ChromeProxyMetricException, (
(...skipping 30 matching lines...) Expand all
278 bad_proxies = [] 311 bad_proxies = []
279 if 'badProxies' in info and info['badProxies']: 312 if 'badProxies' in info and info['badProxies']:
280 bad_proxies = [p['proxy'] for p in info['badProxies'] 313 bad_proxies = [p['proxy'] for p in info['badProxies']
281 if 'proxy' in p and p['proxy']] 314 if 'proxy' in p and p['proxy']]
282 if bad_proxies != expected_bad_proxies: 315 if bad_proxies != expected_bad_proxies:
283 raise ChromeProxyMetricException, ( 316 raise ChromeProxyMetricException, (
284 'Wrong bad proxies (%s). Expect: "%s"' % ( 317 'Wrong bad proxies (%s). Expect: "%s"' % (
285 str(bad_proxies), str(expected_bad_proxies))) 318 str(bad_proxies), str(expected_bad_proxies)))
286 results.AddValue(scalar.ScalarValue( 319 results.AddValue(scalar.ScalarValue(
287 results.current_page, 'http_fallback', 'boolean', True)) 320 results.current_page, 'http_fallback', 'boolean', True))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698