Page MenuHomePhabricator

Build failures from Wikibase\Repo\Tests\ChangeModification\DispatchChangeVisibilityNotificationJobTest::testHandle and Wikibase\Lib\Tests\Store\Sql\SqlChangeStoreTest::testSaveChange_insert
Closed, ResolvedPublicBUG REPORT

Description

These failing tests from Wikibase are preventing merges in mediawiki/core and other repos:

23:50:47 There were 7 failures:
23:50:47 
23:50:47 1) Wikibase\Repo\Tests\ChangeModification\DispatchChangeVisibilityNotificationJobTest::testHandle with data set "One job with one revision identifier dispatched" (array(array('[{"arrayFormatVersion":1,"ent...":12}]', 1)), array(12), array(array(1, 0)))
23:50:47 jobs for dummywiki
23:50:47 Failed asserting that array contains the expected submap.
23:50:47 --- Expected
23:50:47 +++ Actual
23:50:47 @@ @@
23:50:47  array (
23:50:47 -  0 => 
23:50:47 -  array (
23:50:47 -    'revisionIdentifiersJson' => '[{"arrayFormatVersion":1,"entityIdSerialization":"Q1042","revisionTimestamp":"20230504030201","revisionId":12}]',
23:50:47 -    'visibilityBitFlag' => 1,
23:50:47 -  ),
23:50:47  )
23:50:47 
23:50:47 /workspace/src/tests/phpunit/MediaWikiTestCaseTrait.php:252
23:50:47 /workspace/src/extensions/Wikibase/repo/tests/phpunit/includes/ChangeModification/DispatchChangeVisibilityNotificationJobTest.php:206
23:50:47 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:106
Logs generated by test

Show Details
23:50:47 
23:50:47 2) Wikibase\Repo\Tests\ChangeModification\DispatchChangeVisibilityNotificationJobTest::testHandle with data set "One job with two revision identifiers dispatched" (array(array('[{"arrayFormatVersion":1,"ent...":13}]', 1)), array(12, 13), array(array(1, 0), array(1, 474)))
23:50:47 jobs for dummywiki
23:50:47 Failed asserting that array contains the expected submap.
23:50:47 --- Expected
23:50:47 +++ Actual
23:50:47 @@ @@
23:50:47  array (
23:50:47 -  0 => 
23:50:47 -  array (
23:50:47 -    'revisionIdentifiersJson' => '[{"arrayFormatVersion":1,"entityIdSerialization":"Q1042","revisionTimestamp":"20230504030201","revisionId":12},{"arrayFormatVersion":1,"entityIdSerialization":"Q1042","revisionTimestamp":"20230504030201","revisionId":13}]',
23:50:47 -    'visibilityBitFlag' => 1,
23:50:47 -  ),
23:50:47  )
23:50:47 
23:50:47 /workspace/src/tests/phpunit/MediaWikiTestCaseTrait.php:252
23:50:47 /workspace/src/extensions/Wikibase/repo/tests/phpunit/includes/ChangeModification/DispatchChangeVisibilityNotificationJobTest.php:206
23:50:47 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:106
Logs generated by test

