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_cron runs 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, like ConfigImportAllTest and UmamiMultilingualInstallTest.
  • 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 the update_test module'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.url to FunctionalTestSetupTrait::getOfflineSettings() and the KernelTestBase config overrides from #3644200: Unintentional announcements and security advisories fetched in tests, pointing to http://localhost/release-history. Requests to it never leave the machine and fail without network access. It keeps the /release-history path, so tests mocking responses by path, like PackageManagerKernelTestBase::setReleaseMetadata(), keep working.
  • Update Status tests set fetch.url in configuration to the update_test module's fake release history, so UpdateTestBase unsets the override in writeSettings(), like SecurityAdvisoryTest does.
  • 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 raise fetch.max_attempts, like testUpdateShowDisabledThemes() 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

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

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

gábor hojtsy’s picture

Status: Needs review » Closed (duplicate)

Results look good, but they are minimal on top of #3644200: Unintentional announcements and security advisories fetched in tests so folding into that.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.