Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug (tests): JSONScript tests fail with "Wikimedia\Services\ContainerDisabledException: Container disabled!" #5637

Open
gesinn-it-gea opened this issue May 5, 2024 · 8 comments
Labels
bug Occurrence of an unintended or unanticipated behaviour that causes a vulnerability or fatal error

Comments

@gesinn-it-gea
Copy link
Member

gesinn-it-gea commented May 5, 2024

EDIT: this issue was created for SemanticDrilldown extension. There:

Steps to reproduce:

  • clone SemanticDrilldown repo
  • git submodule init
  • git submodule update
  • make ci
@gesinn-it-gea gesinn-it-gea added the bug Occurrence of an unintended or unanticipated behaviour that causes a vulnerability or fatal error label May 5, 2024
@gesinn-it-gea
Copy link
Member Author

@hexmode do you have an idea what's causing this?

@hexmode
Copy link
Member

hexmode commented May 5, 2024

This is probably caused because SMW is improperly using MW services. Probably relevant: https://www.mediawiki.org/wiki/Manual:PHP_unit_testing/Writing_unit_tests#Databases

Talking briefly with @tgr at the hackathon, he suggested that a fix may be to have DatabaseTestCase depend on DatabaseIntegrationTest instead of PHPUnit_Framework_TestCase.

@gesinn-it-gea
Copy link
Member Author

@hexmode thanks for your feedback. Maybe we should move this topic to SMW as it is not directly related to SD. @krabina .

@krabina krabina transferred this issue from SemanticMediaWiki/SemanticDrilldown May 5, 2024
@krabina
Copy link
Contributor

krabina commented May 5, 2024

@Nikerabbit can you help us out here? This would be super important so solve!

@gesinn-it-gea
Copy link
Member Author

gesinn-it-gea commented May 5, 2024

In SMW, if you run for example composer phpunit -- --filter 's-0014.json', you get:

Database was excluded and is not expected to support the test

This is caused by function checkIfDatabaseCanBeUsedOtherwiseSkipTest() in tests/phpunit/DatabaseTestCase.php.

@tgr
Copy link
Contributor

tgr commented May 5, 2024

I think you either need to subclass the test from MediWikiIntegratinTestCase or copy some of the setup code in that class.

@hexmode
Copy link
Member

hexmode commented May 7, 2024

I've started a branch that uses MediaWikiIntegrationTestCase and addressed some php 8 deprecations on it. Tests still don't pass, but it is a start.

@hexmode
Copy link
Member

hexmode commented May 7, 2024

The first error, when running the tests on a new install against sqlite is:

Database access has been disabled.
#0 .../includes/libs/rdbms/loadbalancer/LoadBalancer.php(1147): Wikimedia\Rdbms\LoadBalancer->reallyOpenConnection()
#1 .../includes/libs/rdbms/loadbalancer/LoadBalancer.php(967): Wikimedia\Rdbms\LoadBalancer->getLocalConnection()
#2 .../includes/libs/rdbms/loadbalancer/LoadBalancer.php(944): Wikimedia\Rdbms\LoadBalancer->getServerConnection()
#3 .../extensions/SemanticMediaWiki/tests/phpunit/Utils/Connection/TestDatabaseConnectionProvider.php(40): Wikimedia\Rdbms\LoadBalancer->getConnectionInternal()
#4 .../extensions/SemanticMediaWiki/tests/phpunit/Utils/Connection/TestDatabaseTableBuilder.php(141): SMW\Tests\Utils\Connection\TestDatabaseConnectionProvider->getConnection()
#5 .../extensions/SemanticMediaWiki/tests/phpunit/Utils/Connection/TestDatabaseTableBuilder.php(279): SMW\Tests\Utils\Connection\TestDatabaseTableBuilder->getDBConnection()
#6 .../extensions/SemanticMediaWiki/tests/phpunit/Utils/Connection/TestDatabaseTableBuilder.php(110): SMW\Tests\Utils\Connection\TestDatabaseTableBuilder->isAvailableDatabaseType()
#7 .../extensions/SemanticMediaWiki/tests/phpunit/DatabaseTestCase.php(195): SMW\Tests\Utils\Connection\TestDatabaseTableBuilder->doBuild()
#8 .../vendor/phpunit/phpunit/src/Framework/TestSuite.php(626): SMW\Tests\DatabaseTestCase->run()
#9 .../vendor/phpunit/phpunit/src/Framework/TestSuite.php(626): PHPUnit\Framework\TestSuite->run()
#10 .../vendor/phpunit/phpunit/src/Framework/TestSuite.php(626): PHPUnit\Framework\TestSuite->run()
#11 .../vendor/phpunit/phpunit/src/Framework/TestSuite.php(626): PHPUnit\Framework\TestSuite->run()
#12 .../vendor/phpunit/phpunit/src/TextUI/TestRunner.php(645): PHPUnit\Framework\TestSuite->run()
#13 .../vendor/phpunit/phpunit/src/TextUI/Command.php(236): PHPUnit\TextUI\TestRunner->doRun()
#14 .../tests/phpunit/phpunit.php(101): PHPUnit\TextUI\Command->run()
#15 .../tests/phpunit/phpunit.php(153): PHPUnitMaintClass->execute()
#16 {main}

