Closed (fixed)
Project:
Automatic Updates
Version:
3.0.x-dev
Component:
Automatic Updates Extensions
Priority:
Major
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
27 Jan 2023 at 17:41 UTC
Updated:
20 Nov 2023 at 10:29 UTC
Jump to comment: Most recent
Comments
Comment #2
tedbowUnpostponing but also not tagging with
sprintbecause it iscontrib-onlyComment #3
wim leersJust like I extracted #3320792: Make build tests fail 1) more explicitly, 2) earlier when possible (failing StatusCheckEvent subscribers) from #3331168: Limit trusted Composer plugins to a known list, allow user to add more's https://git.drupalcode.org/project/automatic_updates/-/merge_requests/659, I believe I can do the same here.
(See #3320792-25: Make build tests fail 1) more explicitly, 2) earlier when possible (failing StatusCheckEvent subscribers) through #3320792-27: Make build tests fail 1) more explicitly, 2) earlier when possible (failing StatusCheckEvent subscribers).)
Comment #5
wim leersFirst pushed a test. That should fail like this:
Comment #6
wim leersAs expected:
— https://www.drupal.org/pift-ci-job/2581810
Comment #7
wim leersIf I now extract/cherry-pick the solution from https://git.drupalcode.org/project/automatic_updates/-/merge_requests/65... (which finds its origin in https://git.drupalcode.org/project/automatic_updates/-/merge_requests/65...), we can see that … it does not pass tests.
Why did it work for #3331168: Limit trusted Composer plugins to a known list, allow user to add more? Probably because #3331168 did less strict assertions that
assertStatusReportChecksSuccessful()(introduced by #3320792: Make build tests fail 1) more explicitly, 2) earlier when possible (failing StatusCheckEvent subscribers)) does.So I started debugging … and found a mind-boggling rabbit hole. Put a breakpoint in
update_get_available()and observe how many times it gets called. It's insane. There's call stacks like this:Note how
VersionPolicyValidator(which throws the error messages mentioned in #6 causing tests to fail on 10.x) ends up calling itself. And there's plenty more examples where that came from. The amount of unnecessary function calls is incredible. Now, of course, "premature optimization is the root of all evil", but at this point it interferes with debuggability and hence maintainability.Another example:
ProjectInfo->getInstallableReleases()cannot return different results within the same PHP process by definition, yet it is recomputed countless times.So I did not understand why
CoreUpdateTestwas not affected by this. It also has aassertStatusReportChecksSuccessful()and it passes tests, why?! What is it doing differently?Turns out that both
ModuleUpdateTestandCoreUpdateTestend up in\Drupal\automatic_updates\Validator\VersionPolicy\SupportedBranchInstalled::validate()looking at the real, actually requested Drupal core version info! 😬😳😱Turns out that both
CoreUpdateTestandModuleUpdateTestuse… and
setReleaseMetadata()writes this tosettings.php:$config['update_test.settings']['xml_map'] = …→ but theupdate_testmodule is never even installed! 😳😱Reclassifying this as
core-mvpbecause this severely undermined my trust in both of these testsComment #8
wim leersCompared to #6, the extracted/cherry-picked commit results in:
Comment #9
wim leersFinally found it!
Comment #10
wim leersSimplified further.
Comment #11
wim leersIt looks like the edge case uncovered/investigated in #7 and #9 can also cause random failures: see #3325654-36: Improve the user experience of having your staged update deleted before it was applied, and specifically https://www.drupal.org/pift-ci-job/2583990, which failed like this:
Comment #12
tedbowComment #13
wim leersThis now blocks #3341708 — see #3341708-4: Update requirements for 3.x.
Comment #15
wim leersRebased the old MR onto
3.0.xand opened a new MR 👍Comment #17
wim leersNope, doesn't block that anymore: #3341708-6: Update requirements for 3.x.
Comment #18
wim leers@tedbow and @tim.plunkett discussed the plan for getting Automatic Updates, Project Browser and Package Manager into core. We're likely going to aim to land Package Manager first. So postponing this issue for now, until the dust settles on that.
Comment #19
wim leersComment #20
wim leersThis now blocks #3358878: Test failing on 8.x-2.x on 10.0.x and 10.1.x.
Comment #21
wim leersUpdate on #20: confirmed at #3358878-7: Test failing on 8.x-2.x on 10.0.x and 10.1.x that the fix in this issue is essential.
Comment #22
wim leersI'll push this across the finish line, there's too much tricky past history at play here.
Comment #23
wim leersNo time for this.
Comment #24
tedbowThis issue was fixed in #3362746-7: fix 10.0.x phpstan errors. It was needed to get the tests were passing after I fixed the phpstan issues. I probably shouldn't have committed in that issue but I think the solution is correct. '
Currently
\Drupal\Tests\automatic_updates\Build\CoreUpdateTest::createTestProjectcallsThen later calls
To affirm all the status checks are passing after we have created the project.
Since
ModuleUpdateTest extends UpdateTestBasethis also fixes it for this that test.So I think the only thing left to do on this issue add an extra call to
assertStatusReportChecksSuccessful()to ensure that after\Drupal\Tests\automatic_updates_extensions\Build\ModuleUpdateTest::createTestProjecthas altered the XML fixtures in use that all thats status checks pass and there are no other errors before we start the tests.I am removing
core-mvpbecause we just have a problem left inautomatic_updates_extensionsComment #25
tedbowComment #26
tedbowComment #27
phenaproximaI don't see a problem with this. More checks and safety in our tests, especially our build tests, is a good thing.
Comment #29
tedbowComment #30
wim leers🥳 Weird to see code you wrote in January landing suddenly 😄