Page MenuHomePhabricator

Use a fake timer in EventBus unit test for PageChangeEventSerializerTest::testCreatePageChangeVisibilityEvent
Closed, ResolvedPublic

Description

A flaky test, a fake timer could help to get the same timestamp at all places
https://integration.wikimedia.org/ci/job/wmf-quibble-vendor-mysql-php81-docker/888/console

00:53:05 There was 1 failure:
00:53:05 
00:53:05 1) PageChangeEventSerializerTest::testCreatePageChangeVisibilityEvent
00:53:05 Failed asserting that two arrays are equal.
00:53:05 --- Expected
00:53:05 +++ Actual
00:53:05 @@ @@
00:53:05      'performer' => Array (...)
00:53:05      'revision' => Array (
00:53:05          'rev_id' => 29
00:53:05 -        'rev_dt' => '2022-12-15T23:43:55Z'
00:53:05 +        'rev_dt' => '2022-12-15T23:43:56Z'
00:53:05          'is_minor_edit' => false
00:53:05          'rev_sha1' => 'aqhji8gcje5j0y511s7kgskw3dd6qua'
00:53:05          'rev_size' => 9
00:53:05 
00:53:05 /workspace/src/extensions/EventBus/tests/phpunit/integration/Serializers/MediaWiki/PageChangeEventSerializerTest.php:189
00:53:05 /workspace/src/extensions/EventBus/tests/phpunit/integration/Serializers/MediaWiki/PageChangeEventSerializerTest.php:540
00:53:05 /workspace/src/tests/phpunit/MediaWikiIntegrationTestCase.php:521

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

In case its impact it's not obvious: This is preventing us to merge patches in many repos without multiple tries.

Hm. The test here isn't relying on two different timers. This rev_dt is from a RevisionRecord provided by MediaWikiIntegrationTestCase's getExistingTestPage:

$wikiPage0 = $this->getExistingTestPage( 'MyPageToChangeVisibility' );

This test case does do

$revisionRecord = MutableRevisionRecord::newUpdatedRevisionRecord(...)

Both the expected value and the tested value are created from this $revisionRecord.

So I wonder if what is happening is that the new newUpdatedRevisionRecord does not have its timestamp set properly. Let's try setting it explicitly...

Change 876259 had a related patch set uploaded (by Ottomata; author: Ottomata):

[mediawiki/extensions/EventBus@master] Set explicit revision timestamp in testCreatePageChangeVisibilityEvent

https://gerrit.wikimedia.org/r/876259

Change 876259 merged by jenkins-bot:

[mediawiki/extensions/EventBus@master] Set explicit revision timestamp in testCreatePageChangeVisibilityEvent

https://gerrit.wikimedia.org/r/876259

Umherirrender assigned this task to Ottomata.

@Ladsgroup @Umherirrender did my change help?

The error was not seen since some weeks, so lets take it as fixed. We can still reopen if needed.
Thanks for the fix!