MySQL in memory for faster testing

Neil Bartley
random ramblings, things and stuff
1 min readMar 6, 2017
Creative Commons by Sameer Verma. Only top half of image was used.

During a fit of ‘dammit, why is this test suite taking so long to run?’, I decided to try and squeeze a bit of extra speed out of my development setup.

I’m not going to delve into test suite optimisations, that is for another post. The tests in question were running faster on other peoples machines and that made me sad!

Script

What we have below isn’t new. I’ve taken what I found in this blog post and created a bash script which I can run after each reboot (there is also a teardown script).

These are macOS scripts at the moment but can be very easily updated to work with Linux. I’ll do this in due course.

This started as a gist but is much better at home in a repo. Behold!

https://github.com/neilbartley/mysql-ramdisk-helper

Setup

Copy the mysql-ramdisk-config.sh.example file to mysql-ramdisk-config.sh and make any updates as required.

Usage

Run the script from your project (this is required to run the commands in ENVIRONMENT_SETUP_COMMANDS).

neil | ~/src/myrailsproject (master) $ ls -1 ../mysql-ramdisk-helper
LICENSE
README.md
mysql-ramdisk-config.sh
mysql-ramdisk-config.sh.example
mysql-ramdisk-setup.sh
mysql-ramdisk-teardown.sh
neil | ~/src/myrailsproject (master) $ ../mysql-ramdisk-helper/mysql-ramdisk-setup.sh

--

--

Neil Bartley
random ramblings, things and stuff

Infrastructure and Software fella. All about Dev, Ruby, DevOps, NetSec, Docker, k8s, Cryptocurrencies, Linux | F176 C574 4E56 7DD8 C85E 2C56 DC17 8200 D2FF B94