[pytest-dev] pytest-xdist-1.11: restarting crash nodes, fixture cache fix

holger krekel holger at merlinux.eu
Thu Sep 18 21:08:46 CEST 2014


On Thu, Sep 18, 2014 at 21:00 +0200, Anatoly Bubenkov wrote:
> On 18 September 2014 20:56, holger krekel <holger at merlinux.eu> wrote:
> 
> > On Thu, Sep 18, 2014 at 20:51 +0200, Anatoly Bubenkov wrote:
> > > hmm, but that grouping is not important for session scoped fixtures,
> > right?
> > > i mean, what's the sense of tearing down the session-scoped fixture, even
> > > if most likely it will be not used by any test, earlier than the end of
> > the
> > > session?
> >
> > Parametrized session-scoped fixtures, for example, may depend on being torn
> > down, not all be active at the same time.  In any case, it's part of a
> > general scheme to teardown fixtures as early as possible, not as late as
> > possible.  We can discuss/play with that and introduce an option which
> > prohibits it, possibly.
> >
> ok i see now a bit more, so, the solution, proposed in an article is still
> actual, because there's no strict guarantee
> but the reasoning was described in a wrong way - i'll fix that, thanks!

For others, the actual article is here:
http://developer.paylogic.com/articles/pytest-xdist-and-session-scoped-fixtures.html

I'd recommend to check if pytest-xdist-1.11 doesn't already solve the problem.

> > best,
> > holger
> >
> > P.S: i bet you are using gmail, right? (because of your top-level
> > posting style -- i often prefer inlined comments because it allows to
> > get statements in context).
> >
> i liked that way earlier also, not anymore :)
> but in pytest-dev at least i'll try to keep this style, np

Well, it allows to have discussions on more than one point more easily.
E.g. in this mail we are discussing two things and it's easy for
others to join the thread with my mail here and see what is being
discussed without having to reread the whole thread.

cheers,
holger



> 
> >
> > > it should be ok for that fixture to live till the end of the session, and
> > > then any randomization should not matter
> > > i agree that for modules and classes grouping is nice, though
> > >
> > >
> > > On 18 September 2014 20:46, holger krekel <holger at merlinux.eu> wrote:
> > >
> > > > On Thu, Sep 18, 2014 at 20:35 +0200, Anatoly Bubenkov wrote:
> > > > > yes per testing subprocess, as i've already asked in the comments
> > section
> > > > > on the paylogic developer portal, im waiting for your confirmation
> > that's
> > > > > NOT by design that we were getting multiple test sessions per test
> > > > > subprocess
> > > > > so i'll need to fix the article then
> > > >
> > > > yes, it's not by design.  It was more an implementation incident.
> > > >
> > > > > BTW: now im reading the code again, it looks like even with
> > randomization
> > > > > plugin it should not matter?
> > > >
> > > > pytest relies on the following property of test collections: if a test
> > > > at index I1 uses a session-scoped fixture X and at an index I2>I1 X is
> > not
> > > > used than for any I3>I2 X will not be used, either.  If this is not
> > > > true for any given testing process then the fixture will be torn down
> > > > and setup again (at I3).  pytest groups tests so in general this
> > property
> > > > is true (see here:
> > > >
> > > >
> > https://pytest.org/latest/fixture.html#automatic-grouping-of-tests-by-fixture-instances
> > > > for how it groups).
> > > >
> > > > If you have multiple parametrized session-scoped fixtures (not very
> > common)
> > > > or item randomization the above property is likely not true but that
> > > > already
> > > > is true then for single-process execution.
> > > >
> > > > best,
> > > > holger
> > > >
> > > > > On 18 September 2014 20:31, holger krekel <holger at merlinux.eu>
> > wrote:
> > > > >
> > > > > > On Thu, Sep 18, 2014 at 20:24 +0200, Anatoly Bubenkov wrote:
> > > > > > > so, this is again guaranteed that there will be only one session
> > per
> > > > test
> > > > > > > run on any test slave?
> > > > > >
> > > > > > there is always one session object only but i think you are asking
> > if a
> > > > > > session-scoped fixture will only be instantiated once per testing
> > > > > > subprocess, right?  In general this should be the case if i am not
> > > > missing
> > > > > > something (when you use a test randomization plugin, then it's
> > probably
> > > > > > not the case).
> > > > > >
> > > > > > best,
> > > > > > holger
> > > > > >
> > > > > > > On 18 September 2014 20:23, Anatoly Bubenkov <
> > bubenkoff at gmail.com>
> > > > > > wrote:
> > > > > > >
> > > > > > > > Great!
> > > > > > > > thanks a lot everyone involved
> > > > > > > >
> > > > > > > > On 18 September 2014 20:21, holger krekel <holger at merlinux.eu>
> > > > wrote:
> > > > > > > >
> > > > > > > >>
> > > > > > > >> I just released pytest-xdist-1.11, the distributed testing
> > plugin
> > > > for
> > > > > > > >> pytest.
> > > > > > > >> It introduces automatic restarting of crashed nodes, courtesy
> > of a
> > > > > > > >> complete PR from Floris Bruynooghe.  This also works well
> > together
> > > > > > with
> > > > > > > >> pytest-timeout by the same author: When one or more test
> > functions
> > > > > > hang
> > > > > > > >> or crash, the overall test run will still complete and report
> > > > about
> > > > > > the
> > > > > > > >> incidents.  See the changelog below for more changes and the
> > pypi
> > > > > > > >> project page for what pytest-xdist offers in general:
> > > > > > > >>
> > > > > > > >>     https://pypi.python.org/pypi/pytest-xdist/
> > > > > > > >>
> > > > > > > >> Thanks also to an undisclosed company who partly funded the
> > work
> > > > > > > >> and to Andreas Pelme for contributing analysis of a fixture
> > > > caching
> > > > > > > >> failure including a test.
> > > > > > > >>
> > > > > > > >> best,
> > > > > > > >> Holger Krekel
> > > > > > > >>
> > > > > > > >>
> > > > > > > >> 1.11
> > > > > > > >> -------------------------
> > > > > > > >>
> > > > > > > >> - fix pytest/xdist issue485 (also depends on py-1.4.22):
> > > > > > > >>   attach stdout/stderr on --boxed processes that die.
> > > > > > > >>
> > > > > > > >> - fix pytest/xdist issue503: make sure that a node has usually
> > > > > > > >>   two items to execute to avoid scoped fixtures to be torn
> > down
> > > > > > > >>   pre-maturely (fixture teardown/setup is "nextitem"
> > sensitive).
> > > > > > > >>   Thanks to Andreas Pelme for bug analysis and failing test.
> > > > > > > >>
> > > > > > > >> - restart crashed nodes by internally refactoring setup
> > handling
> > > > > > > >>   of nodes.  Also includes better code documentation.
> > > > > > > >>   Many thanks to Floris Bruynooghe for the complete PR.
> > > > > > > >>
> > > > > > > >> _______________________________________________
> > > > > > > >> Pytest-dev mailing list
> > > > > > > >> Pytest-dev at python.org
> > > > > > > >> https://mail.python.org/mailman/listinfo/pytest-dev
> > > > > > > >>
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Anatoly Bubenkov
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Anatoly Bubenkov
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Anatoly Bubenkov
> > > >
> > >
> > >
> > >
> > > --
> > > Anatoly Bubenkov
> >
> 
> 
> 
> -- 
> Anatoly Bubenkov


More information about the Pytest-dev mailing list