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

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

Issue 661613003: Fix telemetry tests that run against the data reduction dev proxy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 6 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 from telemetry.value import scalar 11 from telemetry.value import scalar
12 12
13 13
14 class ChromeProxyMetricException(page_test.MeasurementFailure): 14 class ChromeProxyMetricException(page_test.MeasurementFailure):
15 pass 15 pass
16 16
17 17
18 CHROME_PROXY_VIA_HEADER = 'Chrome-Compression-Proxy' 18 CHROME_PROXY_VIA_HEADER = 'Chrome-Compression-Proxy'
19 CHROME_PROXY_VIA_HEADER_DEPRECATED = '1.1 Chrome Compression Proxy' 19 CHROME_PROXY_VIA_HEADER_DEPRECATED = '1.1 Chrome Compression Proxy'
20 20
21 PROXY_SETTING_HTTPS = 'proxy.googlezip.net:443' 21 PROXY_SETTING_HTTPS = 'proxy.googlezip.net:443'
22 PROXY_SETTING_HTTPS_WITH_SCHEME = 'https://' + PROXY_SETTING_HTTPS 22 PROXY_SETTING_HTTPS_WITH_SCHEME = 'https://' + PROXY_SETTING_HTTPS
23 PROXY_DEV_SETTING_HTTPS_WITH_SCHEME = 'http://proxy-dev.googlezip.net:80' 23 PROXY_DEV_SETTING_HTTP = 'proxy-dev.googlezip.net:80'
24 PROXY_SETTING_HTTP = 'compress.googlezip.net:80' 24 PROXY_SETTING_HTTP = 'compress.googlezip.net:80'
25 PROXY_SETTING_DIRECT = 'direct://' 25 PROXY_SETTING_DIRECT = 'direct://'
26 26
27 # The default Chrome Proxy bypass time is a range from one to five mintues. 27 # The default Chrome Proxy bypass time is a range from one to five mintues.
28 # See ProxyList::UpdateRetryInfoOnFallback in net/proxy/proxy_list.cc. 28 # See ProxyList::UpdateRetryInfoOnFallback in net/proxy/proxy_list.cc.
29 DEFAULT_BYPASS_MIN_SECONDS = 60 29 DEFAULT_BYPASS_MIN_SECONDS = 60
30 DEFAULT_BYPASS_MAX_SECONDS = 5 * 60 30 DEFAULT_BYPASS_MAX_SECONDS = 5 * 60
31 31
32 def GetProxyInfoFromNetworkInternals(tab, url='chrome://net-internals#proxy'): 32 def GetProxyInfoFromNetworkInternals(tab, url='chrome://net-internals#proxy'):
33 tab.Navigate(url) 33 tab.Navigate(url)
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 92
93 class ChromeProxyMetric(network_metrics.NetworkMetric): 93 class ChromeProxyMetric(network_metrics.NetworkMetric):
94 """A Chrome proxy timeline metric.""" 94 """A Chrome proxy timeline metric."""
95 95
96 def __init__(self): 96 def __init__(self):
97 super(ChromeProxyMetric, self).__init__() 97 super(ChromeProxyMetric, self).__init__()
98 self.compute_data_saving = True 98 self.compute_data_saving = True
99 self.effective_proxies = { 99 self.effective_proxies = {
100 "proxy": PROXY_SETTING_HTTPS_WITH_SCHEME, 100 "proxy": PROXY_SETTING_HTTPS_WITH_SCHEME,
101 "proxy-dev": PROXY_DEV_SETTING_HTTPS_WITH_SCHEME, 101 "proxy-dev": PROXY_DEV_SETTING_HTTP,
102 "fallback": PROXY_SETTING_HTTP, 102 "fallback": PROXY_SETTING_HTTP,
103 "direct": PROXY_SETTING_DIRECT, 103 "direct": PROXY_SETTING_DIRECT,
104 } 104 }
105 105
106 def SetEvents(self, events): 106 def SetEvents(self, events):
107 """Used for unittest.""" 107 """Used for unittest."""
108 self._events = events 108 self._events = events
109 109
110 def ResponseFromEvent(self, event): 110 def ResponseFromEvent(self, event):
111 return ChromeProxyResponse(event) 111 return ChromeProxyResponse(event)
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 'Reponse: status=(%d, %s)\nHeaders:\n %s' % ( 345 'Reponse: status=(%d, %s)\nHeaders:\n %s' % (
346 r.url, r.status, r.status_text, r.headers)) 346 r.url, r.status, r.status_text, r.headers))
347 if count == safebrowsing_count: 347 if count == safebrowsing_count:
348 results.AddValue(scalar.ScalarValue( 348 results.AddValue(scalar.ScalarValue(
349 results.current_page, 'safebrowsing', 'boolean', True)) 349 results.current_page, 'safebrowsing', 'boolean', True))
350 else: 350 else:
351 raise ChromeProxyMetricException, ( 351 raise ChromeProxyMetricException, (
352 'Safebrowsing failed (count=%d, safebrowsing_count=%d)\n' % ( 352 'Safebrowsing failed (count=%d, safebrowsing_count=%d)\n' % (
353 count, safebrowsing_count)) 353 count, safebrowsing_count))
354 354
355 def ProxyListForDev(self, proxies):
356 return [self.effective_proxies['proxy-dev']
357 if proxy == self.effective_proxies['proxy']
358 else proxy for proxy in proxies]
359
355 def VerifyProxyInfo(self, tab, expected_proxies, expected_bad_proxies): 360 def VerifyProxyInfo(self, tab, expected_proxies, expected_bad_proxies):
356 info = GetProxyInfoFromNetworkInternals(tab) 361 info = GetProxyInfoFromNetworkInternals(tab)
357 if not 'enabled' in info or not info['enabled']: 362 if not 'enabled' in info or not info['enabled']:
358 raise ChromeProxyMetricException, ( 363 raise ChromeProxyMetricException, (
359 'Chrome proxy should be enabled. proxy info: %s' % info) 364 'Chrome proxy should be enabled. proxy info: %s' % info)
360
361 proxies = info['proxies'] 365 proxies = info['proxies']
362 if proxies != expected_proxies: 366 if (proxies != expected_proxies and
367 proxies != self.ProxyListForDev(expected_proxies)):
363 raise ChromeProxyMetricException, ( 368 raise ChromeProxyMetricException, (
364 'Wrong effective proxies (%s). Expect: "%s"' % ( 369 'Wrong effective proxies (%s). Expect: "%s"' % (
365 str(proxies), str(expected_proxies))) 370 str(proxies), str(expected_proxies)))
366 371
367 bad_proxies = [] 372 bad_proxies = []
368 if 'badProxies' in info and info['badProxies']: 373 if 'badProxies' in info and info['badProxies']:
369 bad_proxies = [p['proxy'] for p in info['badProxies'] 374 bad_proxies = [p['proxy'] for p in info['badProxies']
370 if 'proxy' in p and p['proxy']] 375 if 'proxy' in p and p['proxy']]
371 if bad_proxies != expected_bad_proxies: 376 if (bad_proxies != expected_bad_proxies and
377 bad_proxies != self.ProxyListForDev(expected_bad_proxies)):
372 raise ChromeProxyMetricException, ( 378 raise ChromeProxyMetricException, (
373 'Wrong bad proxies (%s). Expect: "%s"' % ( 379 'Wrong bad proxies (%s). Expect: "%s"' % (
374 str(bad_proxies), str(expected_bad_proxies))) 380 str(bad_proxies), str(expected_bad_proxies)))
375 381
376 def AddResultsForHTTPFallback( 382 def AddResultsForHTTPFallback(
377 self, tab, results, expected_proxies=None, expected_bad_proxies=None): 383 self, tab, results, expected_proxies=None, expected_bad_proxies=None):
378 if not expected_proxies: 384 if not expected_proxies:
379 expected_proxies = [self.effective_proxies['fallback'], 385 expected_proxies = [self.effective_proxies['fallback'],
380 self.effective_proxies['direct']] 386 self.effective_proxies['direct']]
381 if not expected_bad_proxies: 387 if not expected_bad_proxies:
382 expected_bad_proxies = [] 388 expected_bad_proxies = []
383 389
384 self.VerifyProxyInfo(tab, expected_proxies, expected_bad_proxies) 390 self.VerifyProxyInfo(tab, expected_proxies, expected_bad_proxies)
385 results.AddValue(scalar.ScalarValue( 391 results.AddValue(scalar.ScalarValue(
386 results.current_page, 'http_fallback', 'boolean', True)) 392 results.current_page, 'http_fallback', 'boolean', True))
387 393
388 def AddResultsForHTTPToDirectFallback(self, tab, results): 394 def AddResultsForHTTPToDirectFallback(self, tab, results):
389 self.VerifyAllProxiesBypassed(tab) 395 self.VerifyAllProxiesBypassed(tab)
390 results.AddValue(scalar.ScalarValue( 396 results.AddValue(scalar.ScalarValue(
391 results.current_page, 'direct_fallback', 'boolean', True)) 397 results.current_page, 'direct_fallback', 'boolean', True))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698