buildkite / test-collector-python

Python adapter for Buildkite Test Analytics
https://buildkite.com/test-analytics
MIT License
6 stars 5 forks source link

Check we're not in an xdist worker before submitting payload #29

Closed joshprice closed 1 month ago

joshprice commented 2 months ago

The way xdist works is somewhat surprising:

This checks that we're in the controller process (eg the existence of "workerinput" implies an xdist worker thread), and only submits the results payload if we're in the controller or master process.

The JUnit test reporter has a range of other strategies to deal with xdist but this particular check inspired this fix https://github.com/pytest-dev/pytest/blob/ac4189875562a6ce5b502c3dd87156c0367cf8f1/src/_pytest/junitxml.py#L429

joshprice commented 2 months ago

Thanks @pda, I've verified using this repo https://github.com/team-alembic/pytest-bk-test-analytics which was a fork of https://github.com/adimoldovan/pytest-bk-test-analytics it'd be great if @adimoldovan can verify the fix on his repo.

I'd like to ensure we've got the most robust possible fix here with tests as well before we publish a new version.

Fixed no duplicates on the xdist-duplicates branch:

Screenshot 2024-07-04 at 3 07 13 PM

Duplicates on current version:

Screenshot 2024-07-04 at 3 09 59 PM
adimoldovan commented 2 months ago

I verified this, it looks good. Thanks for the fix @joshprice

joshprice commented 1 month ago

@pda this should be good for a patch release