Page MenuHomePhabricator

Quibble jobs for PHPUnit are missing log artefacts
Closed, ResolvedPublic

Description

The following files are normally collected but seem to no longer be:

  • mw-debug-cli.log.gz
  • mw-ratelimit.log
  • LocalSettings.php
  • LocalSettings-installer.php

These two jobs are for the same patch, and have the same PHPUnit failure:

https://integration.wikimedia.org/ci/job/wmf-quibble-core-vendor-mysql-php72-docker/62378/
https://integration.wikimedia.org/ci/job/mediawiki-quibble-vendor-mysql-php72-docker/53660/
(both builds are preserved)

The "wmf-quibble-core-" job with integrates with all the extensions, is missing these artefacts.
The "mediawiki-quibble-" job with runs cleanly on MediaWiki core only, lacks these artefacts as well.

It seems that on some succesful builds recently, the artefacts do get saved. That is unfortunately not useful since the succesful builds are when we don't need them. Perhaps some logic got flipped?

Event Timeline

Krinkle renamed this task from mediawiki-quibble- jobs for PHPUnit are missing log artefacts to Quibble jobs for PHPUnit are missing log artefacts.Sep 16 2021, 11:01 PM
Krinkle updated the task description. (Show Details)

Note that T285335: Unable to view mw-debug log in Jenkins is also still broken, so they're not viewable by most people even when they do get collected. There's a number of mysterious CI failures building up in code review backlogs due to this.

thcipriani added subscribers: hashar, thcipriani.

@hashar could this be explained by any recent changes to jobs or jenkins upgrades?

Both jobs fail during the PHPUnit unit tests which happens before installing MediaWiki and there is thus no LocalSettings.php, include/DevelopmentSettings.php. The custom logging is thus not enabled and there is no artifacts.

The phase invokes composer run phpunit:unit which is phpunit --colors=always --testsuite=core:unit,extensions:unit,skins:unit". The phpunit.xml.dist uses a bootstrapping file tests/phpunit/bootstrap.php which does thing such as:

wfRequireOnceInGlobalScope( "$IP/includes/AutoLoader.php" );
wfRequireOnceInGlobalScope( "$IP/tests/common/TestsAutoLoader.php" );
wfRequireOnceInGlobalScope( "$IP/includes/Defines.php" );
wfRequireOnceInGlobalScope( "$IP/includes/DefaultSettings.php" );
wfRequireOnceInGlobalScope( "$IP/includes/GlobalFunctions.php" );

So maybe we can include DevelopmentSettings.php ? @kostajh would surely be of good help on that front since he introduced the pure unit testing iirc.

Change 723989 had a related patch set uploaded (by Hashar; author: Hashar):

[mediawiki/core@master] Add DevelopmentSettings to PHPUnit unit tests

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

Both jobs fail during the PHPUnit unit tests which happens before installing MediaWiki and there is thus no LocalSettings.php, include/DevelopmentSettings.php. The custom logging is thus not enabled and there is no artifacts.

The phase invokes composer run phpunit:unit which is phpunit --colors=always --testsuite=core:unit,extensions:unit,skins:unit". The phpunit.xml.dist uses a bootstrapping file tests/phpunit/bootstrap.php which does thing such as:

wfRequireOnceInGlobalScope( "$IP/includes/AutoLoader.php" );
wfRequireOnceInGlobalScope( "$IP/tests/common/TestsAutoLoader.php" );
wfRequireOnceInGlobalScope( "$IP/includes/Defines.php" );
wfRequireOnceInGlobalScope( "$IP/includes/DefaultSettings.php" );
wfRequireOnceInGlobalScope( "$IP/includes/GlobalFunctions.php" );

So maybe we can include DevelopmentSettings.php ? @kostajh would surely be of good help on that front since he introduced the pure unit testing iirc.

Seems fine to do, but I still don't see those log files in a patch added on top of https://gerrit.wikimedia.org/r/c/mediawiki/core/+/723989

I have adjusted my patch to inject $wgDebugLog and $wgDebugLogGroup which is required by the LegacyLogger. I have rebased your failing change and it does have a mw-debug-cli.log file captured!

I have adjusted my patch to inject $wgDebugLog and $wgDebugLogGroup which is required by the LegacyLogger. I have rebased your failing change and it does have a mw-debug-cli.log file captured!

Thanks @hashar & @Krinkle! +2'ed the patch.

Change 723989 merged by jenkins-bot:

[mediawiki/core@master] phpunit: Include DevelopmentSettings for `composer phpunit:unit`

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

The patch work, though I don't really like how the logging stack depends on the MediaWikiUnitTestCase to pass $wgDebugLogFile and $wgDebugLogGroups. So I might complete this work by crafting an ad hoc logging configuration via $wgMwLoggerDefaultSpi. So far I went with the config below, I will see whether I can further tune it this week and craft a patch based on that.

tests/phpunit/bootstrap.php
$GLOBALS['wgMWLoggerDefaultSpi'] = [
	'class' => \MediaWiki\Logger\MonologSpi::class,
	'args'  => [ [
		'loggers' => [
			'@default' => [
				'processors' => ['psr'],
				'handlers' => [ 'errors', 'stream' ],
			],
			'DBConnection' => [
				'handlers' => [ 'errors', 'db_stream' ],
			],
			'DBQuery'      => [
				'handlers' => [ 'errors', 'db_stream' ],
			],
		],
		'processors' => [
			'psr' => [
				'class' => \Monolog\Processor\PsrLogMessageProcessor::class,
			],
		],
		'handlers' => [
			'stream' => [
				'class' => \MediaWiki\Logger\Monolog\LegacyHandler::class,
				'args' => [ '/home/hashar/projects/mediawiki/core/log/debug.log' ],
				'formatter' => 'line',
			],
			'db_stream' => [
				'class' => \MediaWiki\Logger\Monolog\LegacyHandler::class,
				'args' => [ '/home/hashar/projects/mediawiki/core/log/db.log' ],
				'formatter' => 'line',
			],
			'errors' => [
				'class' => \MediaWiki\Logger\Monolog\LegacyHandler::class,
				'args' => [
					'/home/hashar/projects/mediawiki/core/log/errors.log',
					\Monolog\Logger::ERROR,
				],
				'formatter' => 'line',
			],
		],
		'formatters' => [
			'line' => [
				'class' => \Monolog\Formatter\LineFormatter::class,
			],
		],
	] ],
];

Change 725718 had a related patch set uploaded (by Hashar; author: Hashar):

[mediawiki/core@master] tests: add logging SPI for unit tests

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

Change 725718 abandoned by Hashar:

[mediawiki/core@master] tests: add logging SPI for unit tests

Reason:

My intent was to stop having to pass $wgDebugLogFile / $wgDebugLogGroups to the unit test and to explore the Monolog configuration. So it was merely an exploration as to whether we could drop the old $wgDBLog or the legacy logger that depends on globals.

Then as stated, $wgDebugLogFile is well know, it is a simple feature switch and it is super easy for developers. On second thought it is probably not worth the added complexity, unless we had a project to entirely remove the old LegacyLogger. Moreover something breaks when running CI for some reason.

Abandoning since it was merely an experiment. Thank you Timo for the review!

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