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() with settings.php overrides: advisories disabled (moved from prepareSettings()), an announcements cron_interval that never passes, and update.settings:fetch.url pointing to http://localhost/release-history.
  • Apply them in browser tests (prepareSettings()), installer tests (after the installer wrote settings.php) and kernel tests (KernelTestBase::bootKernel()).
  • Tests of these features opt out in writeSettings(), like SecurityAdvisoryTest already does. UpdateTestBase now does too.
  • Fix AnnounceBlockTest and UpdateContribTest::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

Command icon 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

gábor hojtsy created an issue. See original summary.

gábor hojtsy’s picture

Issue tags: +Test suite performance

gábor hojtsy’s picture

Status: Active » Needs review
gábor hojtsy’s picture

gábor hojtsy’s picture

Issue summary: View changes
gábor hojtsy’s picture

Title: Unintentional announcements and security advisories fetched in tests » Unintentional announcements, security advisories and update status fetched in tests