Subsequent runs, though, have a different error and backtrace:

Error 1: index sunittest_smw_object_ids_indexpri already exists
Function: SMW\SQLStore\TableBuilder\SQLiteTableBuilder::doCreateIndex
Query: CREATE UNIQUE INDEX "sunittest_smw_object_ids_indexpri" ON smw_object_ids (smw_id)

#0 .../includes/libs/rdbms/database/Database.php(1602): Wikimedia\Rdbms\Database->getQueryException()
#1 .../includes/libs/rdbms/database/Database.php(1576): Wikimedia\Rdbms\Database->getQueryExceptionAndLog()
#2 .../includes/libs/rdbms/database/Database.php(952): Wikimedia\Rdbms\Database->reportQueryError()
#3 .../includes/libs/rdbms/database/DBConnRef.php(103): Wikimedia\Rdbms\Database->query()
#4 .../includes/libs/rdbms/database/DBConnRef.php(293): Wikimedia\Rdbms\DBConnRef->__call()
#5 .../extensions/SemanticMediaWiki/src/SQLStore/TableBuilder/SQLiteTableBuilder.php(355): Wikimedia\Rdbms\DBConnRef->query()
#6 .../extensions/SemanticMediaWiki/src/SQLStore/TableBuilder/SQLiteTableBuilder.php(294): SMW\SQLStore\TableBuilder\SQLiteTableBuilder->doCreateIndex()
#7 .../extensions/SemanticMediaWiki/src/SQLStore/TableBuilder/TableBuilder.php(169): SMW\SQLStore\TableBuilder\SQLiteTableBuilder->doCreateIndices()
#8 .../extensions/SemanticMediaWiki/src/SQLStore/Installer.php(229): SMW\SQLStore\TableBuilder\TableBuilder->create()
#9 .../extensions/SemanticMediaWiki/src/SQLStore/SQLStore.php(456): SMW\SQLStore\Installer->install()
#10 .../extensions/SemanticMediaWiki/tests/phpunit/Utils/Connection/TestDatabaseTableBuilder.php(196): SMW\SQLStore\SQLStore->setup()
#11 .../extensions/SemanticMediaWiki/tests/phpunit/Utils/Connection/TestDatabaseTableBuilder.php(114): SMW\Tests\Utils\Connection\TestDatabaseTableBuilder->setupDatabaseTables()
#12 .../extensions/SemanticMediaWiki/tests/phpunit/DatabaseTestCase.php(195): SMW\Tests\Utils\Connection\TestDatabaseTableBuilder->doBuild()
#13 .../vendor/phpunit/phpunit/src/Framework/TestSuite.php(626): SMW\Tests\DatabaseTestCase->run()
#14 .../vendor/phpunit/phpunit/src/Framework/TestSuite.php(626): PHPUnit\Framework\TestSuite->run()
#15 .../vendor/phpunit/phpunit/src/Framework/TestSuite.php(626): PHPUnit\Framework\TestSuite->run()
#16 .../vendor/phpunit/phpunit/src/Framework/TestSuite.php(626): PHPUnit\Framework\TestSuite->run()
#17 .../vendor/phpunit/phpunit/src/TextUI/TestRunner.php(645): PHPUnit\Framework\TestSuite->run()
#18 .../vendor/phpunit/phpunit/src/TextUI/Command.php(236): PHPUnit\TextUI\TestRunner->doRun()
#19 .../tests/phpunit/phpunit.php(101): PHPUnit\TextUI\Command->run()
#20 .../tests/phpunit/phpunit.php(153): PHPUnitMaintClass->execute()
#21 {main}

So, we can see that the test runner has DB access initially, tries to set up the temporary unittest schema, and then fails when DB access (the service) is not available. Probably need to look at the set up in DatabaseIntegrationTest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Occurrence of an unintended or unanticipated behaviour that causes a vulnerability or fatal error
Projects
None yet
Development

No branches or pull requests

4 participants