silverstripe / silverstripe-sqlite3

SQLite3 DB Adapter for Silverstripe
BSD 3-Clause "New" or "Revised" License
8 stars 19 forks source link

Transactions break the ability to run tests #48

Closed NightJar closed 5 years ago

NightJar commented 6 years ago

Tests cannot be run any more, presumably since the transactional changes for silverstripe/framework 4.2.0

SilverStripe\SQLite\SQLite3Database does not support transactionDepth

/srv/html/vendor/silverstripe/framework/src/ORM/Connect/Database.php:680
/srv/html/vendor/silverstripe/framework/src/ORM/Connect/TempDatabase.php:101
/srv/html/vendor/silverstripe/framework/src/ORM/Connect/TempDatabase.php:127
/srv/html/vendor/silverstripe/framework/src/Dev/State/FixtureTestState.php:95
/srv/html/vendor/silverstripe/framework/src/Dev/State/SapphireTestState.php:77
/srv/html/vendor/silverstripe/framework/src/Dev/SapphireTest.php:579

ERRORS!

Tests: 1, Assertions: 7, Errors: 1.
PHP Warning:  SilverStripe\SQLite\SQLite3Database does not support transactionDepth in /srv/html/vendor/silverstripe/framework/src/ORM/Connect/Database.php on line 680

Although on testing protected $usesTransactions = false; the issue seems to persist.

dhensby commented 6 years ago

Does it work with 2.x-dev? we may need a new release :)

NightJar commented 6 years ago

Hmm, a fair point. It was late at night so I didn't think to consider installed versions. I'll report back with more detail.

NightJar commented 5 years ago

Running over silverstripe/installer as at a clone of 15 minutes ago...

2.1.1:

ERRORS!
Tests: 8542, Assertions: 6472, Errors: 1269, Failures: 21, Skipped: 17, Incomplete: 3.

2.x-dev:

ERRORS!
Tests: 3052, Assertions: 10508, Errors: 273, Failures: 26, Skipped: 48, Incomplete: 3.

Not fixed, but better. Although one would note the alarming differences in the totals there... (considering the version of silverstripe/sqlite3 is the only difference)


This is new though:

267) SilverStripe\Security\Tests\SecurityTest::testDatabaseIsReadyWithInsufficientMemberColumns
SilverStripe\ORM\Connect\DatabaseException: Couldn't run query:

BEGIN TRANSACTION;

cannot start a transaction within a transaction
NightJar commented 5 years ago

:thinking:

$ vendor/bin/phpunit -d memory_limit=512M vendor/silverstripe/framework/tests/php/
[...]
Time: 5.27 minutes, Memory: 170.25MB

There were 7 errors:
[...]
3) SilverStripe\ORM\Tests\DataObjectTest::testDb
SilverStripe\ORM\Connect\DatabaseException: Couldn't run query:

BEGIN

cannot start a transaction within a transaction
[...]

But...

$ vendor/bin/phpunit -d memory_limit=512M vendor/silverstripe/framework/tests/php/ORM/DataObjectTest --filter testDb
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.

.                                                                   1 / 1 (100%)

Time: 3.32 seconds, Memory: 70.00MB

OK (1 test, 16 assertions)

Seems like something isn't committing correctly.


Upside - 6/7 are all in the ORM suite. The other isn't a DB error. Downside - even running the full DataObjectTest suite isn't sufficient to trigger the issue, gotta run the full ORM suite.

NightJar commented 5 years ago

Neat, recreation invocation: $ vendor/bin/phpunit -v --stop-on-error -d memory_limit=512M vendor/silverstripe/framework/tests/php/ORM/ --filter 'Extra|Extension' Whatever runs after the ManyManyListTest suite will fail, and it is because the transaction count is out (a transaction appears to be open, but the count is 0).

NightJar commented 5 years ago

Allowing for the different ways transactions function between MySQL and SQLite has seen functionality restored in #51