-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run tests with Gradle test runner instead of randomizedtesting.junit4-ant #31496
Comments
Pinging @elastic/es-core-infra |
Looking at what the ant runner implements and what we use it seems that we'll loose test class randomization and heartbeat. The former might eventually land in junit5 junit-team/junit5#13. It doesn't seem extremely difficult to implement random test order in Gradle, there is a precedent for it: However this is internal API so would need to convince Gradle it's useful and contribute it. Other features of randomizedtesting, like stall thread detection are implemented in the runner. |
I don't think it is acceptable to lose any of the functionality from randomized runner. We would need to implement this functionality over the gradle runner. I think it is all doable, though, at least with some work. |
I agree. Especially the w.r.t the ordering of tests. Gradle doesn't have a public API (or any API I could find for that matter) that we can use. Implementing this by making changes to Gradle isn't neither hard or time consuming, but will have to figure out if that's something Gradle will accept, or if we are willing to live with the overhead of maintaining a custom Gradle distribution. Another distinction that we might have to make is: are we ok to go without randomizing test class order temporarily, but I think in order to have an informed decision we would need to measure the advantages in terms of opportunity of build time reduction this will give us, and cluster formation improvements (#30904) also come into play there. I think the first thing is to get to have a PoC run of the tests with Gradle so that we can at least have an initial measurement and comparison. |
I isolated the hanging tests task in this repo: https://github.com/atorok/gradle_test_randomizedtesting_deadlock |
The problem is in |
It's the security manage |
The Gradle runner seems to be a bit slower, running |
No, losing this would be a deal breaker. Reproducibility is paramount above all other concerns. It doesn't matter if we could run all tests in 10 seconds; if we can't reproduce failures, the speed is worthless. It is unfortunate (but not surprising) that gradle cannot handle running with security manager. This is also a deal breaker for using the gradle runner. Another option I considered which would gain us speed, would be to have separate randomized runner tasks, one for each jvm we plan to spawn. We could then do the assignment of classes to jvms late in configuration (or just before execution in a common doFirst or dependsOn). This would allow us all the utility of randomized runner, but utilizing separate tasks would allow parallelization with gradle. |
I created an issue some time ago to be able to randomize test class order with Gradle and just relized it's not mentioned here: gradle/gradle#5760 |
It seems that Gradle won't be adding direct support for this as the direction is to move to junit 5 platform which deals with test execution order. On the bright side, our tests do seem to work with |
Sounds like controlling ordering is now supported in JUnit 4.13. This would still require a contribution to Gradle core to allow deferring ordering to the JUnit runner but that might be a more manageable way forward than migrating to JUnit 5, even with the legacy support. Probably worth spiking both options to get a better idea of what might be involved. |
@atorok I've removed the |
For context we discussed this in the team and came to the conclusion that randomizing the class order might be not as important as we initially taught, so we will try to propose an implementation that doesn't take this into account. |
Currently we use https://github.com/randomizedtesting/ for running the tests.
The Gradle plugin calls into ant to do the heavy lifting.
It also replaces the Gradle
Test
task that the java plugin creates ( calledtest
) with it's ownRandomizedTestingTask
. This proved to be problematic, see #31324, and might no longer be possible in some future Gradle release.Also, running the tests in parallel with the ant runner is independent from Gradle and does not honor Gradle
--max-workers
setting, which makes it hard to make other parts of Gradle run in parallel as it can lead to too many threads being created.It is possible to use the reandmizedtesting runner i.e.
@RunWith
and run the tests with the Grade test runner. This proposal is to replace theant
part and not the runner.The text was updated successfully, but these errors were encountered: