[TIP] REG: pytest-xdist

arun kali raja arunsep886 at gmail.com
Sat Mar 3 02:04:07 PST 2018

Hi ,

I am trying to use pytest for a SOAK testing environment. So essentially i
have a deployment on which i am going to run certain monitoring tests for a
given amount of duration.

I thought xdist can be used to run the monitoring tests on each of the
devices in my deployment in parallel. I went through the documentation and
code of xdist and also did a little hands on. I have few questions though:

1. Each of the worker is itself a pytest run.. In my case i will have to do
certain device configuration at the beginning of the test run.. that will
be common for all the tests. I see that fixtures are executed inside the
worker thread only. so i cant use fixtures to do such configuration/revert
operations. I was thinking if i can use the hooks that i have defined in
the conftest.py in my testpath.. that also is executed only within worker
scope.. I understand that we cant make fixtures executed within the
master's scope.. But can the hooks made to be executed within the master's
scope to do such configurations on devices??

2. I have an internal db where i log all the test run information,
logs/results etc.. now these are all logged against a testrun ID which is
internally generated. I had all these in the conftest.py for my functional
environment. But here again since workers are executing the conftest.py
files each of them are considered a separate testrun, which is  not
desirable for me. I saw that execnet channel is used to send command
strings between master and slaves.. But i dont see a way to extend it
unless i modify the xdist plugin itself... How  can this be achieved.

3. I tried xdist with some demo cases, but when i run the  whole test file
collection mismatch is happening. Logs below:

gw0 [20] / gw1 [20]
scheduling tests via LoadScheduling

ERROR collecting gw1
Different tests were collected between gw0 and gw1. The difference is:
--- gw0

+++ gw1

@@ -1,20 +1,20 @@


Results (8.79s):

what could be the reason for this?

Arun kaliraja.B
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20180303/fe951778/attachment.html>

More information about the testing-in-python mailing list