Page MenuHomeSoftware Heritage
Paste P356

scheduler update test issues in debian build ~> reason is hypothesis version <= 3.6.1 do not follow spec
ActivePublic

Authored by ardumont on Feb 11 2019, 11:15 AM.
============================= test session starts ==============================
platform linux -- Python 3.5.3, pytest-3.0.6, py-1.4.32, pluggy-0.4.0
rootdir: /<<PKGBUILDDIR>>, inifile:
plugins: postgresql-1.3.4, hypothesis-3.6.1, celery-4.2.1
collected 42 items
swh/scheduler/tests/test_celery_tasks.py ..
swh/scheduler/tests/test_utils.py ...
swh/scheduler/tests/updater/test_backend.py F
swh/scheduler/tests/updater/test_consumer.py ...
swh/scheduler/tests/updater/test_events.py ...
swh/scheduler/tests/updater/test_ghtorrent.py ......
=================================== FAILURES ===================================
_______________________________ test_cache_read ________________________________
swh_scheduler_updater = <swh.scheduler.updater.backend.SchedulerUpdaterBackend object at 0x7fb35fcae860>
@given(urls=sets(
> from_regex(
r'^https://somewhere[.]org/[a-z0-9]{5,7}/[a-z0-9]{3,10}$'),
min_size=10, max_size=15))
def test_cache_read(urls, swh_scheduler_updater):
swh/scheduler/tests/updater/test_backend.py:15:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/hypothesis/core.py:524: in wrapped_test
print_example=True, is_final=True
/usr/lib/python3/dist-packages/hypothesis/executors.py:58: in default_new_style_executor
return function(data)
/usr/lib/python3/dist-packages/hypothesis/core.py:111: in run
return test(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
urls = {'', '0', '0\r0', '1', '2', '3', ...}
swh_scheduler_updater = <swh.scheduler.updater.backend.SchedulerUpdaterBackend object at 0x7fb35fcae860>
@given(urls=sets(
from_regex(
r'^https://somewhere[.]org/[a-z0-9]{5,7}/[a-z0-9]{3,10}$'),
min_size=10, max_size=15))
def test_cache_read(urls, swh_scheduler_updater):
# beware that the fixture is only called once for all the tests
# generated by hypothesis, so the db is not cleared between calls.
# see the end of
# https://hypothesis.works/articles/hypothesis-pytest-fixtures/
def gen_events(urls):
for url in urls:
yield SWHEvent({
'url': url,
'type': 'create',
'origin_type': 'git',
})
known_urls = set(e['url'] for e in
swh_scheduler_updater.cache_read(limit=1000000))
swh_scheduler_updater.cache_put(gen_events(urls))
new_urls = {u.strip() for u in urls} - known_urls
all_urls = set(e['url'] for e in
swh_scheduler_updater.cache_read(limit=1000000))
> assert (all_urls - known_urls) == new_urls
E assert set() == {'0\r0'}
E Extra items in the right set:
E '0\r0'
E Use -v to get the full diff
swh/scheduler/tests/updater/test_backend.py:36: AssertionError
---------------------------------- Hypothesis ----------------------------------
Falsifying example: test_cache_read(urls={'', '0', '0\r0', '1', '2', '3', '4', '5', '6', '7'}, swh_scheduler_updater=<swh.scheduler.updater.backend.SchedulerUpdaterBackend at 0x7fb35fcae860>)

Event Timeline

Debian build output.

This draws hypothesis: python3-hypothesis_3.6.1-1

This output does not follow the url's specification (P356$40)

That's it, reproduced with tox and requirements-test.txt (hypothesis <= 3.6.1).

GLOB sdist-make: /home/tony/work/inria/repo/swh/swh-environment/swh-scheduler/setup.py
flake8 recreate: /home/tony/work/inria/repo/swh/swh-environment/swh-scheduler/.tox/flake8
flake8 installdeps: flake8
WARNING: Discarding $PYTHONPATH from environment, to override specify PYTHONPATH in 'passenv' in your configuration.
flake8 installed: entrypoints==0.3,flake8==3.7.5,mccabe==0.6.1,pycodestyle==2.5.0,pyflakes==2.1.0,swh.scheduler==0.0.41.post2
flake8 run-test-pre: PYTHONHASHSEED='2097986683'
flake8 runtests: commands[0] | /home/tony/work/inria/repo/swh/swh-environment/swh-scheduler/.tox/flake8/bin/python -m flake8
py3 recreate: /home/tony/work/inria/repo/swh/swh-environment/swh-scheduler/.tox/py3
py3 installdeps: .[testing], pytest-cov, pifpaf
py3 inst: /home/tony/work/inria/repo/swh/swh-environment/swh-scheduler/.tox/.tmp/package/1/swh.scheduler-0.0.41.post2.zip
py3 installed: aiohttp==3.5.4,amqp==2.4.1,arrow==0.13.0,async-timeout==3.0.1,atomicwrites==1.3.0,attrs==18.2.0,billiard==3.5.0.5,celery==4.2.1,certifi==2018.11.29,cffi==1.11.5,chardet==3.0.4,Click==7.0,coverage==4.5.2,daiquiri==1.5.0,decorator==4.3.2,elasticsearch==6.3.1,extras==1.0.0,fixtures==3.0.0,Flask==1.0.2,hypothesis==3.6.1,idna==2.8,itsdangerous==1.1.0,Jinja2==2.10,kombu==4.3.0,linecache2==1.0.0,MarkupSafe==1.1.0,mirakuru==1.1.0,more-itertools==5.0.0,msgpack-python==0.5.6,multidict==4.5.2,pbr==5.1.2,pifpaf==2.2.2,pluggy==0.8.1,port-for==0.4,psutil==5.5.0,psycopg2==2.7.7,py==1.7.0,pycparser==2.19,pytest==3.10.1,pytest-cov==2.6.1,pytest-postgresql==1.3.4,python-dateutil==2.8.0,python-mimeparse==1.6.0,pytz==2018.9,PyYAML==3.13,requests==2.21.0,six==1.12.0,swh.core==0.0.53,swh.scheduler==0.0.41.post2,systemd-python==234,testtools==2.3.0,traceback2==1.4.0,unittest2==1.1.0,urllib3==1.24.1,vcversioner==2.16.0.0,vine==1.2.0,Werkzeug==0.14.1,xattr==0.9.6,yarl==1.3.0
py3 run-test-pre: PYTHONHASHSEED='2097986683'
py3 runtests: commands[0] | pifpaf run postgresql -- pytest --cov=swh --cov-branch
/home/tony/work/inria/repo/swh/swh-environment/swh-scheduler/.tox/py3/lib/python3.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
  """)
===================================================================================== test session starts =====================================================================================
platform linux -- Python 3.7.2+, pytest-3.10.1, py-1.7.0, pluggy-0.8.1
rootdir: /home/tony/work/inria/repo/swh/swh-environment/swh-scheduler, inifile: pytest.ini
plugins: postgresql-1.3.4, cov-2.6.1, hypothesis-3.6.1, celery-4.2.1
collected 42 items

swh/scheduler/tests/test_api_client.py ..........                                                                                                                                       [ 23%]
swh/scheduler/tests/test_celery_tasks.py .....                                                                                                                                          [ 35%]
swh/scheduler/tests/test_scheduler.py .........                                                                                                                                         [ 57%]
swh/scheduler/tests/test_utils.py ...                                                                                                                                                   [ 64%]
swh/scheduler/tests/updater/test_backend.py F                                                                                                                                           [ 66%]
swh/scheduler/tests/updater/test_consumer.py ...                                                                                                                                        [ 73%]
swh/scheduler/tests/updater/test_events.py ...                                                                                                                                          [ 80%]
swh/scheduler/tests/updater/test_ghtorrent.py ......                                                                                                                                    [ 95%]
swh/scheduler/tests/updater/test_writer.py ..                                                                                                                                           [100%]

========================================================================================== FAILURES ===========================================================================================
_______________________________________________________________________________________ test_cache_read _______________________________________________________________________________________

swh_scheduler_updater = <swh.scheduler.updater.backend.SchedulerUpdaterBackend object at 0x7f54368bd0b8>

    @given(urls=sets(
>       from_regex(
            r'^https://somewhere[.]org/[a-z0-9]{5,7}/[a-z0-9]{3,10}$'),
        min_size=10, max_size=15))
    def test_cache_read(urls, swh_scheduler_updater):

swh/scheduler/tests/updater/test_backend.py:15:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/hypothesis/core.py:524: in wrapped_test
    print_example=True, is_final=True
.tox/py3/lib/python3.7/site-packages/hypothesis/executors.py:58: in default_new_style_executor
    return function(data)
.tox/py3/lib/python3.7/site-packages/hypothesis/core.py:111: in run
    return test(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

urls = {'', '0', '0\r0', '1', '2', '3', ...}, swh_scheduler_updater = <swh.scheduler.updater.backend.SchedulerUpdaterBackend object at 0x7f54368bd0b8>

    @given(urls=sets(
        from_regex(
            r'^https://somewhere[.]org/[a-z0-9]{5,7}/[a-z0-9]{3,10}$'),
        min_size=10, max_size=15))
    def test_cache_read(urls, swh_scheduler_updater):
        # beware that the fixture is only called once for all the tests
        # generated by hypothesis, so the db is not cleared between calls.
        # see the end of
        #   https://hypothesis.works/articles/hypothesis-pytest-fixtures/
        def gen_events(urls):
            for url in urls:
                yield SWHEvent({
                    'url': url,
                    'type': 'create',
                    'origin_type': 'git',
                })
        known_urls = set(e['url'] for e in
                         swh_scheduler_updater.cache_read(limit=1000000))
        swh_scheduler_updater.cache_put(gen_events(urls))
        new_urls = {u.strip() for u in urls} - known_urls
        all_urls = set(e['url'] for e in
                       swh_scheduler_updater.cache_read(limit=1000000))
>       assert (all_urls - known_urls) == new_urls
E       AssertionError: assert set() == {'0\r0'}
E         Extra items in the right set:
E         '0\r0'
E         Use -v to get the full diff

swh/scheduler/tests/updater/test_backend.py:36: AssertionError
----------------------------------------------------------------------------------------- Hypothesis ------------------------------------------------------------------------------------------
Falsifying example: test_cache_read(urls={'', '0', '0\r0', '1', '2', '3', '4', 'İ', 'ı', 'Ȱ', '̰', 'а', '𐠰', '𐤰', '𠠰'}, swh_scheduler_updater=<swh.scheduler.updater.backend.SchedulerUpdaterBackend at 0x7f54368bd0b8>)

----------- coverage: platform linux, python 3.7.2-final-0 -----------
Name                                            Stmts   Miss Branch BrPart  Cover
---------------------------------------------------------------------------------
swh/__init__.py                                     1      0      0      0   100%
swh/scheduler/__init__.py                          14      2      6      2    80%
swh/scheduler/api/__init__.py                       0      0      0      0   100%
swh/scheduler/api/client.py                        42      6      0      0    86%
swh/scheduler/api/server.py                       106     35      8      1    63%
swh/scheduler/backend.py                          186     60     62      8    60%
swh/scheduler/backend_es.py                        50     50     22      0     0%
swh/scheduler/celery_backend/__init__.py            0      0      0      0   100%
swh/scheduler/celery_backend/config.py            111     34     42     10    59%
swh/scheduler/celery_backend/listener.py          110    110     22      0     0%
swh/scheduler/celery_backend/runner.py             55     13     18      3    75%
swh/scheduler/cli.py                              317    317    101      0     0%
swh/scheduler/task.py                              40      9      6      2    76%
swh/scheduler/tests/__init__.py                     3      0      0      0   100%
swh/scheduler/tests/conftest.py                    35      1      7      1    95%
swh/scheduler/tests/tasks.py                       19      0      6      0   100%
swh/scheduler/tests/test_api_client.py             19      0      4      0   100%
swh/scheduler/tests/test_celery_tasks.py           57      1     10      2    96%
swh/scheduler/tests/test_scheduler.py             269      0     82      2    99%
swh/scheduler/tests/test_utils.py                  23      0      0      0   100%
swh/scheduler/tests/updater/__init__.py            22      0      4      0   100%
swh/scheduler/tests/updater/conftest.py            18      0      2      0   100%
swh/scheduler/tests/updater/test_backend.py        13      0      8      0   100%
swh/scheduler/tests/updater/test_consumer.py      110      2      6      0    98%
swh/scheduler/tests/updater/test_events.py         21      1      2      1    91%
swh/scheduler/tests/updater/test_ghtorrent.py      75      0      4      0   100%
swh/scheduler/tests/updater/test_writer.py         63      0     12      0   100%
swh/scheduler/updater/__init__.py                   0      0      0      0   100%
swh/scheduler/updater/backend.py                   59      3     18      4    91%
swh/scheduler/updater/consumer.py                  64     12     18      2    80%
swh/scheduler/updater/events.py                    15      1      0      0    93%
swh/scheduler/updater/ghtorrent/__init__.py        46      3     10      3    89%
swh/scheduler/updater/ghtorrent/cli.py              8      8      2      0     0%
swh/scheduler/updater/ghtorrent/fake.py            32     32      6      0     0%
swh/scheduler/updater/writer.py                    43      4     14      2    89%
swh/scheduler/utils.py                             17      4      6      0    74%
---------------------------------------------------------------------------------
TOTAL                                            2063    708    508     43    62%

====================================================================================== warnings summary =======================================================================================
.tox/py3/lib/python3.7/site-packages/celery/canvas.py:12
  /home/tony/work/inria/repo/swh/swh-environment/swh-scheduler/.tox/py3/lib/python3.7/site-packages/celery/canvas.py:12: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    from collections import MutableSequence, deque

.tox/py3/lib/python3.7/site-packages/hypothesis/strategies.py:170
  /home/tony/work/inria/repo/swh/swh-environment/swh-scheduler/.tox/py3/lib/python3.7/site-packages/hypothesis/strategies.py:170: DeprecationWarning: invalid escape sequence \*
    """

.tox/py3/lib/python3.7/site-packages/werkzeug/datastructures.py:16
  /home/tony/work/inria/repo/swh/swh-environment/swh-scheduler/.tox/py3/lib/python3.7/site-packages/werkzeug/datastructures.py:16: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    from collections import Container, Iterable, MutableSet
  /home/tony/work/inria/repo/swh/swh-environment/swh-scheduler/.tox/py3/lib/python3.7/site-packages/werkzeug/datastructures.py:16: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    from collections import Container, Iterable, MutableSet

-- Docs: https://docs.pytest.org/en/latest/warnings.html
====================================================================== 1 failed, 41 passed, 4 warnings in 151.05 seconds ======================================================================
WARNING [pifpaf.drivers] `psutil.Popen(pid=24357, status='terminated')` is already gone, sending SIGKILL to its process group
WARNING [pifpaf.drivers] `psutil.Popen(pid=24332, status='terminated')` is already gone, sending SIGKILL to its process group
WARNING [pifpaf.drivers] `psutil.Popen(pid=24327, status='terminated')` is already gone, sending SIGKILL to its process group
ERROR: InvocationError for command '/home/tony/work/inria/repo/swh/swh-environment/swh-scheduler/.tox/py3/bin/pifpaf run postgresql -- pytest --cov=swh --cov-branch' (exited with code 1)
___________________________________________________________________________________________ summary ___________________________________________________________________________________________
  flake8: commands succeeded
ERROR:   py3: commands failed
ardumont changed the title of this paste from scheduler update issues in debian build to scheduler update test issues in debian build ~> reason is hypothesis version <= 3.6.1 do not follow spec.Feb 11 2019, 12:35 PM