pytest-dev / pytest-dev/pytest-xdist

Question about DSession:worker_collectionfinish

Open
#431 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.9k
Forks
287
Avg merge
9h 30m
Merged PRs (30d)
2

Description

I am having a small problem in DSession:worker_collectionfinish.

I am using pytest-xdist to execute distributed tests, with the small difference that my test methods depend on each other across test clients. For example:

class MyTest(SynchronisedFixture):
    @pytest.mark.client(name="gw0")
    def test_on_gw0(self):
        execute test steps on gw0 that communicates with gw1...

    @pytest.mark.client(name="gw1")
    def test_on_gw1(self):
        execute different test steps on gw1 that communicates with gw0...

Sometimes I execute tests on 2 nodes, sometimes more - up to 4 currently. This works quite nicely. To accommodate this I spawn 4 test nodes (--tx specifications) every time.

My problem is when I collect the the test results. DSession:worker_collectionfinish sets the self._session.testscollected to the length if ids from the "last" node - in my case gw3, but gw3 does not always execute any tests if I specify "-m" causing pytest to return EXIT_NOTESTSCOLLECTED.

I could just choose to ignore EXIT_NOTESTSCOLLECTED and handle it as a success, but I was wondering if there was another way to handle this situation?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at DSession:worker_collectionfinish and reproduce the issue with multiple --tx specifications and a -m filter that leaves the last node without tests. Trace how collection counts and EXIT_NOTESTSCOLLECTED are handled across workers. Done means the multi-node collection behavior is defined and the reported scenario no longer produces an incorrect result.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
distributed-systems, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.