🇬🇧󠁧󠁢󠁥󠁮󠁧󠁿 Speed up your cookbooks tests with docker

I hope you already test your cookbooks! <3

Outdated article!

If it's a technical article, take care, maybe some informations are not exact anymore.
Otherwise, please keep in mind that this article was written quite a long time ago.

If you're not familiar with chef, a configuration management tool (like Puppet or Ansible for example) you should probably click here and learn how to use it. :)

If you're not familiar with docker it's not a problem! You just need to install it and to continue reading. :)

For those who already use chef, I'm sur you write a lot of tests to check your cookbooks isn't it? :) And you know that it can take a (very) long time to run the full test suite on different VM.

But don't worry, from now on, it's over! Look at kitchen-docker.

Just add kitchen-docker in your Gemfile (or install it directly with gem install kitchen-docker) and you can now start to use docker instead of Vagrant. \o/ Just replace you're current driver in .kitchen.yml:

  name: docker

If you use docker on a Mac (with boot2docker) or inside another machine, you also need to change the socket used by the docker daemon :

- name: ubuntu-12.04
    socket: tcp://docker.example.com:4242

And that's all, you can now launch kitchen test and see the result. :)

On some cookbooks used at BlaBlaCar, running the full test suite is near 60% quicker than before.

Of course, it's not the perfect solution and there is some drawbacks. For example : * the cron service is not automatically launched * on my local environment (mac), when chef change the DNS used in your docker, some tests fails. * some of our tests need a VM with more than 1 disk. Not possible with docker.

Apart from this problems, we save time everyday. \o/

Tags: chef, cookbook, tests, docker, kitchen, serverspec