Fix bugs in ansible-test units command. (#24044)
* Handle old versions of coverage. * Handle old versions of setuptools. * Detect python version for docker/remote units. * Add sanity override for test constraints.
This commit is contained in:
parent
51e3390333
commit
d662f6f0db
6 changed files with 20 additions and 1 deletions
|
@ -16,6 +16,7 @@ from lib.executor import (
|
||||||
SubprocessError,
|
SubprocessError,
|
||||||
ShellConfig,
|
ShellConfig,
|
||||||
SanityConfig,
|
SanityConfig,
|
||||||
|
UnitsConfig,
|
||||||
create_shell_command,
|
create_shell_command,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -201,6 +202,10 @@ def delegate_docker(args, exclude, require):
|
||||||
docker_exec(args, test_id, ['mkdir', '/root/ansible'])
|
docker_exec(args, test_id, ['mkdir', '/root/ansible'])
|
||||||
docker_exec(args, test_id, ['tar', 'oxzf', '/root/ansible.tgz', '-C', '/root/ansible'])
|
docker_exec(args, test_id, ['tar', 'oxzf', '/root/ansible.tgz', '-C', '/root/ansible'])
|
||||||
|
|
||||||
|
# docker images are only expected to have a single python version available
|
||||||
|
if isinstance(args, UnitsConfig) and not args.python:
|
||||||
|
cmd += ['--python', 'default']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
docker_exec(args, test_id, cmd, options=cmd_options)
|
docker_exec(args, test_id, cmd, options=cmd_options)
|
||||||
finally:
|
finally:
|
||||||
|
@ -356,6 +361,10 @@ def delegate_remote(args, exclude, require):
|
||||||
if not args.allow_destructive:
|
if not args.allow_destructive:
|
||||||
cmd.append('--allow-destructive')
|
cmd.append('--allow-destructive')
|
||||||
|
|
||||||
|
# remote instances are only expected to have a single python version available
|
||||||
|
if isinstance(args, UnitsConfig) and not args.python:
|
||||||
|
cmd += ['--python', 'default']
|
||||||
|
|
||||||
manage = ManagePosixCI(core_ci)
|
manage = ManagePosixCI(core_ci)
|
||||||
manage.setup()
|
manage.setup()
|
||||||
|
|
||||||
|
|
|
@ -477,6 +477,9 @@ class EnvironmentConfig(CommonConfig):
|
||||||
|
|
||||||
self.requirements = args.requirements # type: bool
|
self.requirements = args.requirements # type: bool
|
||||||
|
|
||||||
|
if self.python == 'default':
|
||||||
|
self.python = '.'.join(str(i) for i in sys.version_info[:2])
|
||||||
|
|
||||||
self.python_version = self.python or '.'.join(str(i) for i in sys.version_info[:2])
|
self.python_version = self.python or '.'.join(str(i) for i in sys.version_info[:2])
|
||||||
|
|
||||||
self.delegate = self.tox or self.docker or self.remote
|
self.delegate = self.tox or self.docker or self.remote
|
||||||
|
|
|
@ -12,5 +12,6 @@ pytest-xdist
|
||||||
python-memcached
|
python-memcached
|
||||||
pyyaml
|
pyyaml
|
||||||
redis
|
redis
|
||||||
|
setuptools > 0.6 # pytest-xdist installed via requirements does not work with very old setuptools (sanity_ok)
|
||||||
unittest2 ; python_version < '2.7'
|
unittest2 ; python_version < '2.7'
|
||||||
netaddr
|
netaddr
|
||||||
|
|
|
@ -241,7 +241,7 @@ def parse_args():
|
||||||
|
|
||||||
units.add_argument('--python',
|
units.add_argument('--python',
|
||||||
metavar='VERSION',
|
metavar='VERSION',
|
||||||
choices=SUPPORTED_PYTHON_VERSIONS,
|
choices=SUPPORTED_PYTHON_VERSIONS + ('default',),
|
||||||
help='python version: %s' % ', '.join(SUPPORTED_PYTHON_VERSIONS))
|
help='python version: %s' % ', '.join(SUPPORTED_PYTHON_VERSIONS))
|
||||||
|
|
||||||
units.add_argument('--collect-only',
|
units.add_argument('--collect-only',
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
constraints=$(
|
constraints=$(
|
||||||
grep '.' test/runner/requirements/*.txt \
|
grep '.' test/runner/requirements/*.txt \
|
||||||
|
| grep -v '(sanity_ok)$' \
|
||||||
| sed 's/ *;.*$//; s/ #.*$//' \
|
| sed 's/ *;.*$//; s/ #.*$//' \
|
||||||
| grep -v '/constraints.txt:' \
|
| grep -v '/constraints.txt:' \
|
||||||
| grep '[<>=]'
|
| grep '[<>=]'
|
||||||
|
|
|
@ -7,6 +7,11 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
coverage = None
|
coverage = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
test = coverage.Coverage
|
||||||
|
except AttributeError:
|
||||||
|
coverage = None
|
||||||
|
|
||||||
|
|
||||||
def pytest_configure():
|
def pytest_configure():
|
||||||
if not coverage:
|
if not coverage:
|
||||||
|
|
Loading…
Reference in a new issue