tests: Improve unit tests runtime performance

This patch set does 2 things:

1) Improves unit test runtime peformance via pytest-xdist [0]
2) Reduces finnicky nature of `is_connected` helpers which
   sometimes skip even when there is access to the internet;
   logic has been added to make these checks more accurate
   to avoid skipping tests

Note that while there are newer alternatives to pytest-xdist they
are only compatible with much newer versions of Python.

[0] https://pypi.org/project/pytest-xdist/

Change-Id: Ib04b48ebabca0551058e5e1065056f4e559fbfe6
This commit is contained in:
Felipe Monteiro
2018-10-17 21:32:28 +01:00
parent e3e5683765
commit b28788325f
4 changed files with 31 additions and 21 deletions

View File

@@ -2,9 +2,11 @@
set -e
posargs=$@
# cross-platform way to derive the number of logical cores
readonly num_cores=$(python -c 'import multiprocessing as mp; print(mp.cpu_count())')
if [ ${#posargs} -ge 1 ]; then
pytest -k ${posargs}
pytest -k ${posargs} -n $num_cores
else
pytest
pytest -n $num_cores
fi
set +e