Page MenuHomePhabricator

CI failure: Tests should not try to make live requests in tests but use MockHttpTrait instead
Closed, DuplicatePublic

Description

While working on a test on the Wikibase repo, we encountered two suddenly and unrelatedly failing tests on CI with the same error message (Jekins logs). There error message makes this seem to be related to T262443: Do not hit actual urls during phpunit tests.

The first one is in WikimediaEvents: WikimediaEvents\Tests\PageViewsTest::testLog:

00:18:07.575 1) WikimediaEvents\Tests\PageViewsTest::testLog
00:18:07.575 HTTP request blocked: https://meta.wikimedia.org/w/api.php?action=jsonschema&revid=18910134&formatversion=2&format=json by RemoteSchema::httpGet. Use MockHttpTrait.
00:18:07.576 
00:18:07.576 /workspace/src/tests/phpunit/mocks/NullHttpRequestFactory.php:43
00:18:07.576 /workspace/src/includes/http/HttpRequestFactory.php:189
00:18:07.576 /workspace/src/includes/http/HttpRequestFactory.php:212
00:18:07.576 /workspace/src/extensions/EventLogging/includes/RemoteSchema.php:108
00:18:07.576 /workspace/src/extensions/EventLogging/includes/RemoteSchema.php:57
00:18:07.576 /workspace/src/extensions/EventLogging/includes/EventLogging.php:191
00:18:07.576 /workspace/src/extensions/EventLogging/includes/EventLogging.php:84
00:18:07.576 /workspace/src/extensions/WikimediaEvents/includes/PageViews.php:229
00:18:07.576 /workspace/src/extensions/WikimediaEvents/tests/phpunit/PageViewsTest.php:489
00:18:07.576 /workspace/src/tests/phpunit/MediaWikiIntegrationTestCase.php:437
00:18:07.576 /workspace/src/maintenance/doMaintenance.php:106

I'm adding Growth-Team and @kostajh / @Catrope for this.

The second one is one of our Wikibase client tests Wikibase\Client\Tests\Integration\Hooks\EchoNotificationsHandlersTest::testWikibaseHandleChange, which is an old test as well:

00:18:07.576 2) Wikibase\Client\Tests\Integration\Hooks\EchoNotificationsHandlersTest::testWikibaseHandleChange
00:18:07.576 HTTP request blocked: https://meta.wikimedia.org/w/api.php?action=jsonschema&revid=14208837&formatversion=2&format=json by RemoteSchema::httpGet. Use MockHttpTrait.
00:18:07.608 
00:18:07.608 /workspace/src/tests/phpunit/mocks/NullHttpRequestFactory.php:43
00:18:07.608 /workspace/src/includes/http/HttpRequestFactory.php:189
00:18:07.608 /workspace/src/includes/http/HttpRequestFactory.php:212
00:18:07.608 /workspace/src/extensions/EventLogging/includes/RemoteSchema.php:108
00:18:07.608 /workspace/src/extensions/EventLogging/includes/RemoteSchema.php:57
00:18:07.608 /workspace/src/extensions/EventLogging/includes/EventLogging.php:191
00:18:07.608 /workspace/src/extensions/EventLogging/includes/EventLogging.php:84
00:18:07.608 /workspace/src/extensions/WikimediaEvents/includes/WikimediaEventsHooks.php:299
00:18:07.608 /workspace/src/includes/deferred/MWCallableUpdate.php:38
00:18:07.608 /workspace/src/includes/deferred/DeferredUpdates.php:467
00:18:07.608 /workspace/src/includes/deferred/DeferredUpdates.php:344
00:18:07.608 /workspace/src/includes/deferred/DeferredUpdates.php:278
00:18:07.608 /workspace/src/includes/deferred/DeferredUpdates.php:194
00:18:07.608 /workspace/src/includes/deferred/DeferredUpdates.php:491
00:18:07.608 /workspace/src/maintenance/includes/Maintenance.php:698
00:18:07.608 /workspace/src/includes/libs/rdbms/database/Database.php:4241
00:18:07.608 /workspace/src/includes/libs/rdbms/database/Database.php:4610
00:18:07.608 /workspace/src/includes/libs/rdbms/database/Database.php:4371
00:18:07.608 /workspace/src/includes/libs/rdbms/database/DBConnRef.php:68
00:18:07.608 /workspace/src/includes/libs/rdbms/database/DBConnRef.php:629
00:18:07.608 /workspace/src/includes/Storage/PageUpdater.php:1132
00:18:07.608 /workspace/src/includes/Storage/PageUpdater.php:801
00:18:07.608 /workspace/src/includes/page/WikiPage.php:1964
00:18:07.608 /workspace/src/tests/phpunit/MediaWikiIntegrationTestCase.php:1354
00:18:07.609 /workspace/src/extensions/Wikibase/client/tests/phpunit/integration/includes/Hooks/EchoNotificationsHandlersTest.php:171
00:18:07.609 /workspace/src/tests/phpunit/MediaWikiIntegrationTestCase.php:437
00:18:07.609 /workspace/src/maintenance/doMaintenance.php:106

acceptance criteria

  • CI no longer fails on those tests
  • either fix them properly now or create a ticket to look into it later together with our normal maintenance work

open questions

  • Why has this started to fail only now? 632825 was merged in October 2020