Nimut / testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests
GNU General Public License v2.0
52 stars 25 forks source link

Do not spill databases #124

Closed mk-mxp closed 4 years ago

mk-mxp commented 4 years ago

This is not a problem when running tests on Travis CI or another throw-away DB service, but for testing using a non-disposible MySQL instance (especially with shared instances).

A) The DB-user used for testing requires the right to create databases and self-grant all rights to it. By this, the user is root-like. This is inacceptible in shared DB instances and a risk to any other data stored in any DB on that instance.

B) For each test using the DB the framework creates a new DB copy with a random suffix:

mysql> show databases;
+----------------------+
| Database             |
+----------------------+
| information_schema   |
| mysql                |
| performance_schema   |
| typo3                |
| typo3_ft1d226aa      |
| typo3_ft53009df      |
| typo3_ft7054112      |
| typo3_ft9def141      |
| typo3_fta832130      |
| typo3_ftb9be75b      |
| typo3_ftc3170a5      |
| typo3_ftc799e14      |
| typo3_ftdcc4980      |
+----------------------+

And it never cleans up afterwards. Using random names makes it very annoying to cleanup manually.

helhum commented 4 years ago

I'm sorry you're annoyed by using this framework. I was created with best intention and as a fork of the TYPO3 Testing framework with specific support for multiple TYPO3 versions. In general though, it works exactly like the original framework we forked. While I agree this isn't too nice to create many databases for functional tests, changing that would mean re-creating everything from scratch with a different concept in mind. This isn't and will not be our priority with this package.

As workaround I can only recommend to use existing technology to create "disposable" database services for executing the tests, being it a local docker container or on a CI system like Gitlab CI. This framework in not designed to run tests on a production system (e.g. before a deployment).