Show Details
23:50:47 
23:50:47 3) Wikibase\Repo\Tests\ChangeModification\DispatchChangeVisibilityNotificationJobTest::testHandle with data set "Two jobs dispatched (different bit flags)" (array(array('[{"arrayFormatVersion":1,"ent...":12}]', 1), array('[{"arrayFormatVersion":1,"ent...":13}]', 6)), array(12, 13), array(array(1, 0), array(6, 2)))
23:50:47 jobs for dummywiki
23:50:47 Failed asserting that array contains the expected submap.
23:50:47 --- Expected
23:50:47 +++ Actual
23:50:47 @@ @@
23:50:47  array (
23:50:47 -  0 => 
23:50:47 -  array (
23:50:47 -    'revisionIdentifiersJson' => '[{"arrayFormatVersion":1,"entityIdSerialization":"Q1042","revisionTimestamp":"20230504030201","revisionId":12}]',
23:50:47 -    'visibilityBitFlag' => 1,
23:50:47 -  ),
23:50:47 -  1 => 
23:50:47 -  array (
23:50:47 -    'revisionIdentifiersJson' => '[{"arrayFormatVersion":1,"entityIdSerialization":"Q1042","revisionTimestamp":"20230504030201","revisionId":13}]',
23:50:47 -    'visibilityBitFlag' => 6,
23:50:47 -  ),
23:50:47  )
23:50:47 
23:50:47 /workspace/src/tests/phpunit/MediaWikiTestCaseTrait.php:252
23:50:47 /workspace/src/extensions/Wikibase/repo/tests/phpunit/includes/ChangeModification/DispatchChangeVisibilityNotificationJobTest.php:206
23:50:47 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:106
Logs generated by test

Show Details
23:50:47 
23:50:47 4) Wikibase\Repo\Tests\ChangeModification\DispatchChangeVisibilityNotificationJobTest::testHandle with data set "Two jobs dispatched (small batch size)" (array(array('[{"arrayFormatVersion":1,"ent...":13}]', 1), array('[{"arrayFormatVersion":1,"ent...":14}]', 1)), array(12, 13, 14), array(array(1, 0), array(1, 2), array(1, 99)), 2)
23:50:47 jobs for dummywiki
23:50:47 Failed asserting that array contains the expected submap.
23:50:47 --- Expected
23:50:47 +++ Actual
23:50:47 @@ @@
23:50:47  array (
23:50:47 -  0 => 
23:50:47 -  array (
23:50:47 -    'revisionIdentifiersJson' => '[{"arrayFormatVersion":1,"entityIdSerialization":"Q1042","revisionTimestamp":"20230504030201","revisionId":12},{"arrayFormatVersion":1,"entityIdSerialization":"Q1042","revisionTimestamp":"20230504030201","revisionId":13}]',
23:50:47 -    'visibilityBitFlag' => 1,
23:50:47 -  ),
23:50:47 -  1 => 
23:50:47 -  array (
23:50:47 -    'revisionIdentifiersJson' => '[{"arrayFormatVersion":1,"entityIdSerialization":"Q1042","revisionTimestamp":"20230504030201","revisionId":14}]',
23:50:47 -    'visibilityBitFlag' => 1,
23:50:47 -  ),
23:50:47  )
23:50:47 
23:50:47 /workspace/src/tests/phpunit/MediaWikiTestCaseTrait.php:252
23:50:47 /workspace/src/extensions/Wikibase/repo/tests/phpunit/includes/ChangeModification/DispatchChangeVisibilityNotificationJobTest.php:206
23:50:47 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:106
Logs generated by test

Show Details
23:50:47 
23:50:47 5) Wikibase\Repo\Tests\ChangeModification\DispatchChangeVisibilityNotificationJobTest::testHandle with data set "Multiple jobs with multiple revisions dispatched" (array(array('[{"arrayFormatVersion":1,"ent...":14}]', 1), array('[{"arrayFormatVersion":1,"ent...":13}]', 6)), array(12, 13, 14), array(array(1, 0), array(6, 2), array(1, 99)))
23:50:47 jobs for dummywiki
23:50:47 Failed asserting that array contains the expected submap.
23:50:47 --- Expected
23:50:47 +++ Actual
23:50:47 @@ @@
23:50:47  array (
23:50:47 -  0 => 
23:50:47 -  array (
23:50:47 -    'revisionIdentifiersJson' => '[{"arrayFormatVersion":1,"entityIdSerialization":"Q1042","revisionTimestamp":"20230504030201","revisionId":12},{"arrayFormatVersion":1,"entityIdSerialization":"Q1042","revisionTimestamp":"20230504030201","revisionId":14}]',
23:50:47 -    'visibilityBitFlag' => 1,
23:50:47 -  ),
23:50:47 -  1 => 
23:50:47 -  array (
23:50:47 -    'revisionIdentifiersJson' => '[{"arrayFormatVersion":1,"entityIdSerialization":"Q1042","revisionTimestamp":"20230504030201","revisionId":13}]',
23:50:47 -    'visibilityBitFlag' => 6,
23:50:47 -  ),
23:50:47  )
23:50:47 
23:50:47 /workspace/src/tests/phpunit/MediaWikiTestCaseTrait.php:252
23:50:47 /workspace/src/extensions/Wikibase/repo/tests/phpunit/includes/ChangeModification/DispatchChangeVisibilityNotificationJobTest.php:206
23:50:47 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:106
Logs generated by test

