简体   繁体   中英

How does Gradle's java plugin run JUnit tests in parallel: one queue per fork or a single queue and multiple forks?

I have been recently trying Gradle, I didn't have any prior experience with it, and so far I have been able to do the things I wanted to and am satisfied with the results. However, in my case I have to run Selenium tests with JUnit and some of them are disproportionately larger than others (ie: 25min vs 4min).

When using the maxParallelForks option, sometimes it takes longer than I would expect, as the tests seem to be assigned beforehand to the forks and sometimes I end up with iddle forks, while one of them is stuck with a long test, and when it finishes other shorter tests run after it (which could have run in any of the other available forks).

TL;DR: When running tests in parallel, Gradle seems to assign tests as if there were multiple queues (one per fork) and I would like it to be like a single queue where the forks take the next test in the queue.

As an off-topic example, my situation is like being stuck in a queue at the supermarket, when the ones next to you are empty, but you can't change.

it's the latter. gradle uses one queue and distributes each entry clockwise to the running processes. Say you have 4 tests:

  • Test1 taking 10s
  • Test2 taking 1s
  • Test3 taking 10s
  • Test4 taking 1s

and using maxParallelForks = 2 the overall test task execution would be around 20s. I guess we need to discuss if this can be improved by getting notified about "free" processes to assign Test3 directly to test worker process 2 after Test2 comes back after 1s.

As of July 2021, Your question (and my experience) matches the issue described in this issue which "has been automatically closed due to inactivity".

The issue is not resolved, and yes, the system assigns tasks early and does not rebalance to use idle workers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM