Commit 2adf1996 authored by bolian@chromium.org's avatar bolian@chromium.org

Move chrome_proxy tests from under tools/perf to tools/chrome_proxy/integration_tests.

BUG=393360

Review URL: https://codereview.chromium.org/397483002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284310 0039d316-1c4b-4281-b951-d872f2087c98
parent 19c5eafc
bengr@chromium.org
bolian@chromium.org
kundaji@chromium.org
marq@chromium.org
megjablon@chromium.org
......@@ -2,105 +2,105 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from measurements import chrome_proxy
import page_sets
from integration_tests import chrome_proxy_measurements as measurements
from integration_tests import chrome_proxy_pagesets as pagesets
from telemetry import benchmark
@benchmark.Disabled
@benchmark.Enabled('android')
class ChromeProxyLatency(benchmark.Benchmark):
tag = 'latency'
test = chrome_proxy.ChromeProxyLatency
page_set = page_sets.Top20PageSet
test = measurements.ChromeProxyLatency
page_set = pagesets.Top20PageSet
options = {'pageset_repeat_iters': 2}
def CustomizeBrowserOptions(self, options):
options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth')
@benchmark.Disabled
@benchmark.Enabled('android')
class ChromeProxyLatencyDirect(benchmark.Benchmark):
tag = 'latency_direct'
test = chrome_proxy.ChromeProxyLatency
page_set = page_sets.Top20PageSet
test = measurements.ChromeProxyLatency
page_set = pagesets.Top20PageSet
options = {'pageset_repeat_iters': 2}
@benchmark.Disabled
@benchmark.Enabled('android')
class ChromeProxyLatencySynthetic(ChromeProxyLatency):
page_set = page_sets.SyntheticPageSet
page_set = pagesets.SyntheticPageSet
@benchmark.Disabled
@benchmark.Enabled('android')
class ChromeProxyLatencySyntheticDirect(ChromeProxyLatencyDirect):
page_set = page_sets.SyntheticPageSet
page_set = pagesets.SyntheticPageSet
@benchmark.Disabled
@benchmark.Enabled('android')
class ChromeProxyDataSaving(benchmark.Benchmark):
tag = 'data_saving'
test = chrome_proxy.ChromeProxyDataSaving
page_set = page_sets.Top20PageSet
test = measurements.ChromeProxyDataSaving
page_set = pagesets.Top20PageSet
options = {'pageset_repeat_iters': 1}
def CustomizeBrowserOptions(self, options):
options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth')
@benchmark.Disabled
@benchmark.Enabled('android')
class ChromeProxyDataSavingDirect(benchmark.Benchmark):
tag = 'data_saving_direct'
test = chrome_proxy.ChromeProxyDataSaving
page_set = page_sets.Top20PageSet
test = measurements.ChromeProxyDataSaving
page_set = pagesets.Top20PageSet
options = {'pageset_repeat_iters': 2}
@benchmark.Disabled
@benchmark.Enabled('android')
class ChromeProxyDataSavingSynthetic(ChromeProxyDataSaving):
page_set = page_sets.SyntheticPageSet
page_set = pagesets.SyntheticPageSet
@benchmark.Disabled
@benchmark.Enabled('android')
class ChromeProxyDataSavingSyntheticDirect(ChromeProxyDataSavingDirect):
page_set = page_sets.SyntheticPageSet
page_set = pagesets.SyntheticPageSet
@benchmark.Disabled
@benchmark.Enabled('android')
class ChromeProxyHeaderValidation(benchmark.Benchmark):
tag = 'header_validation'
test = chrome_proxy.ChromeProxyHeaders
page_set = page_sets.Top20PageSet
test = measurements.ChromeProxyHeaders
page_set = pagesets.Top20PageSet
@benchmark.Disabled
@benchmark.Enabled('android')
class ChromeProxyBypass(benchmark.Benchmark):
tag = 'bypass'
test = chrome_proxy.ChromeProxyBypass
page_set = page_sets.BypassPageSet
test = measurements.ChromeProxyBypass
page_set = pagesets.BypassPageSet
@benchmark.Disabled
@benchmark.Enabled('android')
class ChromeProxySafeBrowsing(benchmark.Benchmark):
tag = 'safebrowsing'
test = chrome_proxy.ChromeProxySafebrowsing
page_set = page_sets.SafebrowsingPageSet
test = measurements.ChromeProxySafebrowsing
page_set = pagesets.SafebrowsingPageSet
@benchmark.Disabled
@benchmark.Enabled('android')
class ChromeProxyHTTPFallbackProbeURL(benchmark.Benchmark):
tag = 'fallback-probe'
test = chrome_proxy.ChromeProxyHTTPFallbackProbeURL
page_set = page_sets.SyntheticPageSet
test = measurements.ChromeProxyHTTPFallbackProbeURL
page_set = pagesets.SyntheticPageSet
@benchmark.Disabled
@benchmark.Enabled('android')
class ChromeProxyHTTPFallbackViaHeader(benchmark.Benchmark):
tag = 'fallback-viaheader'
test = chrome_proxy.ChromeProxyHTTPFallbackViaHeader
page_set = page_sets.FallbackViaHeaderPageSet
test = measurements.ChromeProxyHTTPFallbackViaHeader
page_set = pagesets.FallbackViaHeaderPageSet
@benchmark.Disabled
@benchmark.Enabled('android')
class ChromeProxySmoke(benchmark.Benchmark):
tag = 'smoke'
test = chrome_proxy.ChromeProxySmoke
page_set = page_sets.SmokePageSet
test = measurements.ChromeProxySmoke
page_set = pagesets.SmokePageSet
......@@ -6,7 +6,7 @@ import base64
import logging
import urlparse
from metrics import chrome_proxy
from integration_tests import chrome_proxy_metrics as metrics
from metrics import loading
from telemetry.core import util
from telemetry.page import page_measurement
......@@ -31,7 +31,7 @@ class ChromeProxyDataSaving(page_measurement.PageMeasurement):
"""Chrome proxy data daving measurement."""
def __init__(self, *args, **kwargs):
super(ChromeProxyDataSaving, self).__init__(*args, **kwargs)
self._metrics = chrome_proxy.ChromeProxyMetric()
self._metrics = metrics.ChromeProxyMetric()
def WillNavigateToPage(self, page, tab):
tab.ClearCache(force=True)
......@@ -50,7 +50,7 @@ class ChromeProxyValidation(page_measurement.PageMeasurement):
def __init__(self, restart_after_each_page=False):
super(ChromeProxyValidation, self).__init__(
needs_browser_restart_after_each_page=restart_after_each_page)
self._metrics = chrome_proxy.ChromeProxyMetric()
self._metrics = metrics.ChromeProxyMetric()
self._page = None
# Whether a timeout exception is expected during the test.
self._expect_timeout = False
......
......@@ -6,8 +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
......@@ -30,7 +30,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 +44,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 +89,7 @@ class ChromeProxyResponse(network.HTTPResponse):
return False
class ChromeProxyMetric(network.NetworkMetric):
class ChromeProxyMetric(network_metrics.NetworkMetric):
"""A Chrome proxy timeline metric."""
def __init__(self):
......
......@@ -5,8 +5,8 @@
import base64
import unittest
from metrics import chrome_proxy
from metrics import network_unittest
from integration_tests import chrome_proxy_metrics as metrics
from integration_tests import network_metrics_unittest as network_unittest
from metrics import test_page_measurement_results
......@@ -28,7 +28,7 @@ EVENT_HTML_PROXY_DEPRECATED_VIA = (
'Content-Type': 'text/html',
'Content-Encoding': 'gzip',
'X-Original-Content-Length': str(len(network_unittest.HTML_BODY)),
'Via': (chrome_proxy.CHROME_PROXY_VIA_HEADER_DEPRECATED +
'Via': (metrics.CHROME_PROXY_VIA_HEADER_DEPRECATED +
',other-via'),
},
body=network_unittest.HTML_BODY))
......@@ -41,7 +41,7 @@ EVENT_IMAGE_PROXY_CACHED = (
'Content-Type': 'image/jpeg',
'Content-Encoding': 'gzip',
'X-Original-Content-Length': str(network_unittest.IMAGE_OCL),
'Via': '1.1 ' + chrome_proxy.CHROME_PROXY_VIA_HEADER,
'Via': '1.1 ' + metrics.CHROME_PROXY_VIA_HEADER,
},
body=base64.b64encode(network_unittest.IMAGE_BODY),
base64_encoded_body=True,
......@@ -64,7 +64,7 @@ EVENT_MALWARE_PROXY = (
url='http://test.malware',
response_headers={
'X-Malware-Url': '1',
'Via': '1.1 ' + chrome_proxy.CHROME_PROXY_VIA_HEADER,
'Via': '1.1 ' + metrics.CHROME_PROXY_VIA_HEADER,
'Location': 'http://test.malware',
},
status=307))
......@@ -77,12 +77,12 @@ class ChromeProxyMetricTest(unittest.TestCase):
def _StubGetProxyInfo(self, info):
def stub(unused_tab, unused_url=''): # pylint: disable=W0613
return ChromeProxyMetricTest._test_proxy_info
chrome_proxy.GetProxyInfoFromNetworkInternals = stub
metrics.GetProxyInfoFromNetworkInternals = stub
ChromeProxyMetricTest._test_proxy_info = info
def testChromeProxyResponse(self):
# An https non-proxy response.
resp = chrome_proxy.ChromeProxyResponse(
resp = metrics.ChromeProxyResponse(
network_unittest.NetworkMetricTest.MakeNetworkTimelineEvent(
url='https://test.url',
response_headers={
......@@ -96,13 +96,13 @@ class ChromeProxyMetricTest(unittest.TestCase):
self.assertTrue(resp.IsValidByViaHeader())
# A proxied JPEG image response
resp = chrome_proxy.ChromeProxyResponse(
resp = metrics.ChromeProxyResponse(
network_unittest.NetworkMetricTest.MakeNetworkTimelineEvent(
url='http://test.image',
response_headers={
'Content-Type': 'image/jpeg',
'Content-Encoding': 'gzip',
'Via': '1.1 ' + chrome_proxy.CHROME_PROXY_VIA_HEADER,
'Via': '1.1 ' + metrics.CHROME_PROXY_VIA_HEADER,
'X-Original-Content-Length': str(network_unittest.IMAGE_OCL),
},
body=base64.b64encode(network_unittest.IMAGE_BODY),
......@@ -112,7 +112,7 @@ class ChromeProxyMetricTest(unittest.TestCase):
self.assertTrue(resp.IsValidByViaHeader())
def testChromeProxyMetricForDataSaving(self):
metric = chrome_proxy.ChromeProxyMetric()
metric = metrics.ChromeProxyMetric()
events = [
EVENT_HTML_PROXY,
EVENT_HTML_PROXY_DEPRECATED_VIA,
......@@ -129,7 +129,7 @@ class ChromeProxyMetricTest(unittest.TestCase):
results.AssertHasPageSpecificScalarValue('resources_direct', 'count', 2)
def testChromeProxyMetricForHeaderValidation(self):
metric = chrome_proxy.ChromeProxyMetric()
metric = metrics.ChromeProxyMetric()
metric.SetEvents([
EVENT_HTML_PROXY,
EVENT_HTML_PROXY_DEPRECATED_VIA,
......@@ -141,7 +141,7 @@ class ChromeProxyMetricTest(unittest.TestCase):
missing_via_exception = False
try:
metric.AddResultsForHeaderValidation(None, results)
except chrome_proxy.ChromeProxyMetricException:
except metrics.ChromeProxyMetricException:
missing_via_exception = True
# Only the HTTP image response does not have a valid Via header.
self.assertTrue(missing_via_exception)
......@@ -154,7 +154,7 @@ class ChromeProxyMetricTest(unittest.TestCase):
results.AssertHasPageSpecificScalarValue('checked_via_header', 'count', 2)
def testChromeProxyMetricForBypass(self):
metric = chrome_proxy.ChromeProxyMetric()
metric = metrics.ChromeProxyMetric()
metric.SetEvents([
EVENT_HTML_PROXY,
EVENT_HTML_PROXY_DEPRECATED_VIA,
......@@ -165,7 +165,7 @@ class ChromeProxyMetricTest(unittest.TestCase):
bypass_exception = False
try:
metric.AddResultsForBypass(None, results)
except chrome_proxy.ChromeProxyMetricException:
except metrics.ChromeProxyMetricException:
bypass_exception = True
# Two of the first three events have Via headers.
self.assertTrue(bypass_exception)
......@@ -176,7 +176,7 @@ class ChromeProxyMetricTest(unittest.TestCase):
results.AssertHasPageSpecificScalarValue('bypass', 'count', 1)
def testChromeProxyMetricForHTTPFallback(self):
metric = chrome_proxy.ChromeProxyMetric()
metric = metrics.ChromeProxyMetric()
metric.SetEvents([
EVENT_HTML_PROXY,
EVENT_HTML_PROXY_DEPRECATED_VIA])
......@@ -188,7 +188,7 @@ class ChromeProxyMetricTest(unittest.TestCase):
self._StubGetProxyInfo(info)
try:
metric.AddResultsForBypass(None, results)
except chrome_proxy.ChromeProxyMetricException:
except metrics.ChromeProxyMetricException:
fallback_exception = True
self.assertTrue(fallback_exception)
......@@ -196,25 +196,25 @@ class ChromeProxyMetricTest(unittest.TestCase):
info['enabled'] = True
info['proxies'] = [
'something.else.com:80',
chrome_proxy.PROXY_SETTING_DIRECT
metrics.PROXY_SETTING_DIRECT
]
self._StubGetProxyInfo(info)
try:
metric.AddResultsForBypass(None, results)
except chrome_proxy.ChromeProxyMetricException:
except metrics.ChromeProxyMetricException:
fallback_exception = True
self.assertTrue(fallback_exception)
info['enabled'] = True
info['proxies'] = [
chrome_proxy.PROXY_SETTING_HTTP,
chrome_proxy.PROXY_SETTING_DIRECT
metrics.PROXY_SETTING_HTTP,
metrics.PROXY_SETTING_DIRECT
]
self._StubGetProxyInfo(info)
metric.AddResultsForHTTPFallback(None, results)
def testChromeProxyMetricForSafebrowsing(self):
metric = chrome_proxy.ChromeProxyMetric()
metric = metrics.ChromeProxyMetric()
metric.SetEvents([EVENT_MALWARE_PROXY])
results = test_page_measurement_results.TestPageMeasurementResults(self)
......
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import inspect
import os
import sys
from telemetry.core import discover
from telemetry.page import page_set
# Import all submodules' PageSet classes.
start_dir = os.path.dirname(os.path.abspath(__file__))
top_level_dir = os.path.abspath(os.path.join(start_dir, os.pardir, os.pardir))
base_class = page_set.PageSet
for cls in discover.DiscoverClasses(
start_dir, top_level_dir, base_class).values():
setattr(sys.modules[__name__], cls.__name__, cls)
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.page import page as page_module
from telemetry.page import page_set as page_set_module
......
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.page import page as page_module
from telemetry.page import page_set as page_set_module
......
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.page import page as page_module
from telemetry.page import page_set as page_set_module
......
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.page import page as page_module
from telemetry.page import page_set as page_set_module
......
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.page import page as page_module
from telemetry.page import page_set as page_set_module
......
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.page import page as page_module
from telemetry.page import page_set as page_set_module
......
......@@ -5,8 +5,8 @@
import base64
import unittest
from integration_tests import network_metrics
from metrics import test_page_measurement_results
from metrics import network
from telemetry.timeline import event
......@@ -18,7 +18,7 @@ HTML_BODY = """<!DOCTYPE HTML>
</body>
</html>"""
IMAGE_BODY = """fake image data"""
GZIPPED_HTML_LEN = network.HTTPResponse.GetGizppedBodyLength(HTML_BODY)
GZIPPED_HTML_LEN = network_metrics.HTTPResponse.GetGizppedBodyLength(HTML_BODY)
# Make up original content length for the image.
IMAGE_OCL = 3 * len(IMAGE_BODY)
......@@ -49,7 +49,7 @@ class NetworkMetricTest(unittest.TestCase):
self.assertLess(GZIPPED_HTML_LEN, len(HTML_BODY))
# A plain text HTML response
resp = network.HTTPResponse(self.MakeNetworkTimelineEvent(
resp = network_metrics.HTTPResponse(self.MakeNetworkTimelineEvent(
url=url,
response_headers={
'Content-Type': 'text/html',
......@@ -68,7 +68,7 @@ class NetworkMetricTest(unittest.TestCase):
self.assertEqual(0.0, resp.data_saving_rate)
# A gzipped HTML response
resp = network.HTTPResponse(self.MakeNetworkTimelineEvent(
resp = network_metrics.HTTPResponse(self.MakeNetworkTimelineEvent(
url=url,
response_headers={
'Content-Type': 'text/html',
......@@ -87,7 +87,7 @@ class NetworkMetricTest(unittest.TestCase):
resp.data_saving_rate)
# A JPEG image response.
resp = network.HTTPResponse(self.MakeNetworkTimelineEvent(
resp = network_metrics.HTTPResponse(self.MakeNetworkTimelineEvent(
url='http://test.image',
response_headers={
'Content-Type': 'image/jpeg',
......@@ -107,7 +107,7 @@ class NetworkMetricTest(unittest.TestCase):
resp.data_saving_rate)
# A JPEG image response from cache.
resp = network.HTTPResponse(self.MakeNetworkTimelineEvent(
resp = network_metrics.HTTPResponse(self.MakeNetworkTimelineEvent(
url='http://test.image',
response_headers={
'Content-Type': 'image/jpeg',
......@@ -154,7 +154,7 @@ class NetworkMetricTest(unittest.TestCase):
body=base64.b64encode(IMAGE_BODY),
base64_encoded_body=True),
]
metric = network.NetworkMetric()
metric = network_metrics.NetworkMetric()
metric._events = events
metric.compute_data_saving = True
......
#!/usr/bin/env python
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, 'telemetry'))
sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, 'perf'))
from telemetry import test_runner
from telemetry.core import environment
if __name__ == '__main__':
base_dir = os.path.dirname(os.path.realpath(__file__))
test_runner.config = environment.Environment([base_dir])
sys.exit(test_runner.main())
#!/usr/bin/env python
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""This script runs unit tests of the code in the perf directory.
This script DOES NOT run benchmarks. run_benchmark does that.
"""
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, 'telemetry'))
sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, 'perf'))
from telemetry.unittest import gtest_output_formatter
from telemetry.unittest import run_tests
if __name__ == '__main__':
base_dir = os.path.dirname(os.path.realpath(__file__))
output_formatters = [
gtest_output_formatter.GTestOutputFormatter(sys.stdout)]
run_tests.config = run_tests.Config(base_dir, [base_dir], output_formatters)
sys.exit(run_tests.RunTestsCommand.main())
per-file *chrome_proxy*=bengr@chromium.org
per-file *chrome_proxy*=bolian@chromium.org
per-file *chrome_proxy*=marq@chromium.org
per-file *chrome_proxy*=bengr@chromium.org
per-file *chrome_proxy*=bolian@chromium.org
per-file *chrome_proxy*=marq@chromium.org
per-file *chrome_proxy*=bengr@chromium.org
per-file *chrome_proxy*=bolian@chromium.org
per-file *chrome_proxy*=marq@chromium.org
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
per-file *chrome_proxy*=bengr@chromium.org
per-file *chrome_proxy*=bolian@chromium.org
per-file *chrome_proxy*=marq@chromium.org
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment