Problem/Motivation
Found in #3644166: [META] Find and resolve external HTTP requests from core tests. The detector there found tests fetching the announcements feed, security advisories and update status release history from drupal.org as a side effect. Mostly, automated_cron runs cron after the first request of a test site, or a kernel test runs cron, and these modules fetch on cron.
Core already disables PSAs in settings.php in FunctionalTestSetupTrait::prepareSettings(), but not in installer and kernel tests, and nothing similar exists for announcements and update status. Update status cannot be turned off by a setting: it fetches missing data on every cron run.
Steps to reproduce
Run for example StandardTest, any update path test or SandboxManagerBaseTest with the detector from #3644166: [META] Find and resolve external HTTP requests from core tests.
Proposed resolution
- New
FunctionalTestSetupTrait::getOfflineSettings()withsettings.phpoverrides: advisories disabled (moved fromprepareSettings()), an announcementscron_intervalthat never passes, andupdate.settings:fetch.urlpointing tohttp://localhost/release-history. - Apply them in browser tests (
prepareSettings()), installer tests (after the installer wrotesettings.php) and kernel tests (KernelTestBase::bootKernel()). - Tests of these features opt out in
writeSettings(), likeSecurityAdvisoryTestalready does.UpdateTestBasenow does too. - Fix
AnnounceBlockTestandUpdateContribTest::testUpdateBrokenFetchURL(), which fetched the live data before their mocks were in place.
Disabling automated_cron instead would break as soon as any test runs cron.
Remaining tasks
Review the 3644200-to-commit MR. The 3644200-with-proof-dont-commit MR adds the detector to show the requests are gone, and is not to be committed.
User interface changes
None.
Introduced terminology
None.
API changes
New protected test method FunctionalTestSetupTrait::getOfflineSettings().
Data model changes
None.
Release notes snippet
Not needed.
LLM disclosure
LLM was used to diagnose this problem, iterate on solutions and develop results. The results were reviewed and adjusted as a human though.
Issue fork drupal-3644200
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:
Comments
Comment #2
gábor hojtsyComment #6
gábor hojtsyComment #7
gábor hojtsyComment #8
gábor hojtsyComment #9
gábor hojtsy