Use subset of Windows tests for "all" tests. (#26830)

This commit is contained in:
Matt Clay 2017-07-14 16:51:32 -07:00 committed by GitHub
parent 32914cac3b
commit 7931e11437
6 changed files with 81 additions and 57 deletions

View file

@ -23,14 +23,20 @@ from lib.import_analysis import (
get_python_module_utils_imports,
)
from lib.config import (
TestConfig,
IntegrationConfig,
)
def categorize_changes(paths, verbose_command=None):
def categorize_changes(args, paths, verbose_command=None):
"""
:type args: TestConfig
:type paths: list[str]
:type verbose_command: str
:rtype paths: dict[str, list[str]]
"""
mapper = PathMapper()
mapper = PathMapper(args)
commands = {
'sanity': set(),
@ -71,7 +77,7 @@ def categorize_changes(paths, verbose_command=None):
if tests is None:
display.info('%s -> all' % path, verbosity=1)
tests = all_tests() # not categorized, run all tests
tests = all_tests(args) # not categorized, run all tests
display.warning('Path not categorized: %s' % path)
else:
tests = dict((key, value) for key, value in tests.items() if value)
@ -102,7 +108,13 @@ def categorize_changes(paths, verbose_command=None):
class PathMapper(object):
"""Map file paths to test commands and targets."""
def __init__(self):
def __init__(self, args):
"""
:type args: TestConfig
"""
self.args = args
self.integration_all_target = get_integration_all_target(self.args)
self.integration_targets = list(walk_integration_targets())
self.module_targets = list(walk_module_targets())
self.compile_targets = list(walk_compile_targets())
@ -250,7 +262,7 @@ class PathMapper(object):
if path.startswith('lib/ansible/module_utils/'):
if ext == '.ps1':
return {
'windows-integration': 'all',
'windows-integration': self.integration_all_target,
}
if ext == '.py':
@ -259,9 +271,9 @@ class PathMapper(object):
if path.startswith('lib/ansible/plugins/connection/'):
if name == '__init__':
return {
'integration': 'all',
'windows-integration': 'all',
'network-integration': 'all',
'integration': self.integration_all_target,
'windows-integration': self.integration_all_target,
'network-integration': self.integration_all_target,
'units': 'test/units/plugins/connection/',
}
@ -279,20 +291,20 @@ class PathMapper(object):
if name == 'winrm':
return {
'windows-integration': 'all',
'windows-integration': self.integration_all_target,
'units': units_path,
}
if name == 'local':
return {
'integration': 'all',
'network-integration': 'all',
'integration': self.integration_all_target,
'network-integration': self.integration_all_target,
'units': units_path,
}
if name == 'network_cli':
return {
'network-integration': 'all',
'network-integration': self.integration_all_target,
'units': units_path,
}
@ -321,7 +333,7 @@ class PathMapper(object):
}
return {
'network-integration': 'all',
'network-integration': self.integration_all_target,
'units': 'all',
}
@ -331,7 +343,7 @@ class PathMapper(object):
}
if path.startswith('lib/ansible/'):
return all_tests() # broad impact, run all tests
return all_tests(self.args) # broad impact, run all tests
if path.startswith('packaging/'):
return minimal
@ -358,9 +370,9 @@ class PathMapper(object):
return minimal # already expanded using get_dependent_paths
return {
'integration': 'all',
'windows-integration': 'all',
'network-integration': 'all',
'integration': self.integration_all_target,
'windows-integration': self.integration_all_target,
'network-integration': self.integration_all_target,
}
return {
@ -377,9 +389,9 @@ class PathMapper(object):
return minimal # network integration test playbook not used by ansible-test
return {
'integration': 'all',
'windows-integration': 'all',
'network-integration': 'all',
'integration': self.integration_all_target,
'windows-integration': self.integration_all_target,
'network-integration': self.integration_all_target,
}
if path.startswith('test/sanity/'):
@ -413,13 +425,13 @@ class PathMapper(object):
'integration': cloud_target,
}
return all_tests() # test infrastructure, run all tests
return all_tests(self.args) # test infrastructure, run all tests
if path.startswith('test/runner/'):
return all_tests() # test infrastructure, run all tests
return all_tests(self.args) # test infrastructure, run all tests
if path.startswith('test/utils/shippable/'):
return all_tests() # test infrastructure, run all tests
return all_tests(self.args) # test infrastructure, run all tests
if path.startswith('test/utils/'):
return minimal
@ -448,7 +460,7 @@ class PathMapper(object):
'shippable.yml',
'.coveragerc',
):
return all_tests() # test infrastructure, run all tests
return all_tests(self.args) # test infrastructure, run all tests
if path == '.yamllint':
return {
@ -461,15 +473,29 @@ class PathMapper(object):
return None # unknown, will result in fall-back to run all tests
def all_tests():
def all_tests(args):
"""
:type args: TestConfig
:rtype: dict[str, str]
"""
integration_all_target = get_integration_all_target(args)
return {
'sanity': 'all',
'compile': 'all',
'units': 'all',
'integration': 'all',
'windows-integration': 'all',
'network-integration': 'all',
'integration': integration_all_target,
'windows-integration': integration_all_target,
'network-integration': integration_all_target,
}
def get_integration_all_target(args):
"""
:type args: TestConfig
:rtype: str
"""
if isinstance(args, IntegrationConfig):
return args.changed_all_target
return 'all'