Problem/Motivation
Tests should not depend on the network unless that is their explicit goal. Several core tests silently do though, because the default configuration of some modules and test profiles points at real drupal.org services, and test mocks often replace the http_client service only, while some code builds its own client from http_client_factory.
This surfaced in #3619842: Translation install and update batch does a HEAD and then a GET request for every project unnecessarily, does not accept compressed data, where the locale translation batch was changed to do one conditional GET instead of a HEAD + GET. In main, installer and translation tests already send HEAD requests to ftp.drupal.org, and the result happens not to matter, since the local test translation file is always newer than the remote one.
Tests depending on the network are slower, fail when the network or the remote service is down, and change behavior when the remote content changes, which is out of our control.
All production Guzzle clients in core are created by ClientFactory::fromOptions(), which gives a single place to observe them.
Steps to reproduce
Run the test suite without network access, or with ftp.drupal.org / updates.drupal.org resolving to 127.0.0.1.
Proposed resolution
The detector found these HTTP requests made, look at the issues solving them here:
| Source | Endpoint | Requests | Issue |
|---|---|---|---|
| Locale translation updates | ftp.drupal.org | 71 | #3644177: Tests should not request translations from ftp.drupal.org |
| Update status | updates.drupal.org/release-history | 26 | #3644200: Unintentional announcements, security advisories and update status fetched in tests |
| Security advisories | updates.drupal.org/psa.json | 15 | #3644200: Unintentional announcements, security advisories and update status fetched in tests |
| Announcements feed in Umami tests | www.drupal.org/announcements.json | 4 | #3644175: Uninstall announcements feed on Umami |
| Announcements feed in other tests | www.drupal.org/announcements.json | 9 | #3644200: Unintentional announcements, security advisories and update status fetched in tests |
| Media oEmbed | oembed.com, oembed1.com, www.youtube.com, i.ytimg.com | 12 | #3644258: oEmbed kernel tests fetch from oembed.com and YouTube |
KernelTestBaseTest::testOutboundHttpRequest() (intentional) |
example.com | 1 | |
| Total | 138 |
Remaining tasks
Review the issues. Once those landed, the detector should not find any more testing of the internet.
User interface changes
None.
Introduced terminology
N/A.
API changes
N/A.
Data model changes
None.
Release notes snippet
N/A.
LLM disclosure
LLM was used to find this problem and come up with a detector. With human review.
Issue fork drupal-3644166
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 #3
gábor hojtsyLLM analysis of the results of the detector run: the MR pipeline failed 51 test classes in kernel, functional and functional JavaScript jobs, all of them on the detector; nothing else failed. Grouped by the code making the request:
LocaleFileManagerAssetOptimizationUmamiTest,ConfigTranslationInstallTest,DemoUmamiProfileTest,DistributionProfileTranslationQueryTest,DistributionProfileTranslationTest,DrupalFlushAllCachesInInstallerTest,HelpTopicTranslationTest,InstallerExistingConfigExistingSettingsTest,InstallerExistingConfigNoProfileTest,InstallerExistingConfigTest,InstallerLanguageDirectionTest,InstallerTranslationDownloadTest,InstallerTranslationMultipleLanguageKeepEnglishTest,InstallerTranslationQueryTest,InstallerTranslationTest,LocaleNonInteractiveInstallTest,LocaleThemeInstallTest,MultipleRequestsPerformanceTest,NodeTypeTranslationTest,OpenTelemetryPerformanceTest,UmamiMultilingualInstallTest,UninstallDefaultContentTestuse_source: localin thetestingandtesting_localeprofiles and thetesting_config_installfixture; a test-level override fordemo_umami; mockhttp_client_factorytoo inInstallerTranslationDownloadTestUpdateFetcherAssetCompressUpdatePathTest,BlockRemoveSyndicateBlocksUpdateTest,ConfigImportAllTest,HelpNoSearchUpgradeTest,NavigationUpdateTest,PreventDowngradeTest,SequencesTableRemovalUpdateTest,TextWithSummaryUpdatePathTest,UmamiMultilingualInstallTest,UpdateContribTest, dblogUpdatePathTest,UpdatePathTestBaseFilledTest,UpdatePathTestBaseTest,UserCreatedFieldDisplayUpgradeTest,ViewsAddFilterMinMaxLabelsUpdateTestupdate.settings:fetch.urlat a local URL inUpdatePathTestBase(the database dumps have update module enabled); find whichUpdateContribTestcase misses the update_test fixtures (requests foraaa_update_test,bbb_update_test,ccc_update_testgo out)AnnounceFetcherAnnounceBlockTest,AssetOptimizationUmamiTest,ConfigImportAllTest,ContentTranslationConfigUITest,DemoUmamiProfileTest,MediaStandardProfileTest,StandardInstallerTest,StandardRecipeInstallTest,StandardRecipeTest,StandardTest,UmamiMultilingualInstallTest,UninstallDefaultContentTestAnnounceBlockTestshould use its test module's fixtureSecurityAdvisoriesFetcherDbLogTest, fileDeleteTest, fileUsageTest,WorkspaceCRUDTest(kernel tests running cron),StandardInstallerTest,StandardRecipeInstallTest,UmamiMultilingualInstallTestsystem.advisories:enabledby default in tests, enabling it only in the advisories tests that use their local fixtureProviderRepository,ResourceFetcher,OEmbedEntityLinksTest,MediaSourceValidationTest(fetches duringsetUp(), before its mock client is set),ProviderRepositoryTest::testNonExistingProviderDatabase(relies on the real oembed.com returning 404 and oembed1.com not resolving)media_test_oembedfixtures, mock the failing responsesKernelTestBaseTest::testOutboundHttpRequestAll requests were logged in
sites/simpletest/browser_output/external-http-requests.logof each job's artifacts (138 requests across the 14 test jobs).Comment #4
gábor hojtsyOpened #3644177: Tests should not request translations from ftp.drupal.org for locale.
Comment #5
gábor hojtsyComment #6
catchUmamiMultilingualInstallTestdoes a full UI install and checks the update status checkbox to make sure it works, but doesn't test anything else about update status. Assuming we don't want to drop the coverage, I think we need to do something like set a mock local endpoint in a settings.php override, possibly for every functional test so it's a catch-all. If we do that it might require the actual real update status tests to do this in settings.php instead of updating config or similar.Comment #7
gábor hojtsyOpened #3644200: Unintentional announcements and security advisories fetched in tests for the announcement and psa feeds. Proof from the collector looks good :) Fix is simple.
Comment #8
gábor hojtsyOpened #3644236: Tests fetch update status data from updates.drupal.org for the update feed but that is only a small few lines on top of hte announcement/psa issue, so may fold it there.
Comment #9
gábor hojtsyAlso opened #3644258: oEmbed kernel tests fetch from oembed.com and YouTube for oEmbed. And folded the updates issue to the announcements issue.
I believe all found instances of testing the internet are now covered by the 4 issues. Added to the issue summary too:
Comment #10
gábor hojtsyComment #11
gábor hojtsyComment #12
gábor hojtsy