smarie / python-pytest-harvest

Store data created during your `pytest` tests execution, and retrieve it at the end of the session, e.g. for applicative benchmarking purposes.
https://smarie.github.io/python-pytest-harvest/
BSD 3-Clause "New" or "Revised" License
61 stars 8 forks source link

pytest_harvest_xdist_worker_dump not getting called #48

Closed rhshadrach closed 3 years ago

rhshadrach commented 3 years ago

We just upgraded packages and we're finding that pytest_harvest_xdist_worker_dump is not getting called.

Previous versions:

pytest                    6.0.1            py37hc8dfbb8_0    conda-forge
pytest-forked             1.2.0              pyh9f0ad1d_0    conda-forge
pytest-harvest            1.10.1                   pypi_0    pypi
pytest-xdist              2.0.0                      py_0    conda-forge

New versions:

pytest                    6.2.2            py37h89c1867_0    conda-forge
pytest-forked             1.3.0              pyhd3deb0d_0    conda-forge
pytest-harvest            1.10.1                   pypi_0    pypi
pytest-xdist              2.2.1              pyhd8ed1ab_0    conda-forge

Instead, to get pytest-harvest to work, we have to call our implementation of pytest_harvest_xdist_worker_dump from pytest_sessionfinish, which is the same implementation as here:

https://smarie.github.io/python-pytest-harvest/#pytest-x-dist

except that we do not dump session_items (causes a pickling error for us, and we don't need it). We use the following code in pytest_sessionfinish to do so.

if not is_main_process(session):
    worker_id = get_xdist_worker_id(session)
    fixture_store = get_fixture_store(session)
    pytest_harvest_xdist_worker_dump(worker_id, {}, fixture_store)

Is this expected to be necessary? Previously, I thought pytest-harvest was automatically detecting and calling our implementation of pytest_harvest_xdist_worker_dump.

smarie commented 3 years ago

THanks @rhshadrach for the feedback ! Surprisingly, I'm receiving this notification just now :( I'll have to investigate, maybe something changed in pytest-xdist ?

smarie commented 3 years ago

I confirm that I can now reproduce the issue

smarie commented 3 years ago

The origin is simple: my old pull request was accepted https://github.com/pytest-dev/pytest-xdist/pull/505 but I do not use it :)

smarie commented 3 years ago

Actually the cause was not this. Rather, funcargnames seems to have disappeared from pytest item api - which was causing one of my hook to fail silently

https://github.com/smarie/python-pytest-harvest/commit/c499ff944144c393737c006ab692603863679b84#diff-93998b7e30b1deb577455fb069b07b7901f08a23277e8b84fb7247dd71823d72R587

smarie commented 3 years ago

Fixed in 1.10.3, let me know @rhshadrach !

rhshadrach commented 3 years ago

Thanks @smarie! Confirmed it's now working in 1.10.3