Problem/Motivation
From #3202016-30: Let GDToolkit support AVIF image format:
ToolkitGdTest::testManipulations()is a monster that dates back to simpletest when multiple tests were performed in a single method to avoid multiple installations. In the era of Kernel tests, it's better split it in more understandable bits.
This entire class dates back to Simpletest times, today we can use data providers and have more atomic tests.
Steps to reproduce
n/a
Proposed resolution
Modernize the test.
Remaining tasks
User interface changes
n/a
API changes
n/a
Data model changes
n/a
Release notes snippet
n/a
| Comment | File | Size | Author |
|---|---|---|---|
| #37 | interdiff_32-37.txt | 1.37 KB | spokje |
| #37 | 3239935-37-d95.patch | 32.17 KB | spokje |
Issue fork drupal-3239935
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3239935-refactor-toolkitgdtest
changes, plain diff MR !1274
Comments
Comment #3
mondrakeComment #4
andypostQuickly skimmed the diff and found only one nit
Comment #5
mondrakeThanks for the review @andypost! Comment and changes in the MR.
Comment #6
andypostI find it ready for commiters! great clean-up!
Comment #7
daffie commentedCreated 2 unresolved threads on the MR.
Comment #8
mondrakeGood points @daffie, thank you
Comment #9
daffie commentedLooks good to me.
Comment #10
mondrakeRerolled
Comment #11
alexpottThis look nicer but there's a massive difference in test performance. What used to take 8 secs is now taking over 2 mins and making my fans blow very very hard. Perhaps we can refactor the test to split things up but not use data providers because ktb site installation is not free.
Compare:
to
Comment #14
alexpottOops did not mean to commit this one given #11. Sorry for the noise.
Comment #15
mondrakeWhile trying to introduce AVIF image processing in #3202016: Let GDToolkit support AVIF image format, with the current test in HEAD I got
We only know from this this that, somewhere, a segfault occurred. With an equivalent of the patch here, I got
This tells us that any non-AVIF image converted to AVIF fails, any operation on an AVIF image fails, but converting an AVIF file to any other non-AVIF image succeeds. This helped to point out that the failure is only when saving an image to AVIF format, hence finding https://bugs.php.net/bug.php?id=81217.
To me, the decrease in perfomance of the test is overcome by the informational gain that having more atomic tests brings. Yes it is significant, but IMHO this is how it should be, and on the testbot a 1 minute long test is not a particularly long one.
Comment #18
andypostIs there a way to run this tests in parallel, it could help minimize time...
Otherwise it should not be a blocker for AVIF format support into 9.5/10
Comment #19
mondrakeComment #20
andypostLooks ready for me, thank you
Comment #21
alexpottJust a few nits added to the MR review. Thanks for working on this @mondrake
Comment #22
alexpottAlso point #11 still stands - we're changing a test that takes 3.6 seconds locally for me to one that takes 81.1 seconds... like over 1 minute.
Comment #23
mondrakeIn #15 I explained why I think we shoud take this hit IMHO
Comment #24
alexpottTo fix #11 I'd drop the data provider for testManipulations... and change the provider to testManipulations() and change testManipulations() to doTestManipulations()... and call that from testManipulations(). FWIW the changes here, moving each operation into a separate test, lose coverage of the fact that operations can be chained in the same process without affecting each other.
Comment #25
mondrakeFixed the review points and removed pre-PHP8 checks, no longer relevant in D10.
Well, the current code in HEAD
https://git.drupalcode.org/project/drupal/-/blob/10.0.x/core/tests/Drupa...
makes so that at every loop we always start from the source image, so we do not really chain ops on the current image as part of the loop - hence why I moved that to dataprovider.
Sure, but that would mean that the first failing op in the loop will fail the entire test, whereas I value the independent testing of each file-operation combination - see #15
Comment #26
daffie commentedAll changes look good to me.
All points of @alexpott have been addressed.
Back to RTBC.
Comment #27
mondrakerebased
Comment #28
alexpottOkay I've work out why my local was making it take so long... I have some themes in my root/themes directory that was making things take a while. There are other things we can do to speed things up. One fix is #3293446: Create less static cache in ExtensionDiscovery during KernelTests
The test now goes from 3 seconds to 30 seconds - not so bad. Still a factor of 10 but I think there are other things we can do to improve test running time.
Committed and pushed fa8a8df587 to 10.1.x and 6ef26c6905 to 10.0.x. Thanks!
Can we get a 9.5.x / 9.4.x version of the patch.
Comment #32
spokjeComment #33
spokjeComment #34
mondrakeThe problem will be with PHP 7.3 that does not support typed class properties.
Comment #35
spokje@mondrake Ah crap, thanks for being as sharp as a knife (as always), I always forgot about the stepchild PHP 7.3.
Comment #36
spokjeComment #37
spokjeLet's give this a whirl.
Comment #38
spokjeComment #39
mondrakeThank you @Spokje!
Comment #40
alexpottCommitted and pushed 414b11760d to 9.5.x and 33e22391ec to 9.4.x. Thanks!