Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In light of #2188661: Extension System, Part II: ExtensionDiscovery:
I wanted to know where exactly tests, or respectively Drupal core, is terribly slow.
So I quickly hacked up a naive bench() facility for TestBase, which is wrapped around individual aspects of interest and simply prints to stdout (on CLI only).
My local box shows some interesting things already, curious to see what the testbot review log will show.
Comment | File | Size | Author |
---|---|---|---|
#17 | interdiff.txt | 2.49 KB | sun |
#17 | test.bench_.17.patch | 11.5 KB | sun |
#13 | interdiff.txt | 535 bytes | sun |
#13 | test.bench_.13.patch | 10.29 KB | sun |
#12 | interdiff.txt | 1.95 KB | sun |
Comments
Comment #2
sunComment #3
sun2: test.bench_.2.patch queued for re-testing.
Comment #4
sun2: test.bench_.2.patch queued for re-testing.
Comment #5
sunAdded hit list of most expensive tests.
Comment #6
sunWell, that was most certainly the best idea ever in terms of benchmarking tests :-)
The testbot spends 14 minutes on Drupal\system\Tests\Module\InstallUninstallTest alone! :-(
The very end of the "Review log" (fieldset) holds the hit list of most expensive tests, ranked by time: https://qa.drupal.org/pifr/test/778973
Excerpt:
Comment #7
sunMost of the top-ranking tests are tests that are needlessly using the Standard profile, which circles back into:
#1595028: Convert tests using Standard profile to use Testing profile instead
I'm going to create dedicated spin-off issues for each of the offending tests now.
Comment #8
martin107 CreditAttribution: martin107 commentedIncluding a graph to show test time
My brain found it easier to process in minutes so here is the top 10
Most expensive tests:
839.917s = 14.00min Drupal\system\Tests\Module\InstallUninstallTest
459.433s = 7.66min Drupal\system\Tests\Module\ModuleApiTest
402.332s = 6.71min Drupal\menu_ui\Tests\MenuTest
358.372s = 5.97min Drupal\node\Tests\NodeTranslationUITest
310.296s = 5.17min Drupal\config\Tests\ConfigImportAllTest
307.069s = 5.12min Drupal\config_translation\Tests\ConfigTranslationUiTest
280.740s = 4.68min Drupal\field_ui\Tests\ManageFieldsTest
280.146s = 4.67min Drupal\views_ui\Tests\DisplayTest
230.260s = 3.84min Drupal\locale\Tests\LocaleUpdateTest
221.772s = 3.70min Drupal\toolbar\Tests\ToolbarAdminMenuTest
Comment #9
sunEven better: Let's make all of 'em FAIL.
Added actual constraint/assertion for total test duration time.
Comment #11
sunDiscovered an additional perf problem on a different end.
Comment #12
sunBumped max allowed duration to 3 minutes.
Make WebTestBase *validate* that a test actually performed any kind of HTTP request.
Based on my recent findings, the second change will reveal *tons* of crappy legacy tests.
Comment #13
sunFixed HTTP request tracking flag must be reset to FALSE in setUp().
Comment #16
martin107 CreditAttribution: martin107 commentedLooking at FieldTestType which is a candidate for conversion
FieldTestType which extends NodeTestBase which extends ViewTestBase which extends WebTestBase.
Quoting from ViewTestBase
It looks like this is a common pattern/mistake and that VIewUnitTest should be used in many more cases.
Comment #17
sunFixed reporting for webtest methods that do not perform a request.
Comment #18
sunSince that web test vs. DUTB situation is only closely related but actually a different problem space:
#2258173: [meta] Various web tests are not performing any HTTP requests
+ first spin-off, since those tests are dominating the report:
#2258177: Convert migrate_drupal tests to KernelTestBase
How to chunk/bundle the other tests should be discussed in the new meta issue. Perhaps by module? Let's discuss over there.
Comment #20
sunCreated #2258241: Remove obsolete Drupal\system\Tests\Module\InstallUninstallTest (yes, I'm that bold.)
Comment #21
sunSame fate: #2258247: Remove useless Drupal\config\Tests\ConfigImportAllTest
Comment #32
quietone CreditAttribution: quietone at PreviousNext commentedThe simpletest module is obsolete in core. Moving to SimpleTest project.
Comment #33
BerdirI'd suggest just closing it (and keep in core maybe for historic reasons?). Conceptually, phpunit browser tests work quite the same, but the issue is very old and nothing actionable will come from it anymore I assume.
Comment #34
quietone CreditAttribution: quietone at PreviousNext commentedFollowing the advice in #33 and returning to core and closing as outdated.