- Do you do continuous integration?
- Do you use sqlite for your tests while deploying against postgresql?
- Do you hate using sqlite for your tests?
If you answer 'yes' to any of those three questions, the following post is for you.
Otherwise, well, stay, it might still be interesting ;-)
When doing unit-tests you want to have something fast which allows you to quickly see if your last changes affect other part of your code.
sqlite is great for that. You can easily create in memory database, no FileIO, it all goes fast and smooth.
That is until you push your application to production where it is deployed against a real database system such as PostgreSQL. Then suddenly, queries which run fine under sqlite start breaking under PostgreSQL.
sqlite and PostgreSQL implements some things differently and this leads to this kind of situation.
The solution for this is of course to run your tests in an environment as close as possible from the production on, ie: run your tests on the same database system as the one you use on production.
But this can also become complex, it means setting up a new database server, create a new database, clean the database after the tests, handle permissions...
With this in mind, project such as postgression appeared.
The idea is simple: easily get access to postgresql databases which are thrown away after a certain time.
The problem is that postgression is not FOSS, thus when a couple of weeks ago there was no way to get a database, there was also no way to set up our own postgression server that could be used by a restricted number of person.
So after discussing it with Aurélien, somewhere between lunch and dessert, faitout appeared.
The idea was simple, have a small web application, create on the fly a user and a database made available to the on who asks and after 30 minutes (via a cron job for the moment) destroy the database and the user.
The API is pretty simple and all is documented on the front page of the application.
So feel free to have a look at it, test it, break it (but let us know how you did that ;-)) at the test instance we have: