Page MenuHomePhabricator

CategoryChangesAsRdfTest::testCategorization: Failed asserting that two strings are equal.
Closed, ResolvedPublic5 Estimated Story Points

Description

This test is failing in various patches and blocking merge. The test itself seems like it has not been touched for months

https://gerrit.wikimedia.org/r/c/mediawiki/core/+/635910

https://gerrit.wikimedia.org/r/c/mediawiki/core/+/637032

https://gerrit.wikimedia.org/r/c/mediawiki/core/+/637574

https://gerrit.wikimedia.org/r/c/mediawiki/core/+/623837

There was 1 failure:

1) CategoryChangesAsRdfTest::testCategorization
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'# Changes\n
-DELETE {\n
-?category ?x ?y\n
-} WHERE {\n
-   ?category ?x ?y\n
-   VALUES ?category {\n
-     <http://acme.test/wiki/Category:CategoryChangesAsRdfTest_L2> <http://acme.test/wiki/Category:CategoryChangesAsRdfTest_Page> <http://acme.test/wiki/Category:CategoryChangesAsRdfTest_L1>\n
-   }\n
-};\n
-INSERT DATA {\n
-\n
-<http://acme.test/wiki/Category:CategoryChangesAsRdfTest_L2> a mediawiki:Category ;\n
-	rdfs:label "CategoryChangesAsRdfTest L2" ;\n
-	mediawiki:pages "0"^^xsd:integer ;\n
-	mediawiki:subcategories "1"^^xsd:integer .\n
-\n
-<http://acme.test/wiki/Category:CategoryChangesAsRdfTest_Page> a mediawiki:Category ;\n
-	rdfs:label "CategoryChangesAsRdfTest Page" ;\n
-	mediawiki:pages "0"^^xsd:integer ;\n
-	mediawiki:subcategories "0"^^xsd:integer .\n
-\n
-<http://acme.test/wiki/Category:CategoryChangesAsRdfTest_L1> a mediawiki:Category ;\n
-	rdfs:label "CategoryChangesAsRdfTest L1" ;\n
-	mediawiki:pages "0"^^xsd:integer ;\n
-	mediawiki:subcategories "1"^^xsd:integer .\n
-\n
-<http://acme.test/wiki/Category:CategoryChangesAsRdfTest_L2> mediawiki:isInCategory <http://acme.test/wiki/Category:CategoryChangesAsRdfTest_L1> .\n
-\n
-<http://acme.test/wiki/Category:CategoryChangesAsRdfTest_Page> mediawiki:isInCategory <http://acme.test/wiki/Category:CategoryChangesAsRdfTest_L2> .\n
-\n
-};\n
-'
+''

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 29 2020, 11:56 PM
Ammarpad triaged this task as High priority.Oct 29 2020, 11:57 PM
Ammarpad updated the task description. (Show Details)Oct 30 2020, 12:03 AM
Ammarpad updated the task description. (Show Details)Oct 30 2020, 1:19 AM
Jdforrester-WMF raised the priority of this task from High to Unbreak Now!.Oct 30 2020, 3:40 AM
Jdforrester-WMF added a subscriber: Jdforrester-WMF.

Can't merge into MW master -> UBN! status.

The test is flaky. The failure is not db releated as sqlite also failing

On https://gerrit.wikimedia.org/r/c/mediawiki/core/+/637563 the mysql and the sqlite tests were failing

Reedy added a subscriber: Reedy.

Is it worth marking the test as broken in the meantime to unblock other merges?

Is it worth marking the test as broken in the meantime to unblock other merges?

Probably / yes in my opinion

Change 637662 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] CategoryChangesAsRdfTest: Skip testCategorization

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

Change 637662 merged by jenkins-bot:
[mediawiki/core@master] CategoryChangesAsRdfTest: Skip testCategorization

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

Reedy lowered the priority of this task from Unbreak Now! to High.Fri, Oct 30, 4:24 PM
Restricted Application added a project: Wikidata. · View Herald TranscriptFri, Oct 30, 4:39 PM
CBogen set the point value for this task to 5.Mon, Nov 2, 6:30 PM

Change 639932 had a related patch set uploaded (by Tim Starling; owner: DannyS712):
[mediawiki/core@wmf/1.36.0-wmf.14] [1.36.0-wmf.14] CategoryChangesAsRdfTest: Skip testCategorization

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

Change 639932 merged by jenkins-bot:
[mediawiki/core@wmf/1.36.0-wmf.14] [1.36.0-wmf.14] CategoryChangesAsRdfTest: Skip testCategorization

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

By diffing the debug log between successful and failed test runs, I noticed that only the failed runs execute RecentChangesUpdateJob::purgeExpiredRows(). Inserting an unconditional call to this function into the test makes it fail unconditionally:

diff --git a/tests/phpunit/maintenance/categoryChangesAsRdfTest.php b/tests/phpunit/maintenance/categoryChangesAsRdfTest.php
index cb72be9a31..23240d96f8 100644
--- a/tests/phpunit/maintenance/categoryChangesAsRdfTest.php
+++ b/tests/phpunit/maintenance/categoryChangesAsRdfTest.php
@@ -282,6 +282,8 @@ class CategoryChangesAsRdfTest extends MediaWikiLangTestCase {
 		$runJobs->loadParamsAndArgs( null, [ 'quiet' => true, 'maxjobs' => 50 ] );
 		$runJobs->execute();
 
+		RecentChangesUpdateJob::newPurgeJob()->run();
+
 		$dbr = wfGetDB( DB_REPLICA );
 		$categoryChangesAsRdf = new CategoryChangesAsRdf();

The test sets the fake timestamp to 2020-07-31, and so recentchanges rows are inserted with this timestamp, but purgeExpiredRows() does not use the fake timestamp:

$cutoff = $dbw->timestamp( time() - $wgRCMaxAge );

And so the recentchanges rows needed by CategoryChangesAsRdf are deleted.

Instead of using the RunJobs maintenance subclass, I suggest following the example of RevertedTagUpdateIntegrationTest. Call MediaWikiServices::getInstance()->getJobRunner()->run() directly, specifying the types of jobs needed to make the test work.

Change 639958 had a related patch set uploaded (by Tim Starling; owner: Tim Starling):
[mediawiki/core@master] categoryChangesAsRdfTest: Avoid RC purge which randomly breaks the test

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

Change 639958 merged by jenkins-bot:
[mediawiki/core@master] categoryChangesAsRdfTest: Avoid RC purge which randomly breaks the test

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

Gehel closed this task as Resolved.Mon, Nov 23, 1:24 PM