"Too many connections" using PHPUnit for testing Laravel 4 on CircleCI
This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.
Starting to get a big test suite here on one of our projects, and our CI tool CircleCI just threw a wonky towards the end of the game because the database was refusing any more connections. Clearly an issue with the max_connections
setting for MySQL (or whatever database you might be using). Unfortunately, I couldn't find a way to easily adjust this setting in our CircleCI testing environment. However, there is another way - simply close the database connection after each test. It adds a tiny bit of overhead to your testing, but hey, whatever gets the job done.
In your app/tests/TestCase.php
add the following:
EDIT: Just got word from CircleCI with details on how to up the max_connections
and it's super simple with this command (thanks Gordon!):
EDIT 2: I've now written another post about solving the “too many connections” issue when testing Laravel 5.1.