Show Details
23:50:47 
23:50:47 6) Wikibase\Repo\Tests\ChangeModification\DispatchChangeVisibilityNotificationJobTest::testHandle with data set "One job dispatched, some revisions discarded" (array(array('[{"arrayFormatVersion":1,"ent...":12}]', 1)), array(404, 12, 408), array(array(1, 0), array(1, 0), array(1, 2)))
23:50:47 jobs for dummywiki
23:50:47 Failed asserting that array contains the expected submap.
23:50:47 --- Expected
23:50:47 +++ Actual
23:50:47 @@ @@
23:50:47  array (
23:50:47 -  0 => 
23:50:47 -  array (
23:50:47 -    'revisionIdentifiersJson' => '[{"arrayFormatVersion":1,"entityIdSerialization":"Q1042","revisionTimestamp":"20230504030201","revisionId":12}]',
23:50:47 -    'visibilityBitFlag' => 1,
23:50:47 -  ),
23:50:47  )
23:50:47 
23:50:47 /workspace/src/tests/phpunit/MediaWikiTestCaseTrait.php:252
23:50:47 /workspace/src/extensions/Wikibase/repo/tests/phpunit/includes/ChangeModification/DispatchChangeVisibilityNotificationJobTest.php:206
23:50:47 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:106
Logs generated by test

Show Details
23:50:47 
23:50:47 7) Wikibase\Lib\Tests\Store\Sql\SqlChangeStoreTest::testSaveChange_insert with data set "Simple change" (array('wikibase-item~add', '20230504030201', 'Q21389475', '0', '0', '[]'), Wikibase\Lib\Changes\ItemChange Object (...))
23:50:47 Change time
23:50:47 Failed asserting that 1722376144 matches expected 1683169321.
23:50:47 
23:50:47 /workspace/src/extensions/Wikibase/lib/tests/phpunit/Store/Sql/SqlChangeStoreTest.php:136
23:50:47 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:106
Logs generated by test

Show Details
23:50:47 
23:50:47 FAILURES!
23:50:47 Tests: 15016, Assertions: 63141, Failures: 7, Skipped: 140.

Example failing changes:

Event Timeline

matmarex triaged this task as Unbreak Now! priority.Jul 31 2024, 9:01 AM

This is also the case in CI for wmf branches.

So far I can’t reproduce this locally (neither repo/tests/phpunit/includes/ChangeModification/DispatchChangeVisibilityNotificationJobTest.php nor lib/tests/phpunit/Store/Sql/SqlChangeStoreTest.php), even after updating core and Wikibase locally. I guess I need to look closer at the test and see if I can figure out which other extension might be related…

Change #1058569 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] DNM: Empty change to test CI

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

Show Details
23:50:47 
23:50:47 7) Wikibase\Lib\Tests\Store\Sql\SqlChangeStoreTest::testSaveChange_insert with data set "Simple change" (array('wikibase-item~add', '20230504030201', 'Q21389475', '0', '0', '[]'), Wikibase\Lib\Changes\ItemChange Object (...))
23:50:47 Change time
23:50:47 Failed asserting that 1722376144 matches expected 1683169321.
23:50:47 
23:50:47 /workspace/src/extensions/Wikibase/lib/tests/phpunit/Store/Sql/SqlChangeStoreTest.php:136
23:50:47 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:106

