-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Upgrade Tests to Parallel Execution #5737
Comments
Seems to be a good time saver for the devs. How is the coverage of the tests? |
Yes, based on our experiments, after this issue is implemented, it will save developers time and thereby improve R&D efficiency. |
This is a good improvement, with parallel execution turned on, do the test case methods suffer from each other. |
@CarlChaoCarl Have you compared the test results after serial execution and parallel execution? Are the two guaranteed to be completely consistent? If parallel execution is enabled, is the order of single test execution actually completely random? And is the time of execution remains stable ? |
@CarlChaoCarl It is a good idea to execute tests in parallel to reduce running time. We look forward to implementing it. In addition, many tests need to start the system, which takes up a lot of time. Can the tests that need to start the system be merged? |
Yes. |
|
Starting the system in test method is not a good way @ss3344520 |
@CarlChaoCarl Hi, any future plan for this function? Looking forward to the progress of the project~ |
Features are already under development. |
Test parallelization is currently paused, so I temporarily close this issue. |
Background
Currently, the tests of Java-tron are executed serially, which makes it take a long time to execute all of them. For a Macbook Pro with a 2.6 GHz six-core Intel Core i7 processor, and 16 GB 2667 MHz DDR4 memory, it takes 24 minutes to run all tests.
Technically speaking, parallel execution of the tests compared to serial execution will significantly reduce the total execution time, thus improving R&D efficiency. Meanwhile, the coverage of the tests should be maintained.
Rationale
To enable test parallelism in java-tron, you need to change the configuration of gradle.
Gradle supports parallel execution of tests, which can be achieved by using Gradle's parallel testing function.
Use the following properties to control how the test process is started Test task:
For example, let’s configure parallel testing in the build.gradle file of gradle and configure the maxParallelForks attribute in the test task.
After this configuration, Gradle will run 4 test tasks in parallel.
Refer to Gradle's configuration documentation here: Testing in Java & JVM projects
By setting this property to a value greater than 1, tests can be run in parallel. This may make the tests run faster, especially with a multi-core CPU. When using parallel test execution, make sure your tests are properly isolated from each other. Tests that interact with the file system are particularly prone to conflicts, causing intermittent test failures.
This can be done by using the org.gradle.test.worker property, which is unique for each parallel worker. You can use this for anything you want, but it is especially useful for filenames and other resource identifiers to prevent the single-test conflicts mentioned above.
Implementation
To enable test parallelism in Java-tron, you need to make the following Gradle configuration changes
The tests of Java-tron have incurred some new problems under parallel execution. Currently, the tests with these problems have been sorted out.
When these problematic tests are commented out, everything is fine when executing tests in parallel.
After changing to parallel execution, some tests occasionally failed to execute.These tests need to be refactored so that all tests of Java-tron can be executed in parallel.
Experiments were conducted on an AMD EPYC 7R32 server with 64G memory and 32 core processors, and the following data were obtained:
Based on the above experiments, enabling test parallelism on a multi-core machine can indeed reduce the execution time of tests, and the test parallelism can be set to = cpu core num / 2.
After enabling parallel unit tests, the newly added unit tests need to be executed normally under parallel execution.
The text was updated successfully, but these errors were encountered: