1

I have 10 test files:

sc0 - run 4 min

sc1 - run 6 min

sc2 - run 6 min

sc3 - run 25 min

sc4 - run 25 min

sc5 - run 5 min

sc6 - run 5 min

sc7 - run 5 min

sc8 - run 6 min

sc9 - run 33 min

I use the below command in order to run test in parallel ( each file should run sequentially)

pytest -n 3 --dist loadfile --junit-xml=pytest-junit.xml -o junit_family=xunit2

I see that workers get test to run based on file name order and the total execution time is 1 h

the distribution are:

worker0 - sc0 (4m), sc3 (25m) and sc9 (33m) = 1h

worker1 - sc1 (6m), sc4 (25m) = 31m

worker2 - sc2 (6m), sc5 (5m), sc6 (5m), sc7 (5m), sc8 (6m) = 27m

but if I will have ability to control the worker split decision which file to choose, I can save 20m of test execution

worker0 - sc3 (25m), sc0 (4m), sc2 (6m), sc7 (5m) = 40m

worker1 - sc4 (25m), sc1 (6m), sc5 (5m), sc8 (6m) = 42m

worker2 - sc9 (33m), sc6 (5m) = 38m

How can I control the order of test file distribution for pytest-xdist plugin? ( I don't want to rename files names)

Shurik
  • 562
  • 1
  • 7
  • 19

0 Answers0