Problem/Motivation
Drupal 8's REST support was developed in parallel with many other major changes in Drupal 8. Consequently, we ended up with a REST module that had little test coverage.
We fixed that in #2737719: EntityResource: Provide comprehensive test coverage: for every entity type, every format, every method + #2824572: Write EntityResourceTestBase subclasses for every other entity type.. Then we ensured that we'd never regress: #2868035: Test that all core content+config entity types have functional REST test coverage.
The next step is to ensure that every module owns its REST test coverage, to instill responsibility.
Proposed resolution
Move \Drupal\Tests\hal\Functional\EntityResource\Node\NodeHalJsonAnonTest
to \Drupal\Tests\node\Functional\Rest\NodeHalJsonAnonTest
, etc.
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#70 | 2910883-70.patch | 1.11 KB | Anonymous (not verified) |
#65 | 2910883-65-port-d85.patch | 616.8 KB | Anonymous (not verified) |
#58 | 2910883-58-script-helper.php_.txt | 1.56 KB | Anonymous (not verified) |
#58 | interdiff-d85-d86.txt | 72.52 KB | Anonymous (not verified) |
#58 | d85-2910883-58.patch | 649.33 KB | Anonymous (not verified) |
Comments
Comment #2
Wim LeersLet's show the actual number of blockers.
Comment #3
Wim Leers#2843780: EntityResource: Provide comprehensive test coverage for EntityFormMode entity landed!
Comment #4
Wim Leers#2843781: EntityResource: Provide comprehensive test coverage for EntityViewMode entity landed!
Comment #5
Wim Leers#2843755: EntityResource: Provide comprehensive test coverage for Message entity landed!
Comment #6
Wim Leers#2843764: EntityResource: Provide comprehensive test coverage for EntityFormDisplay entity and #2843765: EntityResource: Provide comprehensive test coverage for EntityViewDisplay entity landed!
Comment #7
Wim Leers#2868035: Test that all core content+config entity types have functional REST test coverage just landed. Now we just need #2843139: EntityResource: Provide comprehensive test coverage for File entity, and tighten access control handler to land (the last blocker for #2824572: Write EntityResourceTestBase subclasses for every other entity type.).
This is still PP-3 though: #2824572: Write EntityResourceTestBase subclasses for every other entity type. is still blocked on #2843139: EntityResource: Provide comprehensive test coverage for File entity, and tighten access control handler, and we did finish #2868035: Test that all core content+config entity types have functional REST test coverage ahead of time (by cheating a little bit: we specifically check that
File
has no test coverage yet, which #2824572 is fixing), but we should also block this on #2800873: Add XML GET REST test coverage, work around XML encoder quirks. So, keeping at the same postponedness level.Comment #8
Wim Leers#2800873: Add XML GET REST test coverage, work around XML encoder quirks just landed! Down to PP-2 :)
Comment #9
Wim Leers#2824572: Write EntityResourceTestBase subclasses for every other entity type. and #2868035: Test that all core content+config entity types have functional REST test coverage are done.
Time to move the tests out of REST module and into the modules that contain the respective entity types.
Comment #10
Wim LeersI've done the first step: moved the tests for the
Action
entity type into the module that provides that entity type (system
module in this case).This seems like an excellent issue for a novice to finish 🙂
EntityResourceRestTestCoverageTest
still passes with these tests moved, and should continue to pass.Comment #11
Wim LeersThe end goal is to make this test simplification pass. This ensures that every entity type has REST test coverage in the module providing the entity type.
This should fail right now.
Comment #13
Wim LeersTo be clear: somebody taking this on should continue with #10, and once they think they're done, they should be able to apply #11 and
\Drupal\Tests\rest\Functional\EntityResource\EntityResourceRestTestCoverageTest
should then still be green.Comment #14
Ivan Berezhnov CreditAttribution: Ivan Berezhnov as a volunteer and at Drupal Ukraine Community for Levi9 commentedComment #15
rajeevkAssigning myself to work in weekend..
Comment #16
rajeevkComment #17
Anonymous (not verified) CreditAttribution: Anonymous commentedFor reasons that have not yet been full clarified, the massive flow of rest tests is not very stable on CI. Shuffle tests increases stability and reduces execution time in twice (#2926309-18: Random fail due to APCu not being able to allocate memory). It seems to me, that this issue will give the same improve effect, therefore it will be very helpful check the result in a faster way. Sorry if it violates someone's plans, now the issue is not assigned, but CI is on fire.
Patch contains #10 + #11 + other tests.
Comment #18
Anonymous (not verified) CreditAttribution: Anonymous commented#17: incorrect patch :(
Comment #20
Anonymous (not verified) CreditAttribution: Anonymous commentedI made a mistake in calculations, tests are still quite close to each other :| Okay, will find something else)
Few questions by current patch:
This is an external error. Should we preserve the old classes like wrappers for BC?
core/tests/Drupal/Tests/Core/Functional - is this the right location for the test?
Comment #22
Anonymous (not verified) CreditAttribution: Anonymous commented@Wim Leers, help us please in #2930022: Testing fails 'CI aborted' and 'apcu memory' 🙏
We found that the rest-tests very strongly stop the CI. Although we have created a non-rest-patch that also adversely affects CI, it is not yet possible to pinpoint the cause of all ills. Maybe you'll have some great idea about this.
Comment #24
Wim LeersBlocked on #2930022: Testing fails 'CI aborted' and 'apcu memory', updating issue status to reflect that.
Comment #25
Anonymous (not verified) CreditAttribution: Anonymous commented#2930022 is still contains a number of puzzles that have yet to be solved. But the main problem of random apcu fail was while resolved via #2926309: Random fail due to APCu not being able to allocate memory, continued #2934002: APCu cache backend can have unreasonable number of entries during testing or multi-site. (Although I do not yet understand why, the random order of the tests and I/O blocked regim were so good for speed and stable. 🔮)
But now there are no specific assumptions that could delay us here. So let's continue.
#20 contains 1 CS error (good for a novice, and NW for this), and 2 questions (presumably for @Wim Leers):
1. Can we just move classes without leaving stubs behind them? Because some tests (like EntityTestDateonlyTest and EntityTestDatetimeTest) can rely on prev namespaces.
2. Are the tests correctly moved? I could be mistaken in some of them. Example
From:
core/modules/hal/tests/src/Functional/EntityResource/BaseFieldOverride/BaseFieldOverrideHalJsonAnonTest.php
To:
core/tests/Drupal/Tests/Core/Functional/Hal/BaseFieldOverrideHalJsonAnonTest.php
This movement is suitable for our test coverage. I also do not see anything wrong with this. But it requires a more experienced review.
Comment #26
mohit1604 CreditAttribution: mohit1604 at Google Summer of Code commentedPatch #20 no longer apply, adding needs reroll tag.
Comment #27
Anonymous (not verified) CreditAttribution: Anonymous commentedReroll done.
Also about #25.1 question. Probably the tests do not fall under the rigid BC policy. Or we can leave stubs only for the base classes like
*ResourceTestBase
. If we do the stubs for all tests, it will give a very massive duplication for the test runs on the DI.Comment #28
Anonymous (not verified) CreditAttribution: Anonymous commentedMy bad. One more attempt.
Comment #29
Wim Leers#28 still applies cleanly! Retesting…
Comment #31
xjmThe fatal is:
Comment #32
xjmUntagging for the moment. :)
Comment #33
benjifisherComment #34
ShawnB CreditAttribution: ShawnB as a volunteer commentedI'm at the Nashville 2018 sprints and I'm taking a look.
Comment #35
ShawnB CreditAttribution: ShawnB as a volunteer commentedI've submitted a patch that addresses the proposed resolution in the issue summary.
There's still the issue in #31 so I won't change this to Needs Review
Comment #36
benjifisher@ShawnB, can you attach an interdiff so that it is easier review the changes you made? Instructions here: https://www.drupal.org/documentation/git/interdiff
Looking at the error message quoted in #31 (but without checking the code) it seems likely that there is a reference to the class
EntityTestResourceTestBase
, but there is nouse
statement to give a namespace for that class. If so, then adding the missinguse
statement should fix it.Comment #37
borisson_Setting to needs review, so the testbot can take a look at #35
Comment #39
Anonymous (not verified) CreditAttribution: Anonymous commentedTL;DR; We need:
1. Reroll #28. Just update in patch
MediaResourceTestBase
to:2. Fix error #31: add to
EntityTestTextItemNormalizerTest
line:use Drupal\Tests\entity_test\Functional\Rest\EntityTestResourceTestBase;
3. Fix CS typo in
ConfigTestHalJsonCookieTest
: remove double';;'
in line:use Drupal\Tests\rest\Functional\CookieResourceTestTrait;;
Background:
💡 The task of issue is to move the tests from the folder
core/modules/rest/tests/src/Functional/EntityResource/
to folders with target modules.🎓 #10 / #11: @Wim Leers showed how to do this (and check).
📌 #17 - #20: I jumped, and laid out an almost ready patch.
🔞 This might not seem entirely ethical, since it was intended for Novice, and it was already taken for CSKyiv18 (by the way, it seems there with him did not work, so let's delete this tag). But I did it because sometimes I just can not resist the temptation of credits. And because I hoped that this would help to solve another problem, because of which the DI was on fire. Unfortunately, this did not help (or not help enough), and I switched to the further search.
☑️ Only CS nit left after #17. We hoped that one of the novice hero would help solve it.
⌛ #28 I did an unsuccessful reroll, and now one more little mistake was added. Therefore, the hope for the novices remained.
⚔️ #35: @ShawnB did a tremendous job from scratch, because unfortunately he misread IS.
🎓#36: @benjifisher explained the necessary corrections, but apparently he was not heard.
Today another reroll also is needed (see 1 point from TL;DR; part).
Comment #40
ShawnB CreditAttribution: ShawnB as a volunteer commentedShould I wait for the reroll to supply the interdiffs?
Comment #41
Anonymous (not verified) CreditAttribution: Anonymous commentedHere #28 reroll.
Comment #42
ShawnB CreditAttribution: ShawnB as a volunteer commentedLooks like the only files left to move were the ones covered by this patch. Those are
I've also attached an interdiff.
Comment #43
Anonymous (not verified) CreditAttribution: Anonymous commented@ShawnB, nice catch!
#42: Looks like 2 interdiff patches. Also, the interdiff does not contain fixes for #39.2, #39.3. If you have a desire to help them too?
Comment #44
ShawnB CreditAttribution: ShawnB as a volunteer commentedThis patch contains fixes for #39.2 and #39.3
Comment #46
Anonymous (not verified) CreditAttribution: Anonymous commentedThank you, @ShawnB! Merged 3 commits (#41 + #42 + #44).
Comment #47
Wim Leers🎉🎉🎉🎉🎉🎉
😍😍😍
Thank you, everyone! And special thanks to @vaplas for getting this issue back on track again!
I really really wanted to RTBC this, but I think this is in the wrong place.
I think this does not belong in
core/tests/Drupal/Tests/Core/Functional/…
(which did not exist before), but incore/tests/Drupal/FunctionalTests/…
, which does already exist.Once that's fixed, this is RTBC!
P.S.: I tried to generate a smaller patch, but failed to do so. This is as small as it gets — it's so big because so many files are being moved!
Comment #48
Anonymous (not verified) CreditAttribution: Anonymous commentedThank you, @Wim Leers!
#47: Sounds logical as always. I did this by using the following fraud:
Open the patch in the text editor and run Find/Replace:
After that, a little edited
EntityResourceRestTestCoverageTest
.Let's see how the test bot reacts.
Comment #49
Wim Leers🎉👌🙏
You're amazing, @vaplas! :)
Comment #51
Wim LeersThe new nightwatch-based test site installation command test coverage is failing:
Comment #52
alexpottI think we need to consider if the *TestBase classes here are test API. In other recent move all the tests issues we've left a deprecated version of the TestBase class in the existing location - which extends from the correctly placed class.
Comment #53
Anonymous (not verified) CreditAttribution: Anonymous commentedDone :)
Comment #54
Anonymous (not verified) CreditAttribution: Anonymous commentedopps, unfortunate misprint - no 'dot' in trigger_error
I already fixed it locally. Are there any ideas about the alias class name?
use Drupal\...\CommentHalJsonTestBase as CommentHalJsonTestBaseOriginal;
Maybe better 'Actual' instead of 'Original'?
Comment #55
alexpottActual is better because Original is confusing. But I think Real is probably better than Actual.
Comment #56
Anonymous (not verified) CreditAttribution: Anonymous commentedReal is the best!
Comment #57
Wim LeersThis is a good middle ground.
Just one thing:
Not 8.5.x, but 8.6.x.
Comment #58
Anonymous (not verified) CreditAttribution: Anonymous commented#56 need reroll after #2572613: Fix 'Drupal.Array.Array.CommaLastItem' coding standard (Done via #48 + #56 script).
#57: Why not in the 8.5.x? Usually we do conversion in both releases. But in any case, no problem.
Comment #60
Wim Leers👌
Comment #61
alexpottWe only deprecate stuff in the next minor. So we should only do the testbase moves in the 8.6.x. If we want we can move all the other tests in 8.5.x but that needs a new patch.
Committed 92be45b and pushed to 8.6.x. Thanks!
Comment #63
alexpottI think an 8.5.x patch of just the test moves might be a really good idea in terms of bug fixes for the 8.5.x release.
Comment #64
Wim Leers#63 I of course agree that committing it to 8.5 too would make bugfixes much easier! But doesn't that mean that #56 rather than #58 should have been committed? Or are you saying that in 8.5 you would essentially like to see the same patch but without the
@deprecated
?Also: YAY!
Comment #65
Anonymous (not verified) CreditAttribution: Anonymous commentedGreat idea. Also I bet that in most cases the changes will be made in the base classes, since they are the heart of the tests.
Comment #66
Wim LeersRTBC to get feedback from @alexpott.
Comment #67
alexpottYep no new deprecations in 8.5.x but we've kept the tests all aligned for quicker bug fixing.
Committed 0c58e37 and pushed to 8.5.x. Thanks!
Comment #69
Wim Leers🎉🎉🎉🎉
This is a huge milestone in making Drupal truly API-First:
That next step is now DONE!
Comment #70
Anonymous (not verified) CreditAttribution: Anonymous commented🚀🚀🚀
Although I will miss this thick
EntityTest
folder :)Ohh, one nit for 8.6.x (8.5.x ok)!
Comment #71
Wim LeersManually reviewed, #70 is indeed fixing the only oversight in 8.6!
Comment #72
Wim LeersAlso, since the committed patches now leave behind a BC layer, that means #2893804: Remove rest.module BC layers now needs to remove that BC layer. Did that in #2893804-32: Remove rest.module BC layers.
Comment #74
alexpottCommitted 6fdd377 and pushed to 8.6.x. Thanks!
Comment #75
Anonymous (not verified) CreditAttribution: Anonymous commented🙏🏻 Thanks @Wim Leers and @alexpott! You are great men! ⭐
Comment #77
Anonymous (not verified) CreditAttribution: Anonymous commentedFollow-up.
Comment #78
Wim LeersComment #79
quietone CreditAttribution: quietone at PreviousNext commentedpublish the change record