| Index: tools/chrome_proxy/webdriver/variations_combinations.py
|
| diff --git a/tools/chrome_proxy/webdriver/variations_combinations.py b/tools/chrome_proxy/webdriver/variations_combinations.py
|
| index 3471a418acd2a44887806c0aab0c0c678fadf48e..8371505966d2a10a5abdfb548c944562c05f6fd7 100644
|
| --- a/tools/chrome_proxy/webdriver/variations_combinations.py
|
| +++ b/tools/chrome_proxy/webdriver/variations_combinations.py
|
| @@ -2,60 +2,69 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| +import io
|
| import os
|
| -import re
|
| +import platform
|
| import sys
|
| import time
|
| import unittest
|
|
|
| import common
|
|
|
| +sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
| + os.pardir, 'tools', 'variations'))
|
| +import fieldtrial_util
|
|
|
| -combinations = [
|
| - # One object for each set of tests to run with the given variations.
|
| - {
|
| - 'label': 'dummy example',
|
| - 'tests': [
|
| - # Of the form <file_name>.<class_name>.<method_name>
|
| - # Also accepts wildcard (*) as matching anything.
|
| - "lite_page.LitePage.testLitePage",
|
| - "lite_page.LitePage.testLitePageFallback",
|
| - "quic*"
|
| - ],
|
| - 'variations': [
|
| - "DataReductionProxyUseQuic/Enabled",
|
| - "DataCompressionProxyLoFi/Enabled_Preview",
|
| - "DataCompressionProxyLitePageFallback/Enabled"
|
| - ],
|
| - 'variations-params': [
|
| - "DataCompressionProxyLoFi.Enabled_Preview:effective_connection_type/4G"
|
| - ]
|
| - }
|
| +test_blacklist = [
|
| + # These tests set their own field trials and should be ignored.
|
| + 'lofi.LoFi.testLoFiSlowConnection',
|
| + 'lofi.LoFi.testLoFiIfHeavyFastConnection',
|
| + 'quic.Quic.testCheckPageWithQuicProxy',
|
| + 'quic.Quic.testCheckPageWithQuicProxyTransaction',
|
| + 'lite_page.LitePage.testLitePageFallback',
|
| ]
|
|
|
| +def GetExperimentArgs():
|
| + """Returns a list of arguments with all tested field trials.
|
|
|
| -def GetAllTestsFromRegexList(test_list, test_suite_iter):
|
| - """A helper function to make a test suite from tests matching the given list.
|
| + This function is a simple wrapper around the variation team's fieldtrail_util
|
| + script that generates command line arguments to test Chromium field trials.
|
|
|
| - Args:
|
| - test_list: a string list of all tests to run, allowing for simple regex
|
| - test_suite_iter: An iterator of all test suites to search
|
| Returns:
|
| - a test suite with all the tests specified by the test_list
|
| + an array of command line arguments to pass to chrome
|
| + """
|
| + config_path = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
| + os.pardir, 'testing', 'variations', 'fieldtrial_testing_config.json')
|
| + my_platform = ''
|
| + if common.ParseFlags().android:
|
| + my_platform = 'android'
|
| + elif platform.system().lower() == 'linux':
|
| + my_platform = 'linux'
|
| + elif platform.system().lower() == 'windows':
|
| + my_platform = 'win'
|
| + elif platform.system().lower() == 'darwin':
|
| + my_platform = 'mac'
|
| + else:
|
| + raise Exception('unknown platform!')
|
| + return fieldtrial_util.GenerateArgs(config_path, my_platform)
|
| +
|
| +def GenerateTestSuites():
|
| + """A generator function that yields non-blacklisted tests to run.
|
| +
|
| + This function yeilds test suites each with a single test case whose id is not
|
| + blacklisted in the array at the top of this file.
|
| +
|
| + Yields:
|
| + non-blacklisted test suites to run
|
| """
|
| - id_to_test_map = {}
|
| - for test_suite in test_suite_iter:
|
| + loader = unittest.TestLoader()
|
| + for test_suite in loader.discover(os.path.dirname(__file__), pattern='*.py'):
|
| for test_case in test_suite:
|
| for test_method in test_case:
|
| - id_to_test_map[test_method.id()] = test_method
|
| - my_test_suite = unittest.TestSuite()
|
| - for test_spec in test_list:
|
| - regex = re.compile('^' + test_spec.replace('.', '\\.').replace('*', '.*')
|
| - + '$')
|
| - for test_id in sorted(id_to_test_map):
|
| - if regex.match(test_id):
|
| - my_test_suite.addTest(id_to_test_map[test_id])
|
| - return my_test_suite
|
| + if test_method.id() not in test_blacklist:
|
| + ts = unittest.TestSuite()
|
| + ts.addTest(test_method)
|
| + yield (ts, test_method.id())
|
|
|
| def ParseFlagsWithExtraBrowserArgs(extra_args):
|
| """Generates a function to override common.ParseFlags.
|
| @@ -76,26 +85,36 @@ def ParseFlagsWithExtraBrowserArgs(extra_args):
|
| return AddExtraBrowserArgs
|
|
|
| def main():
|
| - """Runs each set of tests against its set of variations.
|
| + """Runs all non-blacklisted tests against Chromium field trials.
|
|
|
| - For each test combination, the above variation specifications will be used to
|
| - setup the browser arguments for each test given above that will be run.
|
| + This script run all chrome proxy integration tests that haven't been
|
| + blacklisted against the field trial testing configuration used by Chromium
|
| + perf bots.
|
| """
|
| flags = common.ParseFlags()
|
| - for variation_test in combinations:
|
| - # Set browser arguments to use the given variations.
|
| - extra_args = '--force-fieldtrials=' + '/'.join(variation_test['variations'])
|
| - extra_args += ' --force-fieldtrial-params=' + ','.join(
|
| - variation_test['variations-params'])
|
| - common.ParseFlags = ParseFlagsWithExtraBrowserArgs(extra_args)
|
| - # Run the given tests.
|
| - loader = unittest.TestLoader()
|
| - test_suite_iter = loader.discover(os.path.dirname(__file__), pattern='*.py')
|
| - my_test_suite = GetAllTestsFromRegexList(variation_test['tests'],
|
| - test_suite_iter)
|
| - testRunner = unittest.runner.TextTestRunner(verbosity=2,
|
| - failfast=flags.failfast, buffer=(not flags.disable_buffer))
|
| - testRunner.run(my_test_suite)
|
| + experiment_args = ' '.join(GetExperimentArgs())
|
| + common.ParseFlags = ParseFlagsWithExtraBrowserArgs(experiment_args)
|
| + # Each test is wrapped in its own test suite so results can be evaluated
|
| + # individually.
|
| + for test_suite, test_id in GenerateTestSuites():
|
| + buf = io.BytesIO()
|
| + sys.stdout.write('%s... ' % test_id)
|
| + sys.stdout.flush()
|
| + testRunner = unittest.runner.TextTestRunner(stream=buf, verbosity=2,
|
| + buffer=(not flags.disable_buffer))
|
| + result = testRunner.run(test_suite)
|
| + if result.wasSuccessful():
|
| + print 'ok'
|
| + else:
|
| + print 'failed'
|
| + print buf.getvalue()
|
| + print 'To repeat this test, run: '
|
| + print "%s %s %s --test_filter=%s --browser_args='%s'" % (sys.executable,
|
| + os.path.join(os.path.dirname(__file__), 'run_all_tests.py'),
|
| + ' '.join(sys.argv[1:]), '.'.join(test_id.split('.')[1:]),
|
| + experiment_args)
|
| + if flags.failfast:
|
| + return
|
|
|
| if __name__ == '__main__':
|
| main()
|
|
|