It would be useful if there was a version of run-tests.sh that could just run the PHPUnit tests but allowed concurrency.

CommentFileSizeAuthor
#3 2867818-3.patch6.23 KBdawehner

Comments

DamienMcKenna created an issue. See original summary.

chi’s picture

We may consider the use of ParaTest.

dawehner’s picture

StatusFileSize
new6.23 KB

I tried to experiment a bit with paratest earlier and again now.

Unit tests

$ time ./vendor/bin/paratest -c core/phpunit.xml core/tests/Drupal/Tests/Component/
Time: 14.5 seconds, Memory: 16.00MB
Tests: 5540, Assertions: 11087, Incomplete: 7.
       14.59 real        38.34 user        16.12 sys

$ time ./vendor/bin/phpunit -c core/phpunit.xml core/tests/Drupal/Tests/Component/
Time: 24.91 seconds, Memory: 82.00MB
Tests: 8932, Assertions: 11087, Skipped: 1917.
       24.98 real        16.14 user         1.65 sys

I haven't done the research yet why it counts the amount of tests different nor why the pure phpunit runner skips some tests for me.

Kernel tests

$ time ./vendor/bin/paratest -c core/phpunit.xml core/tests/Drupal/KernelTests/Core/Entity/
Time: 2.01 minutes, Memory: 10.00MB
OK (162 tests, 5174 assertions)
      120.68 real       304.35 user        32.02 sys

$ time ./vendor/bin/phpunit -c core/phpunit.xml core/tests/Drupal/KernelTests/Core/Entity/
Time: 7.01 minutes, Memory: 12.00MB

OK (162 tests, 5174 assertions)
      421.12 real       267.67 user        20.72 sys

Browser tests

$ time ./vendor/bin/paratest -c core/phpunit.xml core/tests/Drupal/FunctionalTests/Routin
g/
Time: 33.33 seconds, Memory: 6.00MB
OK (4 tests, 13 assertions)
       33.35 real        41.35 user         2.56 sys

$ time ./vendor/bin/phpunit -c core/phpunit.xml core/tests/Drupal/FunctionalTests/Routing/
Time: 53.53 seconds, Memory: 6.00MB
OK (4 tests, 13 assertions)
       53.56 real        40.79 user         2.29 sys

TL;DR It speeds things up indeed

As a side note: https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/PhpUni... provides some poormans parallelism.

To be honest though run-tests.sh does not just solves the paralleism side of things, it opens up the result in a browser. It does things like

// Ensure all test locks are released once finished. If tests are run with a
// concurrency of 1 the each test will clean up its own lock. Test locks are
// not released if using a higher concurrency to ensure each test method has
// unique fixtures.
TestDatabase::releaseAllTestLocks();
mile23’s picture

The version of run-tests.sh that runs phpunit tests concurrently is run-tests.sh. :-)

$ php ./core/scripts/run-tests.sh --concurrency 32 --types="PHPUnit-Unit,PHPUnit-Kernel,PHPUnit-Functional"
## We run PHPUnit-FunctionalJavascript separately because it can't do concurrency.

The issue is maintainability and testability, not capability. See for instance #2641632: Refactor simpletest's *_phpunit_*() (and junit) functions etc. to a class, deprecate where we start to make this hunk of code more maintainable. #2624926: Refactor run-tests.sh for Console component. tries to refactor the whole thing, which might not be the best idea in just one go. #2866082: [Plan] Roadmap for Simpletest talking about decoupling run-tests.sh and other testing infrastructure from the simpletest module.

Even if we do switch to paratest or whatever, we'll still need to maintain run-tests.sh because the testbot needs it for BC on contrib. So let's just make run-tests.sh maintainable.

Adding tag and parent because you can't actually search for 'run-tests.sh' on d.o.

chi’s picture

As a side note, the performance of tests can be improved by adjusting the number of test processes to run in parallel.

Here are ParaTest results against core/tests/Drupal/KernelTests/Core/Entity made on my local environment (8 cores).

Concurrency Time, min
1 (pure PHPUnit) 6.69
1 6.93
2 3.48
3 2.74
4 2.43
5 (default value) 2.08
6 1.96
7 1.94
8 1.87
9 1.83
10 1.78
15 1.81
20 1.80
25 1.78
30 1.76
35 1.76

Given the above note (#4) there is no point in adding ParaTest to core unless it is considered as successor of run-tests.php in Drupal 9.

dawehner’s picture

I have a hard time seeing us maintaining simpletest and run-tests.sh and all the suite in case phpunit totally cuts it. In general it feels like its better to make the phpunit stuff better than to iterating on the simpletest stuff, but you know, that's simply my personal opinion.

mile23’s picture

Issue tags: +Needs issue rescope

OK, so what specifically is missing that we'll get by going from three test runners to four?

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jibran’s picture

I think it should be good if we'd be able to fix it before D9.

mile23’s picture

What needs fixing?

jibran’s picture

I meant get rid of run-test.sh and build/use a new phpunit based script which allows concurrency for drupalci.

mile23’s picture

run-tests.sh currently provides concurrency for PHPUnit-based tests under DrupalCI.

I don't love run-tests.sh, but we have two options:

Make run-tests.sh maintainable or re-write run-tests.sh.

The former can be accomplished in a way that's consistent. In fact most of the work has already been done and awaits review, or at least a ping of interest from anyone to do a reroll. #2866082: [Plan] Roadmap for Simpletest

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.