From: Tomas Krizek Date: Tue, 20 Nov 2018 14:18:56 +0000 (+0100) Subject: pytests: add html report X-Git-Tag: v3.2.0~18^2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4dda8df2f00bc21568c7164bbf6e39a3be04621e;p=thirdparty%2Fknot-resolver.git pytests: add html report --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cc7d9b2df..39005be18 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -287,7 +287,15 @@ pytests:run: except: - master script: - - PATH="$PREFIX/sbin:$PATH" ./ci/pytests/run.sh + - PATH="$PREFIX/sbin:$PATH" ./ci/pytests/run.sh &> pytests.log.txt + after_script: + - tail -1 pytests.log.txt + - echo "See pytests.html or pytests.log.txt for full report." + artifacts: + when: always + expire_in: 1 week + paths: + - pytest* tags: - docker - linux diff --git a/ci/pytests/run.sh b/ci/pytests/run.sh index bd1a1b216..e1b55afc6 100755 --- a/ci/pytests/run.sh +++ b/ci/pytests/run.sh @@ -1,3 +1,3 @@ #!/bin/bash -python3 -m pytest -ra -n 24 tests/pytests +python3 -m pytest --html pytests.html --self-contained-html -dn 24 tests/pytests diff --git a/tests/pytests/README.rst b/tests/pytests/README.rst index f6cb7c957..e066f3c0d 100644 --- a/tests/pytests/README.rst +++ b/tests/pytests/README.rst @@ -18,7 +18,7 @@ Tests can be executed with the pytest framework. $ pytest-3 # sequential, all tests (with exception of few special tests) $ pytest-3 test_conn_mgmt.py::test_ignore_garbage # specific test only - $ pytest-3 -s # turn on verbose logs even for successfull tests + $ pytest-3 --html pytests.html --self-contained-html # html report It's highly recommended to run these tests in parallel, since lot of them wait for kresd timeout. This can be don with `python-xdist`: diff --git a/tests/pytests/conftest.py b/tests/pytests/conftest.py index 7beed5050..9e7370d31 100644 --- a/tests/pytests/conftest.py +++ b/tests/pytests/conftest.py @@ -49,3 +49,15 @@ def kresd_sock(make_kresd_sock): ]) def sock_family(request): return request.param + + +@pytest.mark.optionalhook +def pytest_metadata(metadata): # filter potentially sensitive data from GitLab CI + keys_to_delete = [] + for key in metadata.keys(): + key_lower = key.lower() + if 'password' in key_lower or 'token' in key_lower or \ + key_lower.startswith('ci') or key_lower.startswith('gitlab'): + keys_to_delete.append(key) + for key in keys_to_delete: + del metadata[key] diff --git a/tests/pytests/requirements.txt b/tests/pytests/requirements.txt index 98bedb0c6..6e2e4d24a 100644 --- a/tests/pytests/requirements.txt +++ b/tests/pytests/requirements.txt @@ -1,4 +1,5 @@ dnspython jinja2 pytest +pytest-html pytest-xdist