Page MenuHomePhabricator

Failure in MoveLogEntriesFromCuChangesTest unit test in CheckUser due to timestamp mismatch
Closed, ResolvedPublic

Description

Flaky test on gate-and-submit seen under https://integration.wikimedia.org/ci/job/wmf-quibble-core-vendor-mysql-php81-docker/6519/console

1) MediaWiki\CheckUser\Tests\Unit\Maintenance\MoveLogEntriesFromCuChangesTest::testMoveLogEntriesFromCuChanges with data set "Two delete batches with one item to move" (1, 2, 100, array(array(array(1, 0, 'Test', 2, 'Testing', 2, 3, '20231223200736', '127.0.0.1', '7F000001', '1.2.3.4', '01020304', 'Testing', '')), array()), array(array(array('20231223200737', 0, 'Test', 2, 3, 'migrated-cu_changes-log-event', 'checkuser-private-event', 'a:1:{s:13:"4::actiontext";s:7...ing";}', 2, '127.0.0.1', '7F000001', '1.2.3.4', '01020304', 'Testing', '')), array()), array(array(1, 100), array(100, 199)))
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
     0 => 'cu_private_event'
     1 => Array &1 (
         0 => Array &2 (
-            'cupe_timestamp' => '20231223200737'
+            'cupe_timestamp' => '20231223200736'
             'cupe_namespace' => 0
             'cupe_title' => 'Test'
             'cupe_actor' => 2

/workspace/src/extensions/CheckUser/tests/phpunit/unit/maintenance/MoveLogEntriesFromCuChangesTest.php:212
/workspace/src/includes/libs/rdbms/querybuilder/InsertQueryBuilder.php:343
/workspace/src/extensions/CheckUser/maintenance/moveLogEntriesFromCuChanges.php:152
/workspace/src/vendor/wikimedia/testing-access-wrapper/src/TestingAccessWrapper.php:114
/workspace/src/extensions/CheckUser/tests/phpunit/unit/maintenance/MoveLogEntriesFromCuChangesTest.php:233
/workspace/src/tests/phpunit/MediaWikiUnitTestCase.php:127

The idea to use a fake timer in 739438ff does not work as the timestamp is taken in the @dataProvider, which is called before the setUp.
Just pin the timestamp in the expected data, as unit test there is no database involved, no extra call to the timestamp.

Event Timeline

Change 986195 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/extensions/CheckUser@master] tests: Avoid timestamp mismatch in MoveLogEntriesFromCuChangesTest

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

Change 986195 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@master] tests: Avoid timestamp mismatch in MoveLogEntriesFromCuChangesTest

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