Problem/Motivation
Found in #3644166: [META] Find and resolve external HTTP requests from core tests. The detector added there found tests fetching release history from updates.drupal.org through UpdateFetcher, as a side effect of what they test. With #3644177: Tests should not request translations from ftp.drupal.org and #3644200: Unintentional announcements and security advisories fetched in tests fixing the translation, announcement and security advisory requests, this is the largest group left:
AssetCompressUpdatePathTest, BlockRemoveSyndicateBlocksUpdateTest, ConfigImportAllTest, HelpNoSearchUpgradeTest, NavigationUpdateTest, PreventDowngradeTest, SequencesTableRemovalUpdateTest, TextWithSummaryUpdatePathTest, UmamiMultilingualInstallTest, UpdateContribTest, UpdatePathTest (dblog), UpdatePathTestBaseTest, UpdatePathTestBaseFilledTest, UserCreatedFieldDisplayUpgradeTest, ViewsAddFilterMinMaxLabelsUpdateTest, and the kernel test SandboxManagerBaseTest.
There are three ways these requests happen:
- Update path tests load database dumps with the Update Status module installed, and
automated_cronruns cron at the end of a request:UpdateFetcher::fetchProjectData() < UpdateProcessor::fetchData() < UpdateCronHooks::cron() < Cron::run() < AutomatedCron::onTerminate(). The same happens in other tests installing the module, likeConfigImportAllTestandUmamiMultilingualInstallTest. - Kernel tests run cron with the module installed, for example
SandboxManagerBaseTest::testStageDirectoryDeletedDuringCron(). UpdateContribTest::testUpdateBrokenFetchURL()visits the available updates report before it points the module at theupdate_testmodule's fake release history, so the first fetch goes to updates.drupal.org.
Unlike announcements, update status has no setting to skip the fetching: UpdateCronHooks::cron() fetches data that is missing on every cron run regardless of check.interval_days, and fetch.max_attempts does not prevent the first attempt for a URL.
Steps to reproduce
Run any of the tests above with the detector from #3644166: [META] Find and resolve external HTTP requests from core tests.
Proposed resolution
Use the same approach as #3644200: Unintentional announcements and security advisories fetched in tests, with the update.settings:fetch.url setting, which every fetch uses unless a project sets its own project status url:
- Add an override for
update.settings:fetch.urltoFunctionalTestSetupTrait::getOfflineSettings()and theKernelTestBaseconfig overrides from #3644200: Unintentional announcements and security advisories fetched in tests, pointing tohttp://localhost/release-history. Requests to it never leave the machine and fail without network access. It keeps the/release-historypath, so tests mocking responses by path, likePackageManagerKernelTestBase::setReleaseMetadata(), keep working. - Update Status tests set
fetch.urlin configuration to theupdate_testmodule's fake release history, soUpdateTestBaseunsets the override inwriteSettings(), likeSecurityAdvisoryTestdoes. - Remove the first visit of the report from
UpdateContribTest::testUpdateBrokenFetchURL(), which only fetched from updates.drupal.org. That visit happened to fill the data of the projects that do not fail, so without it, the test also needs to raisefetch.max_attempts, liketestUpdateShowDisabledThemes()in the same class already does: refreshing through the user interface fetches twice, and the project that fails both times would otherwise stop the project after it from being fetched.
This builds on getOfflineSettings() from #3644200: Unintentional announcements and security advisories fetched in tests.
Remaining tasks
Land #3644200: Unintentional announcements and security advisories fetched in tests first.
Review.
User interface changes
None.
Introduced terminology
None.
API changes
None.
Data model changes
None.
Release notes snippet
Not needed.
LLM disclosure
LLM was used to diagnose this problem a develop solutions. The results were reviewed and adjusted as a human though.
Issue fork drupal-3644236
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:
- 3644236-tests-fetch-update
changes, plain diff MR !18125
- 3644236-testing-only
changes, plain diff MR !18124
Comments
Comment #4
gábor hojtsyComment #5
gábor hojtsyComment #6
gábor hojtsyResults look good, but they are minimal on top of #3644200: Unintentional announcements and security advisories fetched in tests so folding into that.