Changes
Title
unchanged
Speedup unit tests by moving MySql data to memory (in Ubuntu)
Category
unchanged
Tips
Yii version
unchanged
Tags
unchanged
mysql, unit test
Content
changed
[...]
* Refactor code and tests and do not touch db in tests
* Use sqlite db in memory instead of MySql
* Use MySql MEMORY engine
* Move MySql data to memory
> Each method has drawbacks:
>
> * Not using DB in unit tests means that parts of the code won't be tested.
> * Using SQLite only for tests may induce different behavior. This is against the very meaning of unit tests.
> * Like SQLite, the MySQL Memory engine is different from InnoDB and MyISAM. For example, FK are ignored.
> The following process moves **every MySQL database** into a memory filesystem.
> If you have databases other than the test DB, the copy/restore process may be slow,
> and **you can loose data** if something goes wrong.
> You've been warned, do not use this when you have important data in any database of your MySQL server.
It is better to try other listed approaches and I think of last method as of quick temporary hack, but here it is:
* stop mysql
* move /var/lib/mysql to /dev/shm/mysql
* link /var/lib/mysql to /dev/shm/mysql
* start mysql[...]