| Index: tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py
|
| diff --git a/tools/perf/metrics/chrome_proxy.py b/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py
|
| similarity index 88%
|
| rename from tools/perf/metrics/chrome_proxy.py
|
| rename to tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py
|
| index 390da68141dc380f6d8ba897932885871d5719b1..14482a7d4e129fb001b703c5cd6c265f8ab926f1 100644
|
| --- a/tools/perf/metrics/chrome_proxy.py
|
| +++ b/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py
|
| @@ -6,9 +6,8 @@ import datetime
|
| import logging
|
| import os
|
|
|
| +from integration_tests import network_metrics
|
| from telemetry.page import page_measurement
|
| -from metrics import network
|
| -from telemetry.value import scalar
|
|
|
|
|
| class ChromeProxyMetricException(page_measurement.MeasurementFailure):
|
| @@ -30,7 +29,8 @@ DEFAULT_BYPASS_MAX_SECONDS = 5 * 60
|
|
|
| def GetProxyInfoFromNetworkInternals(tab, url='chrome://net-internals#proxy'):
|
| tab.Navigate(url)
|
| - with open(os.path.join(os.path.dirname(__file__), 'chrome_proxy.js')) as f:
|
| + with open(os.path.join(os.path.dirname(__file__),
|
| + 'chrome_proxy_metrics.js')) as f:
|
| js = f.read()
|
| tab.ExecuteJavaScript(js)
|
| tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300)
|
| @@ -43,7 +43,7 @@ def ProxyRetryTimeInRange(retry_time, low, high, grace_seconds=30):
|
| (retry_time < high + datetime.timedelta(seconds=grace_seconds)))
|
|
|
|
|
| -class ChromeProxyResponse(network.HTTPResponse):
|
| +class ChromeProxyResponse(network_metrics.HTTPResponse):
|
| """ Represents an HTTP response from a timeleine event."""
|
| def __init__(self, event):
|
| super(ChromeProxyResponse, self).__init__(event)
|
| @@ -88,7 +88,7 @@ class ChromeProxyResponse(network.HTTPResponse):
|
| return False
|
|
|
|
|
| -class ChromeProxyMetric(network.NetworkMetric):
|
| +class ChromeProxyMetric(network_metrics.NetworkMetric):
|
| """A Chrome proxy timeline metric."""
|
|
|
| def __init__(self):
|
| @@ -124,14 +124,9 @@ class ChromeProxyMetric(network.NetworkMetric):
|
| else:
|
| resources_direct += 1
|
|
|
| - results.AddValue(scalar.ScalarValue(
|
| - results.current_page, 'resources_via_proxy', 'count',
|
| - resources_via_proxy))
|
| - results.AddValue(scalar.ScalarValue(
|
| - results.current_page, 'resources_from_cache', 'count',
|
| - resources_from_cache))
|
| - results.AddValue(scalar.ScalarValue(
|
| - results.current_page, 'resources_direct', 'count', resources_direct))
|
| + results.Add('resources_via_proxy', 'count', resources_via_proxy)
|
| + results.Add('resources_from_cache', 'count', resources_from_cache)
|
| + results.Add('resources_direct', 'count', resources_direct)
|
|
|
| def AddResultsForHeaderValidation(self, tab, results):
|
| via_count = 0
|
| @@ -147,10 +142,8 @@ class ChromeProxyMetric(network.NetworkMetric):
|
| raise ChromeProxyMetricException, (
|
| '%s: Via header (%s) is not valid (refer=%s, status=%d)' % (
|
| r.url, r.GetHeader('Via'), r.GetHeader('Referer'), r.status))
|
| - results.AddValue(scalar.ScalarValue(
|
| - results.current_page, 'checked_via_header', 'count', via_count))
|
| - results.AddValue(scalar.ScalarValue(
|
| - results.current_page, 'request_bypassed', 'count', bypass_count))
|
| + results.Add('checked_via_header', 'count', via_count)
|
| + results.Add('request_bypassed', 'count', bypass_count)
|
|
|
| def IsProxyBypassed(self, tab):
|
| """ Returns True if all configured proxies are bypassed."""
|
| @@ -217,8 +210,7 @@ class ChromeProxyMetric(network.NetworkMetric):
|
| [self.effective_proxies['proxy'],
|
| self.effective_proxies['fallback']])
|
|
|
| - results.AddValue(scalar.ScalarValue(
|
| - results.current_page, 'bypass', 'count', bypass_count))
|
| + results.Add('bypass', 'count', bypass_count)
|
|
|
| def AddResultsForSafebrowsing(self, tab, results):
|
| count = 0
|
| @@ -234,8 +226,7 @@ class ChromeProxyMetric(network.NetworkMetric):
|
| 'Reponse: status=(%d, %s)\nHeaders:\n %s' % (
|
| r.url, r.status, r.status_text, r.headers))
|
| if count == safebrowsing_count:
|
| - results.AddValue(scalar.ScalarValue(
|
| - results.current_page, 'safebrowsing', 'boolean', True))
|
| + results.Add('safebrowsing', 'boolean', True)
|
| else:
|
| raise ChromeProxyMetricException, (
|
| 'Safebrowsing failed (count=%d, safebrowsing_count=%d)\n' % (
|
| @@ -268,5 +259,4 @@ class ChromeProxyMetric(network.NetworkMetric):
|
| raise ChromeProxyMetricException, (
|
| 'Wrong bad proxies (%s). Expect: "%s"' % (
|
| str(bad_proxies), str(expected_bad_proxies)))
|
| - results.AddValue(scalar.ScalarValue(
|
| - results.current_page, 'http_fallback', 'boolean', True))
|
| + results.Add('http_fallback', 'boolean', True)
|
|
|