Improve test resiliency

Avoids occasional test executions failures
caused by leftover files on dev machine or
by preexisting configuration files.

Change-Id: Ia0ba29e2dda58c37410a6926cae3039e4ba3473e
This commit is contained in:
Sorin Sbarnea 2018-01-14 19:56:47 +00:00
parent 705051658f
commit c0b3b021dc
4 changed files with 23 additions and 11 deletions

3
.gitignore vendored
View File

@ -16,7 +16,8 @@ etc/jenkins_jobs.ini
dist/*
doc/build/*
jenkins_jobs/versioninfo
.coverage
.coverage*
cover/
jenkins-job-builder
testr_subunit_log
__pycache__

View File

@ -199,10 +199,10 @@ class JJBConfig(object):
# check the ignore_cache setting
ignore_cache = False
if config.has_option(self._section, 'ignore_cache'):
logging.warning("ignore_cache option should be moved to the "
"[job_builder] section in the config file, the "
"one specified in the [jenkins] section will be "
"ignored in the future")
logger.warning("ignore_cache option should be moved to the "
"[job_builder] section in the config file, the "
"one specified in the [jenkins] section will be "
"ignored in the future")
ignore_cache = config.getboolean(self._section, 'ignore_cache')
elif config.has_option('job_builder', 'ignore_cache'):
ignore_cache = config.getboolean('job_builder', 'ignore_cache')

View File

@ -100,8 +100,11 @@ def get_scenarios(fixtures_path, in_ext='yaml', out_ext='xml',
conf_candidate = re.sub(r'\.yaml$|\.json$', '.conf', input_filename)
conf_filename = files.get(os.path.basename(conf_candidate), None)
if conf_filename is not None:
if conf_filename:
conf_filename = conf_filename[0]
else:
# for testing purposes we want to avoid using user config files
conf_filename = os.devnull
scenarios.append((input_filename, {
'in_filename': input_filename,

18
tox.ini
View File

@ -5,15 +5,23 @@ skip_missing_interpreters = true
[testenv]
# Note(Vek): JJB is not compatible with a non-zero PYTHONHASHSEED
setenv = VIRTUAL_ENV={envdir}
SUBUNIT_FORMATTER=tee testr_subunit_log
OS_STDOUT_NOCAPTURE=False
PYTHONHASHSEED=0
setenv =
LANG=en_US.UTF-8
PYTHONDONTWRITEBYTECODE=1
PYTHONHASHSEED=0
SUBUNIT_FORMATTER=tee testr_subunit_log
VIRTUAL_ENV={envdir}
usedevelop = True
install_command = pip install {opts} {packages}
deps = -r{toxinidir}/test-requirements.txt
commands = python setup.py testr --slowest --testr-args='{posargs}'
# cleanup is needed mostly for dev environmnts and assures that if dev
# is switching branch, no lefovers will impact execution.
# No git commands here because test should run even from a source archive.
commands =
- find . -type f -name "*.pyc" -delete
- find . -type d -name "__pycache__" -delete
python setup.py testr --slowest --testr-args='{posargs}'
whitelist_externals = find
[testenv:cover]
commands =