I don’t know where this was copy+pasted from, but this build has the same test fail with different timestamps (even ignoring time zones):

11:07:59 7) Wikibase\Lib\Tests\Store\Sql\SqlChangeStoreTest::testSaveChange_insert with data set "Simple change" (array('wikibase-item~add', '20230504030201', 'Q21389475', '0', '0', '[]'), Wikibase\Lib\Changes\ItemChange Object (...))
11:07:59 Change time
11:07:59 Failed asserting that 1722416751 matches expected 1683169321.

Note that the expected timestamp is identical, though the actual one isn’t. The actual timestamp seems to be the real time when the test runs (see date -d @1722416751); the “expected” timestamp is a seemingly random time in 2023-05-04.

I put “expected” in scare quotes because this test doesn’t really expect a particular timestamp, it initializes it with the current time:

SqlChangeStoreTest
	public function saveChangeInsertProvider() {
		$factory = $this->getEntityChangeFactory();

		$time = wfTimestamp( TS_MW );

		# ...

		return [
			'Simple change' => [
				[
					'change_type' => 'wikibase-item~add',
					'change_time' => $time,
		# ...

I think something must be calling ConvertibleTimestamp::setFakeTime() (which affects wfTimestamp()) and not properly resetting it? And I think that could potentially explain the other test failure too – something in change dispatching might be discarding a change that looks like it’s too old.

Okay, gotta be MediaModeration. (I needed to codesearch for the timestamp without dashes.)

$ TZ=UTC date -d @1683169321
Do 4. Mai 03:02:01 UTC 2023
ScanFilesInScanTableTest (a few other files also use this timestamp)
	public function testParseLastCheckedTimestamp( $lastCheckedOptionValue, $expectedLastChecked ) {
		// Fix the current time as the method under test calls ConvertibleTimestamp::time.
		ConvertibleTimestamp::setFakeTime( '20230504030201' );

Okay, I can reproduce it locally with:

diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 863277be2a..aa1b2c6c3c 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -23,6 +23,10 @@
 		<ini name="max_execution_time" value="0" />
 	</php>
 	<testsuites>
+		<testsuite name="T371460">
+			<file>extensions/MediaModeration/tests/phpunit/unit/maintenance/ScanFilesInScanTableTest.php</file>
+			<file>extensions/Wikibase/lib/tests/phpunit/Store/Sql/SqlChangeStoreTest.php</file>
+		</testsuite>
 		<testsuite name="core:unit">
 			<directory>tests/phpunit/unit</directory>
 		</testsuite>
composer run phpunit:entrypoint -- --testsuite T371460

Change #1058572 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/MediaModeration@master] Don’t call setFakeTime() in data provider

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

It turns out ScanFilesInScanTableTest.php calls setFakeTime() in a data provider, thus also setting the fake time for all other data providers. (setFakeTime() calls in the actual test function are “protected” by MediaWikiTestCaseTrait::fakeTimestampTearDown() automatically running after every test, but data providers don’t have that; see also T332865: PHPUnit data providers should be simple static functions that return plain data.)

Apparently the problematic setFakeTime() call has been there since December 2023, so I guess the immediate cause for this bug task is Add MediaModeration to the gated extensions list (T371324).

Change #1058569 abandoned by Lucas Werkmeister (WMDE):

[mediawiki/extensions/Wikibase@master] DNM: Empty change to test CI

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

Change #1058572 merged by jenkins-bot:

[mediawiki/extensions/MediaModeration@master] Don’t call setFakeTime() in data provider

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

CI is fixed AFAICT; I think if we want to follow-up by forbidding setFakeTime() in data providers in general, we should have a separate task for that.