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.
See #2862508: Convert system functional tests to phpunit
See #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase)
Scope:
Everything in /core/modules/system/src/Tests/Install
Things taken into account:
- All tests were moved to /core/tests/Drupal/FunctionalTests/Installer where the BrowserTestBase version of InstallerTestBase already lives
- All setUp() logic was moved to prepareEnvironment() to take into account the order in which the file system is set up in BrowserTestBase
Comment | File | Size | Author |
---|---|---|---|
#88 | interdiff-78-87.txt | 1.08 KB | Anonymous (not verified) |
#87 | 2907728-87.patch | 58.55 KB | Lendude |
#78 | 2907728-78.patch | 59.62 KB | Lendude |
#78 | interdiff-2907728-74-78.txt | 3.83 KB | Lendude |
#74 | interdiff-71-74.txt | 3.81 KB | Anonymous (not verified) |
Comments
Comment #2
dawehnerLet's see where I get to
Comment #3
dawehnerCurrent progress ...
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedI'm not sure, that my patch contains improvements (it's hard enough for me). So, you can ignore this patch. It seems that the install page hasn't
'profile'
tab (task). As result, drupalPostForm not works (without related 'profile' field).Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedAlso ConfigTranslationInstallTest already works with patch #3. Cool!
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commentedNit reroll.
Comment #9
Lendudeworking on cleaning up some of these fails
Comment #10
LendudeThis should clear up some of the fails, just moving stuff from setup() to prepareEnvironment()
Comment #12
LendudeThis comes back green for everything locally, lets see what happens here.
Comment #14
Anonymous (not verified) CreditAttribution: Anonymous commented#10, #12: Steep fixes!
#13: I cann't reproduce these fails too.
Comment #15
LendudeYeah these are green for me locally too, stab in the dark attempt at a fix....
Comment #17
LendudeLendude's proficiency in Blind fighting has gone up a level (2)
Ok that seems to do the trick, now the other one...
Comment #19
LendudeOk so fixing the second one, re-breaks the other one....
lets simplify InstallerExistingSettingsNoProfileTest, locally it works fine without the whole $request = Request::createFromGlobals(); bit
Comment #21
LendudeAhhh crap, it's random fails :(
#19 had 3 failing tests the first time, 0 fails on retest. That's not good.
Edit: On the plus side: it's green! So that's nice :)
Comment #22
LendudeLets get rid of this __construct(), passes locally without it and I can imagine that could lead to weird results.
Comment #24
Anonymous (not verified) CreditAttribution: Anonymous commented#17: xD
#19: First green! 🎉
#22: Yep, in #4 I added a lot of garbage :(
Revert __construct(), ad the attempt to clean anything else.
Comment #26
Anonymous (not verified) CreditAttribution: Anonymous commentedWhat can cause a random fail? Maybe the redirect does not have time to happen?
Comment #29
Anonymous (not verified) CreditAttribution: Anonymous commentedRandom fail: miss
PHP versions: hit
Comment #31
Anonymous (not verified) CreditAttribution: Anonymous commentedMaybe path to file?
Comment #33
Anonymous (not verified) CreditAttribution: Anonymous commented#31 bad patch, sorry. Continue search in #2920081: Ignore: patch testing issue . Current results:
Comment #34
dawehner@vaplas
That sounds like the user is not logged in after the installation.
Comment #35
Anonymous (not verified) CreditAttribution: Anonymous commented@dawehner, thanks for hint! Perhaps it is true. But not only logged is problem here. Because we would get an "Access denied" instead of "Page not found". In any case, I'm starting to hunt for the account instance in the ignore-issue :) I hope to catch something else 🎣
Comment #36
dawehnerKeep up the great work!
Comment #37
Anonymous (not verified) CreditAttribution: Anonymous commentedThank you!
It seems the stability is violated by
cache bin 'config' last_write_timestamp_cache_config
record. Unfortunately, I do not know how to take advantage of this yet.. So, while just delete it.Comment #38
Anonymous (not verified) CreditAttribution: Anonymous commentedComparing
last_write_timestamp_cache_config
values:Nanoseconds round problem?
Comment #39
Anonymous (not verified) CreditAttribution: Anonymous commentedSplit to #2920590: (canard?) Big Bos of Random Fails is ChainedFastBackend::markAsOutdated()
Comment #40
dawehnerI tried to compare what is different to this patch from before, they are reallly similar at this point!
One part of the
initMink
call is, so I'm wondering whether skipping this here makes any difference. I think it is worth giving it a try
Comment #41
LendudeLets see if #40 helps.
Comment #42
Lendude?
Comment #44
Anonymous (not verified) CreditAttribution: Anonymous commented#40: Brilliant point!
#41: For some reason, I was not smart enough to understand how to implement it.
#42: Both green!
#43: I wanted to check that without this correction tests are still falling.
Comment #45
Lendude@dawehner+++++++++++++++
Now without the massive code duplication of copy/pasting initMink()
Comment #46
dawehner@lendude++ I'm glad you actually tried it out :)
👍 Nice method name and excellent documentation.
Did you tried that already out in a test only issue?
@vaplas I would rely on you on
Note: One is using
\Drupal::root()
and one$this->root
, but mostly i'm wondering whether why we cannot keep the code invisitInstaller
Does this belong in this patch?
Comment #47
Anonymous (not verified) CreditAttribution: Anonymous commentedYep. I restarted the #29, after I saw the green DistributionProfileExistingSettingsTest in #41. And this restart ended in failure.
Not that I doubted your great proposal, just for an additional check ) 🙏
Comment #48
LendudeBit of a clean up.
#46.1 I moved everything that used to be in setup() to prepareEnvironment() in all tests. I'm sure there are some other places we could put that code in certain tests but this keeps it a little sane for reviewing purposes.
#46.2 oops! mixin up patches, took it out.
Comment #49
dawehnerI think we have more examples of \Drupal::root() vs. $this->root. What about creating a follow up: #2928710: Eliminate usages of \Drupal::root() in tests
Can I be naive and ask why this moving is needed in the first place?
Comment #50
LendudeSorry it took me a while to get back to this one. Needed a reroll so no interdiff.
#49.1 yeah doing a clean up sounds like a good idea. Changed the usage of \Drupal::root() where we we already using $this->root to prevent mixing them inside the same method.
#49.2 It was mostly because in a lot of cases we needed the file system to be set up, and this happens in prepareEnvironment. So running this code before setup was run would lead to problems (see #10). So just for ease of conversion, everything that was in setUp() was moved to prepareEnvironment. I'm not sure it was needed in every case, but I think it's clearer to just use the same pattern for every test.
Comment #52
Anonymous (not verified) CreditAttribution: Anonymous commented@Lendude, thanks for continue! I do not know why, but I was knocked down for it. So it's great that you have a time for this again!
But why almost all the tests fail? Locally they are green. Let's check the contents of the page on which the fall occurs.
Comment #53
Anonymous (not verified) CreditAttribution: Anonymous commented:)
So, c/p changes in InstallerTestBase from #2670966-129: Warn users of old PHP versions with two bit difference in
continueOnExpectedWarnings()
:Mink specific.
Otherwise, the redirect does not work after the click.
Comment #54
LendudeSo the only thing left in the Installer dir after applying the patch is
\Drupal\system\Tests\Installer\ConfigAfterInstallerTestBase
.We probably need to @deprecated that, and add a CR for that. Or do we want to leave it for #2932909: Convert web tests to browser tests for Simpletest module
Updated the IS a bit.
Comment #56
LendudeAdded the deprecation for ConfigAfterInstallerTestBase, that takes care of everything in the installer dir.
Comment #58
Lendudeneeded a reroll for 8.6.x
Comment #60
Lendude.....
Comment #61
jibranJust some observations.
Why are we doing this twice?
The comment needs an update.
> 80 char
Outdated comment.
Do we need this BTB as well?
> 80 char.
Comment #62
Lendude@jibran thanks for looking at this!
#61.1 nice catch! removed the __construct method from InstallerTestBase, we should not be setting up in __construct, that's what setUp is for. Tried a couple of tests locally and doesn't seem its needed, but lets see what the Bot thinks.
#62.5 Not sure what you mean. Do you think we should move the translatePostValues method to BrowserTestBase? It was on WebTestBase but in core its only used in installer tests, so my vote would be to keep BrowserTestBase as lean as possible.
Fixed the comments you found plus some other WebTestBase references that were floating around.
Comment #63
jibrannm #62.5. interdiff looks good to me so RTBC unless bot disagrees.
Comment #65
Lendudelooks like the __construct was a left over from previous attempts to make tests pass while overriding setup(). This doesn't work for BrowserTestBase, so all tests now use prepareEnvironment() and not setup(). The failing tests in #62 were all still using setup().
Lets see if I got everything.
Comment #66
jibranThat's even better.
Comment #68
jibranComment #69
tstoecklerNote that [2939753] actually deprecates
ConfigAfterInstallerTestBase
into a more genericProfileTestBase
. I just saw this issue now, otherwise would have coordinated earlier. Don't want to stop this going in, though, as that one is not yet RTBC. So just a heads up, maybe someone has thoughts on this...Comment #71
LendudeNeeded an update after #2927344: Specifically warn about end dates for PHP support for old versions landed. This gets the BrowserTestBase version of InstallerTestBase back in line with the Simpletest version.
Comment #72
jibranThanks, for the update.
Comment #73
Anonymous (not verified) CreditAttribution: Anonymous commentedgit diff HEAD:core/modules/simpletest/src/InstallerTestBase.php HEAD:core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php > interdiff-InstallerTestBase.txt
All changes looks good. Except
+ protected function translatePostValues(array $values) {
This method from in WebTestBase. What about idea move it to BTB too? This will also remove the duplicate from
MigrateUpgradeTestBase::translatePostValues()
.Comment #74
Anonymous (not verified) CreditAttribution: Anonymous commentedAdded related issue from @tstoeckler (#69). If I understand correctly, whose issue will be commited the second, that it will be necessary to make correction. But not before?
#73: done (or it should be like follow-up?)
Comment #75
Lendude@vaplas would have been fine to do in a follow up I think (this is big enough as it is), but we have it now, so that's fine too. Always good to reduce duplication like that.
Looks good.
Comment #76
alexpottHmmmm... why? At the very least this needs a comment. I can comment it out and run
\Drupal\FunctionalTests\Installer\StandardInstallerTest
successfully so it's definitely not needed for every test.If I run tests via run-tests.sh for some reason tests based on the new InstallerTestBase don't look right...
versus for a regular BTB test...
For some reason the test summary is missing.
Comment #77
Mile23We've made it this far without adding globals to our functional tests, and we shouldn't do it now.
Normalize on $this->root.
StandardInstallerTest
shows up as a risky test, so apparently it's not making any assertions.Also, you can't run
--group Installer
unless you've already installed a site in place. Try it:That's an argument in favor of converting these tests to kernel tests instead of functional tests, but that might be out of scope here.
Comment #78
Lendude@alexpott and @Mile23 thanks for the feedback.
#76.1 Took out bootstrap.inc, you are right, it makes no difference, no idea why that was in, probably some left over earlier attempt to get these things to pass
#76.2 run-tests.sh just spams me with deprecation notices and fails, but I think it might have something to do with #77.3, lets see it that fixes this
#77.1 removed $base_path, lets see if that was needed anywhere, left $base_url in since removing that seems out of scope here
#77.2 sorta violates our 'keep the changes minimal' policy, but yeah lets clean that up
#77.3 "it's not making any assertions", well to be precise, it's not making any PHPUnit assertions, just custom stuff so they don't show up for the PHPUnit count, added some calls to
addToAssertionCount
in what seems like good places to start.Yeah that seems a tad out of scope here :D
Lets see how this does on the bot.
Comment #79
Anonymous (not verified) CreditAttribution: Anonymous commented#78: Excellent adjustments! +1 to RTBC.
I added bootstrap.inc in #4 because many tests failed without predefined path constants (and I was afraid that they might lack something else too). But after numerous adjustments from Lendude, the tests work like a charm without it. Cool!
Comment #80
dawehnerThis is indeed some nice improvement!
Great catches by @Mile23 and @alexpott!
Comment #81
alexpottEverything looks great here. I think we should open a follow-up (or search for an existing issue) to fix how run-tests.sh deals with risky tests. We might have some atm and we would not know.
One thing that gives me pause about committing this now is that this would represent a massive divergence in 8.5.x and 8.6.x testing and it some of our most important tests - ie. the installer tests. I'm going to tag this needs release manager review and see if we can get consensus to backport this to 8.5.1.
Comment #82
chr.fritschWould it make sense to make this configurable so that distributions could use this test as well?
I am thinking about ThunderInstallerTest that currently extends InstallerTestBase.
https://cgit.drupalcode.org/thunder/tree/src/Tests/Installer/ThunderInst...
Comment #83
alexpott@chr.fritsch I think that that might valid but in a separate issue.
Comment #84
alexpottCommitted 21dd263 and pushed to 8.6.x. Thanks!
Can we get an 8.5.x version of the patch without the deprecation (thanks @catch for the idea). So we can keep 8.5.x and 8.6.x in sync. We'll commit once 8.5.0 is out.
Comment #86
alexpottComment #87
LendudeThanks everybody for your work on this, very nice to get this in!
Here is the 8.5.x patch without the deprecation of \Drupal\system\Tests\Installer\ConfigAfterInstallerTestBase
Comment #88
Anonymous (not verified) CreditAttribution: Anonymous commentedExcellent news! Many thanks! 🎉🎉🎉
Made an interdiff for insurance.
Comment #89
jibranWe already have #2905007: Allow run-tests.sh to report skipped/risky/incomplete PHPUnit-based tests. Do we still need a dedicated issue for risky tests?
Comment #90
alexpott@jibran it's not the same as a skipped test - so I would say yes. Obviously the issues are related though so should be linked.
Comment #91
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #92
Mile23I'll update the scope for #2905007: Allow run-tests.sh to report skipped/risky/incomplete PHPUnit-based tests because they're different categories but the same solution.
Comment #93
alexpottCommitted 578b093 and pushed to 8.5.x. Thanks!