Some tests input data returned by swh-web fixtures are sampled from
filtered objects stored in a static test archive.
In order to reproduce any failing test with the same fixture data:
- add a new autouse function scope fixture setting the random seed
to current time before each test execution and putting that seed
in cache
- implement custom pytest reporting which adds a new section detailing
the random seeds used for each failing test and the pytests commands
to reproduce the failures
- add a new pytest option --swh-web-random-seed enabling to explicitely
specify the random seed that will be used to run the tests
After hacking on a test to make it fail, this is the pytest output we get:
```
15:39 $ pytest -sv swh/web/tests/api/views/test_directory.py::test_api_directory
================================================================================================================================== test session starts ==================================================================================================================================
platform linux -- Python 3.9.2, pytest-6.2.5, py-1.10.0, pluggy-1.0.0 -- /home/anlambert/.virtualenvs/swh/bin/python
cachedir: .pytest_cache
django: settings: swh.web.settings.tests (from ini)
hypothesis profile 'swh-web-fast' -> deadline=None, max_examples=5, database=DirectoryBasedExampleDatabase('/home/anlambert/swh/swh-environment/swh-web/.hypothesis/examples'), suppress_health_check=[HealthCheck.too_slow, HealthCheck.filter_too_much, HealthCheck.function_scoped_fixture]
rootdir: /home/anlambert/swh/swh-environment/swh-web, configfile: pytest.ini
plugins: django-4.4.0, postgresql-3.1.1, hypothesis-6.23.2, mock-3.6.1, requests-mock-1.9.3, xdist-2.4.0, redis-2.1.1, dash-2.0.0, forked-1.3.0, asyncio-0.15.1, django-test-migrations-1.1.0, swh.core-0.15.0, swh.journal-0.8.1.dev1+g95d945e
collected 1 item
swh/web/tests/api/views/test_directory.py::test_api_directory FAILED
======================================================================================================================================= FAILURES ========================================================================================================================================
__________________________________________________________________________________________________________________________________ test_api_directory ___________________________________________________________________________________________________________________________________
api_client = <rest_framework.test.APIClient object at 0x7ff03702a910>, archive_data = <swh.web.tests.conftest._ArchiveData object at 0x7ff03702a7f0>, directory = 'bf0bc5553f663cf2d58c6b86a0bf409e23eb60ee'
def test_api_directory(api_client, archive_data, directory):
url = reverse("api-1-directory", url_args={"sha1_git": directory})
rv = check_api_get_responses(api_client, url, status_code=200)
dir_content = list(archive_data.directory_ls(directory))
expected_data = list(
map(enrich_directory_entry, dir_content, [rv.wsgi_request] * len(dir_content))
)
> assert rv.data != expected_data
E assert [{'checksums': {'sha1': 'a64431fdd98a365de8804650801fcf09e6e1fa25', 'sha1_git': '7895cfc379e8ac385d9e8690834d0e0396d88...8'}, 'dir_id': 'bf0bc5553f663cf2d58c6b86a0bf409e23eb60ee', 'length': 5353, 'name': 'highlightjs-line-numbers.js', ...}] != [{'checksums': {'sha1': 'a64431fdd98a365de8804650801fcf09e6e1fa25', 'sha1_git': '7895cfc379e8ac385d9e8690834d0e0396d88...8'}, 'dir_id': 'bf0bc5553f663cf2d58c6b86a0bf409e23eb60ee', 'length': 5353, 'name': 'highlightjs-line-numbers.js', ...}]
E + where [{'checksums': {'sha1': 'a64431fdd98a365de8804650801fcf09e6e1fa25', 'sha1_git': '7895cfc379e8ac385d9e8690834d0e0396d88...8'}, 'dir_id': 'bf0bc5553f663cf2d58c6b86a0bf409e23eb60ee', 'length': 5353, 'name': 'highlightjs-line-numbers.js', ...}] = <Response status_code=200, "application/json">.data
swh/web/tests/api/views/test_directory.py:24: AssertionError
---------------------------------------------------------------------------------------------------------------------------------- Captured log setup -----------------------------------------------------------------------------------------------------------------------------------
INFO swh.loader.git.from_disk.GitLoaderFromArchive:loader.py:330 Load origin 'https://github.com/memononen/libtess2' with type 'git'
INFO swh.loader.git.from_disk:from_disk.py:433 Project https://github.com/memononen/libtess2 - Uncompressing archive libtess2.zip at /tmp/tmp.4lxzsfz5.swh.loader.git/libtess2
INFO swh.loader.git.from_disk:from_disk.py:448 Project https://github.com/memononen/libtess2 - Done injecting /tmp/tmp.4lxzsfz5.swh.loader.git/libtess2
INFO swh.loader.git.from_disk.GitLoaderFromArchive:loader.py:330 Load origin 'https://github.com/wcoder/highlightjs-line-numbers.js' with type 'git'
INFO swh.loader.git.from_disk:from_disk.py:433 Project https://github.com/wcoder/highlightjs-line-numbers.js - Uncompressing archive highlightjs-line-numbers.js.zip at /tmp/tmp.xmkex_j3.swh.loader.git/highlightjs-line-numbers.js
INFO swh.loader.git.from_disk:from_disk.py:448 Project https://github.com/wcoder/highlightjs-line-numbers.js - Done injecting /tmp/tmp.xmkex_j3.swh.loader.git/highlightjs-line-numbers.js
INFO swh.loader.git.from_disk.GitLoaderFromArchive:loader.py:330 Load origin 'https://github.com/wcoder/highlightjs-line-numbers.js' with type 'git'
INFO swh.loader.git.from_disk:from_disk.py:433 Project https://github.com/wcoder/highlightjs-line-numbers.js - Uncompressing archive highlightjs-line-numbers.js_visit2.zip at /tmp/tmp.lpiu0lga.swh.loader.git/highlightjs-line-numbers.js_visit2
INFO swh.loader.git.from_disk:from_disk.py:448 Project https://github.com/wcoder/highlightjs-line-numbers.js - Done injecting /tmp/tmp.lpiu0lga.swh.loader.git/highlightjs-line-numbers.js_visit2
INFO swh.loader.git.from_disk.GitLoaderFromArchive:loader.py:330 Load origin 'repo_with_submodules' with type 'git'
INFO swh.loader.git.from_disk:from_disk.py:433 Project repo_with_submodules - Uncompressing archive repo_with_submodules.tgz at /tmp/tmp.cj3vdywt.swh.loader.git/repo_with_submodules
INFO swh.loader.git.from_disk:from_disk.py:448 Project repo_with_submodules - Done injecting /tmp/tmp.cj3vdywt.swh.loader.git/repo_with_submodules
DEBUG swh.indexer:indexer.py:161 <swh.indexer.mimetype.MimetypeIndexer object at 0x7ff032079eb0>: config={'indexer_storage': {'cls': 'memory', 'args': {}}, 'tools': {'name': 'file', 'version': '1:5.30-1+deb9u1', 'configuration': {'type': 'library', 'debian-package': 'python3-magic'}}, 'storage': {'cls': 'memory'}, 'objstorage': {'cls': 'memory', 'args': {}}}
DEBUG swh.indexer:indexer.py:161 <swh.indexer.fossology_license.FossologyLicenseIndexer object at 0x7ff01aa435e0>: config={'tools': {'name': 'nomos', 'version': '3.1.0rc2-31-ga2cbb8c', 'configuration': {'command_line': 'nomossa <filepath>'}}, 'workdir': '/tmp/swh/indexer.fossology.license', 'storage': {'cls': 'memory'}, 'objstorage': {'cls': 'memory', 'args': {}}, 'indexer_storage': {'cls': 'memory', 'args': {}}}
DEBUG swh.indexer:indexer.py:161 <swh.indexer.ctags.CtagsIndexer object at 0x7ff03b14a220>: config={'tools': {'name': 'universal-ctags', 'version': '~git7859817b', 'configuration': {'command_line': 'ctags --fields=+lnz --sort=no --links=no --output-format=json <filepath>'}}, 'languages': {'c': 'c'}, 'workdir': '/tmp/swh/indexer.ctags', 'storage': {'cls': 'memory'}, 'objstorage': {'cls': 'memory', 'args': {}}, 'indexer_storage': {'cls': 'memory', 'args': {}}}
----------------------------------------------------------------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------------------------------------------------------------
DEBUG urllib3.connectionpool:connectionpool.py:227 Starting new HTTP connection (1): saatchi.internal.softwareheritage.org:5008
DEBUG urllib3.util.retry:retry.py:576 Incremented Retry for (url='/task_type/get_all'): Retry(total=2, connect=None, read=None, redirect=None, status=None)
WARNING urllib3.connectionpool:connectionpool.py:780 Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7ff01ad747f0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /task_type/get_all
DEBUG urllib3.connectionpool:connectionpool.py:227 Starting new HTTP connection (2): saatchi.internal.softwareheritage.org:5008
DEBUG urllib3.util.retry:retry.py:576 Incremented Retry for (url='/task_type/get_all'): Retry(total=1, connect=None, read=None, redirect=None, status=None)
WARNING urllib3.connectionpool:connectionpool.py:780 Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7ff01ad74190>: Failed to establish a new connection: [Errno -2] Name or service not known')': /task_type/get_all
DEBUG urllib3.connectionpool:connectionpool.py:227 Starting new HTTP connection (3): saatchi.internal.softwareheritage.org:5008
DEBUG urllib3.util.retry:retry.py:576 Incremented Retry for (url='/task_type/get_all'): Retry(total=0, connect=None, read=None, redirect=None, status=None)
WARNING urllib3.connectionpool:connectionpool.py:780 Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7ff01ad74670>: Failed to establish a new connection: [Errno -2] Name or service not known')': /task_type/get_all
DEBUG urllib3.connectionpool:connectionpool.py:227 Starting new HTTP connection (4): saatchi.internal.softwareheritage.org:5008
-------------------------------------------------------------------------------------------------------------------------------- swh-web custom section ---------------------------------------------------------------------------------------------------------------------------------
FAILED swh/web/tests/api/views/test_directory.py::test_api_directory: Use "pytest --swh-web-random-seed=1634218842 swh/web/tests/api/views/test_directory.py::test_api_directory" to reproduce that test failure with same inputs
=================================================================================================================================== warnings summary ====================================================================================================================================
swh/web/tests/api/views/test_directory.py::test_api_directory
swh/web/tests/api/views/test_directory.py::test_api_directory
swh/web/tests/api/views/test_directory.py::test_api_directory
/home/anlambert/swh/swh-environment/swh-objstorage/swh/objstorage/factory.py:80: DeprecationWarning: Explicit "args" key is deprecated for objstorage initialization, use class arguments keys directly instead.
warnings.warn(
swh/web/tests/api/views/test_directory.py::test_api_directory
swh/web/tests/api/views/test_directory.py::test_api_directory
swh/web/tests/api/views/test_directory.py::test_api_directory
/home/anlambert/swh/swh-environment/swh-indexer/swh/indexer/storage/__init__.py:68: DeprecationWarning: Explicit "args" key is deprecated, use keys directly instead.
warnings.warn(
-- Docs: https://docs.pytest.org/en/stable/warnings.html
-------------------------------------------------------------------------------------------------------------------------------- swh-web custom section ---------------------------------------------------------------------------------------------------------------------------------
FAILED swh/web/tests/api/views/test_directory.py::test_api_directory: Use "pytest --swh-web-random-seed=1634218842 swh/web/tests/api/views/test_directory.py::test_api_directory" to reproduce that test failure with same inputs
================================================================================================================================ short test summary info ================================================================================================================================
FAILED swh/web/tests/api/views/test_directory.py::test_api_directory - assert [{'checksums': {'sha1': 'a64431fdd98a365de8804650801fcf09e6e1fa25', 'sha1_git': '7895cfc379e8ac385d9e8690834d0e0396d88...8'}, 'dir_id': 'bf0bc5553f663cf2d58c6b86a0bf409e23eb60ee', 'length': 5353, 'nam...
============================================================================================================================= 1 failed, 6 warnings in 2.78s =============================================================================================================================
```
If we run the same test again, we can see that directory fixture value is not the same due to random sampling:
```
15:40 $ pytest -sv swh/web/tests/api/views/test_directory.py::test_api_directory
================================================================================================================================== test session starts ==================================================================================================================================
platform linux -- Python 3.9.2, pytest-6.2.5, py-1.10.0, pluggy-1.0.0 -- /home/anlambert/.virtualenvs/swh/bin/python
cachedir: .pytest_cache
django: settings: swh.web.settings.tests (from ini)
hypothesis profile 'swh-web-fast' -> deadline=None, max_examples=5, database=DirectoryBasedExampleDatabase('/home/anlambert/swh/swh-environment/swh-web/.hypothesis/examples'), suppress_health_check=[HealthCheck.too_slow, HealthCheck.filter_too_much, HealthCheck.function_scoped_fixture]
rootdir: /home/anlambert/swh/swh-environment/swh-web, configfile: pytest.ini
plugins: django-4.4.0, postgresql-3.1.1, hypothesis-6.23.2, mock-3.6.1, requests-mock-1.9.3, xdist-2.4.0, redis-2.1.1, dash-2.0.0, forked-1.3.0, asyncio-0.15.1, django-test-migrations-1.1.0, swh.core-0.15.0, swh.journal-0.8.1.dev1+g95d945e
collected 1 item
swh/web/tests/api/views/test_directory.py::test_api_directory FAILED
======================================================================================================================================= FAILURES ========================================================================================================================================
__________________________________________________________________________________________________________________________________ test_api_directory ___________________________________________________________________________________________________________________________________
api_client = <rest_framework.test.APIClient object at 0x7fcf183a58e0>, archive_data = <swh.web.tests.conftest._ArchiveData object at 0x7fcf183a57c0>, directory = 'cd19126d815470b28919d64b2a8e6a3e37f900dd'
def test_api_directory(api_client, archive_data, directory):
url = reverse("api-1-directory", url_args={"sha1_git": directory})
rv = check_api_get_responses(api_client, url, status_code=200)
dir_content = list(archive_data.directory_ls(directory))
expected_data = list(
map(enrich_directory_entry, dir_content, [rv.wsgi_request] * len(dir_content))
)
> assert rv.data != expected_data
E assert [{'checksums': {'sha1': '1c34570332c08d4a0ff89ab1d1b7ed5924d7114f', 'sha1_git': '420ebab5ea719a78f9c3059087885fab3eca7...82b58d520ef8a6369'}, 'dir_id': 'cd19126d815470b28919d64b2a8e6a3e37f900dd', 'length': 3479, 'name': 'geom.h', ...}, ...] != [{'checksums': {'sha1': '1c34570332c08d4a0ff89ab1d1b7ed5924d7114f', 'sha1_git': '420ebab5ea719a78f9c3059087885fab3eca7...82b58d520ef8a6369'}, 'dir_id': 'cd19126d815470b28919d64b2a8e6a3e37f900dd', 'length': 3479, 'name': 'geom.h', ...}, ...]
E + where [{'checksums': {'sha1': '1c34570332c08d4a0ff89ab1d1b7ed5924d7114f', 'sha1_git': '420ebab5ea719a78f9c3059087885fab3eca7...82b58d520ef8a6369'}, 'dir_id': 'cd19126d815470b28919d64b2a8e6a3e37f900dd', 'length': 3479, 'name': 'geom.h', ...}, ...] = <Response status_code=200, "application/json">.data
swh/web/tests/api/views/test_directory.py:24: AssertionError
---------------------------------------------------------------------------------------------------------------------------------- Captured log setup -----------------------------------------------------------------------------------------------------------------------------------
INFO swh.loader.git.from_disk.GitLoaderFromArchive:loader.py:330 Load origin 'https://github.com/memononen/libtess2' with type 'git'
INFO swh.loader.git.from_disk:from_disk.py:433 Project https://github.com/memononen/libtess2 - Uncompressing archive libtess2.zip at /tmp/tmp.yexmaku6.swh.loader.git/libtess2
INFO swh.loader.git.from_disk:from_disk.py:448 Project https://github.com/memononen/libtess2 - Done injecting /tmp/tmp.yexmaku6.swh.loader.git/libtess2
INFO swh.loader.git.from_disk.GitLoaderFromArchive:loader.py:330 Load origin 'https://github.com/wcoder/highlightjs-line-numbers.js' with type 'git'
INFO swh.loader.git.from_disk:from_disk.py:433 Project https://github.com/wcoder/highlightjs-line-numbers.js - Uncompressing archive highlightjs-line-numbers.js.zip at /tmp/tmp.1mnjhyyj.swh.loader.git/highlightjs-line-numbers.js
INFO swh.loader.git.from_disk:from_disk.py:448 Project https://github.com/wcoder/highlightjs-line-numbers.js - Done injecting /tmp/tmp.1mnjhyyj.swh.loader.git/highlightjs-line-numbers.js
INFO swh.loader.git.from_disk.GitLoaderFromArchive:loader.py:330 Load origin 'https://github.com/wcoder/highlightjs-line-numbers.js' with type 'git'
INFO swh.loader.git.from_disk:from_disk.py:433 Project https://github.com/wcoder/highlightjs-line-numbers.js - Uncompressing archive highlightjs-line-numbers.js_visit2.zip at /tmp/tmp.vqfk0ph8.swh.loader.git/highlightjs-line-numbers.js_visit2
INFO swh.loader.git.from_disk:from_disk.py:448 Project https://github.com/wcoder/highlightjs-line-numbers.js - Done injecting /tmp/tmp.vqfk0ph8.swh.loader.git/highlightjs-line-numbers.js_visit2
INFO swh.loader.git.from_disk.GitLoaderFromArchive:loader.py:330 Load origin 'repo_with_submodules' with type 'git'
INFO swh.loader.git.from_disk:from_disk.py:433 Project repo_with_submodules - Uncompressing archive repo_with_submodules.tgz at /tmp/tmp.y480bwjf.swh.loader.git/repo_with_submodules
INFO swh.loader.git.from_disk:from_disk.py:448 Project repo_with_submodules - Done injecting /tmp/tmp.y480bwjf.swh.loader.git/repo_with_submodules
DEBUG swh.indexer:indexer.py:161 <swh.indexer.mimetype.MimetypeIndexer object at 0x7fcf133fa310>: config={'tools': {'name': 'file', 'configuration': {'type': 'library', 'debian-package': 'python3-magic'}, 'version': '1:5.30-1+deb9u1'}, 'indexer_storage': {'cls': 'memory', 'args': {}}, 'storage': {'cls': 'memory'}, 'objstorage': {'cls': 'memory', 'args': {}}}
DEBUG swh.indexer:indexer.py:161 <swh.indexer.fossology_license.FossologyLicenseIndexer object at 0x7fcefbcf17f0>: config={'workdir': '/tmp/swh/indexer.fossology.license', 'storage': {'cls': 'memory'}, 'tools': {'name': 'nomos', 'configuration': {'command_line': 'nomossa <filepath>'}, 'version': '3.1.0rc2-31-ga2cbb8c'}, 'indexer_storage': {'cls': 'memory', 'args': {}}, 'objstorage': {'cls': 'memory', 'args': {}}}
DEBUG swh.indexer:indexer.py:161 <swh.indexer.ctags.CtagsIndexer object at 0x7fcf1c4c4220>: config={'workdir': '/tmp/swh/indexer.ctags', 'storage': {'cls': 'memory'}, 'tools': {'name': 'universal-ctags', 'configuration': {'command_line': 'ctags --fields=+lnz --sort=no --links=no --output-format=json <filepath>'}, 'version': '~git7859817b'}, 'indexer_storage': {'cls': 'memory', 'args': {}}, 'languages': {'c': 'c'}, 'objstorage': {'cls': 'memory', 'args': {}}}
----------------------------------------------------------------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------------------------------------------------------------
DEBUG urllib3.connectionpool:connectionpool.py:227 Starting new HTTP connection (1): saatchi.internal.softwareheritage.org:5008
DEBUG urllib3.util.retry:retry.py:576 Incremented Retry for (url='/task_type/get_all'): Retry(total=2, connect=None, read=None, redirect=None, status=None)
WARNING urllib3.connectionpool:connectionpool.py:780 Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fcefc036550>: Failed to establish a new connection: [Errno -2] Name or service not known')': /task_type/get_all
DEBUG urllib3.connectionpool:connectionpool.py:227 Starting new HTTP connection (2): saatchi.internal.softwareheritage.org:5008
DEBUG urllib3.util.retry:retry.py:576 Incremented Retry for (url='/task_type/get_all'): Retry(total=1, connect=None, read=None, redirect=None, status=None)
WARNING urllib3.connectionpool:connectionpool.py:780 Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fcefb999940>: Failed to establish a new connection: [Errno -2] Name or service not known')': /task_type/get_all
DEBUG urllib3.connectionpool:connectionpool.py:227 Starting new HTTP connection (3): saatchi.internal.softwareheritage.org:5008
DEBUG urllib3.util.retry:retry.py:576 Incremented Retry for (url='/task_type/get_all'): Retry(total=0, connect=None, read=None, redirect=None, status=None)
WARNING urllib3.connectionpool:connectionpool.py:780 Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fcefb999490>: Failed to establish a new connection: [Errno -2] Name or service not known')': /task_type/get_all
DEBUG urllib3.connectionpool:connectionpool.py:227 Starting new HTTP connection (4): saatchi.internal.softwareheritage.org:5008
-------------------------------------------------------------------------------------------------------------------------------- swh-web custom section ---------------------------------------------------------------------------------------------------------------------------------
FAILED swh/web/tests/api/views/test_directory.py::test_api_directory: Use "pytest --swh-web-random-seed=1634218902 swh/web/tests/api/views/test_directory.py::test_api_directory" to reproduce that test failure with same inputs
=================================================================================================================================== warnings summary ====================================================================================================================================
swh/web/tests/api/views/test_directory.py::test_api_directory
swh/web/tests/api/views/test_directory.py::test_api_directory
swh/web/tests/api/views/test_directory.py::test_api_directory
/home/anlambert/swh/swh-environment/swh-objstorage/swh/objstorage/factory.py:80: DeprecationWarning: Explicit "args" key is deprecated for objstorage initialization, use class arguments keys directly instead.
warnings.warn(
swh/web/tests/api/views/test_directory.py::test_api_directory
swh/web/tests/api/views/test_directory.py::test_api_directory
swh/web/tests/api/views/test_directory.py::test_api_directory
/home/anlambert/swh/swh-environment/swh-indexer/swh/indexer/storage/__init__.py:68: DeprecationWarning: Explicit "args" key is deprecated, use keys directly instead.
warnings.warn(
-- Docs: https://docs.pytest.org/en/stable/warnings.html
-------------------------------------------------------------------------------------------------------------------------------- swh-web custom section ---------------------------------------------------------------------------------------------------------------------------------
FAILED swh/web/tests/api/views/test_directory.py::test_api_directory: Use "pytest --swh-web-random-seed=1634218902 swh/web/tests/api/views/test_directory.py::test_api_directory" to reproduce that test failure with same inputs
================================================================================================================================ short test summary info ================================================================================================================================
FAILED swh/web/tests/api/views/test_directory.py::test_api_directory - assert [{'checksums': {'sha1': '1c34570332c08d4a0ff89ab1d1b7ed5924d7114f', 'sha1_git': '420ebab5ea719a78f9c3059087885fab3eca7...82b58d520ef8a6369'}, 'dir_id': 'cd19126d815470b28919d64b2a8e6a3e37f900dd', 'len...
============================================================================================================================= 1 failed, 6 warnings in 2.76s =============================================================================================================================
```
If we explicitely pass the random seed used in previous test run, we can see the directory fixture value is now the same:
```
15:41 $ pytest -sv --swh-web-random-seed=1634218902 swh/web/tests/api/views/test_directory.py::test_api_directory
================================================================================================================================== test session starts ==================================================================================================================================
platform linux -- Python 3.9.2, pytest-6.2.5, py-1.10.0, pluggy-1.0.0 -- /home/anlambert/.virtualenvs/swh/bin/python
cachedir: .pytest_cache
django: settings: swh.web.settings.tests (from ini)
hypothesis profile 'swh-web-fast' -> deadline=None, max_examples=5, database=DirectoryBasedExampleDatabase('/home/anlambert/swh/swh-environment/swh-web/.hypothesis/examples'), suppress_health_check=[HealthCheck.too_slow, HealthCheck.filter_too_much, HealthCheck.function_scoped_fixture]
rootdir: /home/anlambert/swh/swh-environment/swh-web, configfile: pytest.ini
plugins: django-4.4.0, postgresql-3.1.1, hypothesis-6.23.2, mock-3.6.1, requests-mock-1.9.3, xdist-2.4.0, redis-2.1.1, dash-2.0.0, forked-1.3.0, asyncio-0.15.1, django-test-migrations-1.1.0, swh.core-0.15.0, swh.journal-0.8.1.dev1+g95d945e
collected 1 item
swh/web/tests/api/views/test_directory.py::test_api_directory FAILED
======================================================================================================================================= FAILURES ========================================================================================================================================
__________________________________________________________________________________________________________________________________ test_api_directory ___________________________________________________________________________________________________________________________________
api_client = <rest_framework.test.APIClient object at 0x7fd6bf2211f0>, archive_data = <swh.web.tests.conftest._ArchiveData object at 0x7fd6bf23b850>, directory = 'cd19126d815470b28919d64b2a8e6a3e37f900dd'
def test_api_directory(api_client, archive_data, directory):
url = reverse("api-1-directory", url_args={"sha1_git": directory})
rv = check_api_get_responses(api_client, url, status_code=200)
dir_content = list(archive_data.directory_ls(directory))
expected_data = list(
map(enrich_directory_entry, dir_content, [rv.wsgi_request] * len(dir_content))
)
> assert rv.data != expected_data
E assert [{'checksums': {'sha1': '1c34570332c08d4a0ff89ab1d1b7ed5924d7114f', 'sha1_git': '420ebab5ea719a78f9c3059087885fab3eca7...82b58d520ef8a6369'}, 'dir_id': 'cd19126d815470b28919d64b2a8e6a3e37f900dd', 'length': 3479, 'name': 'geom.h', ...}, ...] != [{'checksums': {'sha1': '1c34570332c08d4a0ff89ab1d1b7ed5924d7114f', 'sha1_git': '420ebab5ea719a78f9c3059087885fab3eca7...82b58d520ef8a6369'}, 'dir_id': 'cd19126d815470b28919d64b2a8e6a3e37f900dd', 'length': 3479, 'name': 'geom.h', ...}, ...]
E + where [{'checksums': {'sha1': '1c34570332c08d4a0ff89ab1d1b7ed5924d7114f', 'sha1_git': '420ebab5ea719a78f9c3059087885fab3eca7...82b58d520ef8a6369'}, 'dir_id': 'cd19126d815470b28919d64b2a8e6a3e37f900dd', 'length': 3479, 'name': 'geom.h', ...}, ...] = <Response status_code=200, "application/json">.data
swh/web/tests/api/views/test_directory.py:24: AssertionError
---------------------------------------------------------------------------------------------------------------------------------- Captured log setup -----------------------------------------------------------------------------------------------------------------------------------
INFO swh.loader.git.from_disk.GitLoaderFromArchive:loader.py:330 Load origin 'https://github.com/memononen/libtess2' with type 'git'
INFO swh.loader.git.from_disk:from_disk.py:433 Project https://github.com/memononen/libtess2 - Uncompressing archive libtess2.zip at /tmp/tmp.y6zjknjo.swh.loader.git/libtess2
INFO swh.loader.git.from_disk:from_disk.py:448 Project https://github.com/memononen/libtess2 - Done injecting /tmp/tmp.y6zjknjo.swh.loader.git/libtess2
INFO swh.loader.git.from_disk.GitLoaderFromArchive:loader.py:330 Load origin 'https://github.com/wcoder/highlightjs-line-numbers.js' with type 'git'
INFO swh.loader.git.from_disk:from_disk.py:433 Project https://github.com/wcoder/highlightjs-line-numbers.js - Uncompressing archive highlightjs-line-numbers.js.zip at /tmp/tmp.jcmzrsw7.swh.loader.git/highlightjs-line-numbers.js
INFO swh.loader.git.from_disk:from_disk.py:448 Project https://github.com/wcoder/highlightjs-line-numbers.js - Done injecting /tmp/tmp.jcmzrsw7.swh.loader.git/highlightjs-line-numbers.js
INFO swh.loader.git.from_disk.GitLoaderFromArchive:loader.py:330 Load origin 'https://github.com/wcoder/highlightjs-line-numbers.js' with type 'git'
INFO swh.loader.git.from_disk:from_disk.py:433 Project https://github.com/wcoder/highlightjs-line-numbers.js - Uncompressing archive highlightjs-line-numbers.js_visit2.zip at /tmp/tmp.l6g4nvlt.swh.loader.git/highlightjs-line-numbers.js_visit2
INFO swh.loader.git.from_disk:from_disk.py:448 Project https://github.com/wcoder/highlightjs-line-numbers.js - Done injecting /tmp/tmp.l6g4nvlt.swh.loader.git/highlightjs-line-numbers.js_visit2
INFO swh.loader.git.from_disk.GitLoaderFromArchive:loader.py:330 Load origin 'repo_with_submodules' with type 'git'
INFO swh.loader.git.from_disk:from_disk.py:433 Project repo_with_submodules - Uncompressing archive repo_with_submodules.tgz at /tmp/tmp.w7dwwecu.swh.loader.git/repo_with_submodules
INFO swh.loader.git.from_disk:from_disk.py:448 Project repo_with_submodules - Done injecting /tmp/tmp.w7dwwecu.swh.loader.git/repo_with_submodules
DEBUG swh.indexer:indexer.py:161 <swh.indexer.mimetype.MimetypeIndexer object at 0x7fd6ba290eb0>: config={'tools': {'configuration': {'debian-package': 'python3-magic', 'type': 'library'}, 'name': 'file', 'version': '1:5.30-1+deb9u1'}, 'indexer_storage': {'args': {}, 'cls': 'memory'}, 'storage': {'cls': 'memory'}, 'objstorage': {'args': {}, 'cls': 'memory'}}
DEBUG swh.indexer:indexer.py:161 <swh.indexer.fossology_license.FossologyLicenseIndexer object at 0x7fd6a2c559d0>: config={'tools': {'configuration': {'command_line': 'nomossa <filepath>'}, 'name': 'nomos', 'version': '3.1.0rc2-31-ga2cbb8c'}, 'storage': {'cls': 'memory'}, 'objstorage': {'args': {}, 'cls': 'memory'}, 'indexer_storage': {'args': {}, 'cls': 'memory'}, 'workdir': '/tmp/swh/indexer.fossology.license'}
DEBUG swh.indexer:indexer.py:161 <swh.indexer.ctags.CtagsIndexer object at 0x7fd6a2b2cd60>: config={'languages': {'c': 'c'}, 'tools': {'configuration': {'command_line': 'ctags --fields=+lnz --sort=no --links=no --output-format=json <filepath>'}, 'name': 'universal-ctags', 'version': '~git7859817b'}, 'storage': {'cls': 'memory'}, 'objstorage': {'args': {}, 'cls': 'memory'}, 'indexer_storage': {'args': {}, 'cls': 'memory'}, 'workdir': '/tmp/swh/indexer.ctags'}
----------------------------------------------------------------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------------------------------------------------------------
DEBUG urllib3.connectionpool:connectionpool.py:227 Starting new HTTP connection (1): saatchi.internal.softwareheritage.org:5008
DEBUG urllib3.util.retry:retry.py:576 Incremented Retry for (url='/task_type/get_all'): Retry(total=2, connect=None, read=None, redirect=None, status=None)
WARNING urllib3.connectionpool:connectionpool.py:780 Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd6a2ed53a0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /task_type/get_all
DEBUG urllib3.connectionpool:connectionpool.py:227 Starting new HTTP connection (2): saatchi.internal.softwareheritage.org:5008
DEBUG urllib3.util.retry:retry.py:576 Incremented Retry for (url='/task_type/get_all'): Retry(total=1, connect=None, read=None, redirect=None, status=None)
WARNING urllib3.connectionpool:connectionpool.py:780 Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd6a2f87d30>: Failed to establish a new connection: [Errno -2] Name or service not known')': /task_type/get_all
DEBUG urllib3.connectionpool:connectionpool.py:227 Starting new HTTP connection (3): saatchi.internal.softwareheritage.org:5008
DEBUG urllib3.util.retry:retry.py:576 Incremented Retry for (url='/task_type/get_all'): Retry(total=0, connect=None, read=None, redirect=None, status=None)
WARNING urllib3.connectionpool:connectionpool.py:780 Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd6a2f871f0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /task_type/get_all
DEBUG urllib3.connectionpool:connectionpool.py:227 Starting new HTTP connection (4): saatchi.internal.softwareheritage.org:5008
-------------------------------------------------------------------------------------------------------------------------------- swh-web custom section ---------------------------------------------------------------------------------------------------------------------------------
FAILED swh/web/tests/api/views/test_directory.py::test_api_directory: Use "pytest --swh-web-random-seed=1634218902 swh/web/tests/api/views/test_directory.py::test_api_directory" to reproduce that test failure with same inputs
=================================================================================================================================== warnings summary ====================================================================================================================================
swh/web/tests/api/views/test_directory.py::test_api_directory
swh/web/tests/api/views/test_directory.py::test_api_directory
swh/web/tests/api/views/test_directory.py::test_api_directory
/home/anlambert/swh/swh-environment/swh-objstorage/swh/objstorage/factory.py:80: DeprecationWarning: Explicit "args" key is deprecated for objstorage initialization, use class arguments keys directly instead.
warnings.warn(
swh/web/tests/api/views/test_directory.py::test_api_directory
swh/web/tests/api/views/test_directory.py::test_api_directory
swh/web/tests/api/views/test_directory.py::test_api_directory
/home/anlambert/swh/swh-environment/swh-indexer/swh/indexer/storage/__init__.py:68: DeprecationWarning: Explicit "args" key is deprecated, use keys directly instead.
warnings.warn(
-- Docs: https://docs.pytest.org/en/stable/warnings.html
-------------------------------------------------------------------------------------------------------------------------------- swh-web custom section ---------------------------------------------------------------------------------------------------------------------------------
FAILED swh/web/tests/api/views/test_directory.py::test_api_directory: Use "pytest --swh-web-random-seed=1634218902 swh/web/tests/api/views/test_directory.py::test_api_directory" to reproduce that test failure with same inputs
================================================================================================================================ short test summary info ================================================================================================================================
FAILED swh/web/tests/api/views/test_directory.py::test_api_directory - assert [{'checksums': {'sha1': '1c34570332c08d4a0ff89ab1d1b7ed5924d7114f', 'sha1_git': '420ebab5ea719a78f9c3059087885fab3eca7...82b58d520ef8a6369'}, 'dir_id': 'cd19126d815470b28919d64b2a8e6a3e37f900dd', 'len...
============================================================================================================================= 1 failed, 6 warnings in 2.75s =============================================================================================================================
```