This is video is probably the best demonstration I've seen so far showing the TDD process for cookbook development. - Fletcher Nichol

There is something wonderful coming to devops-land called test-kitchen 1.0. Its a complete rewrite of old test-kitchen by Fletcher Nichol. Its supposedly agnostic to chef[^agnostic]; yet for chef cookbook development it is going to be huge when you combine it with berkshelf (bundler for cookbooks) and vagrant (friendly local VMs for developers).

How huge? I jammed as much as I know into a 20 minute TDD demo to create a chef cookbook for the hub project. The resulting repo was called chef-hub and a shared cookbook hub.

Watch the video and please let me know in the comments if you'll be switching to test-kitchen?

TDD and DevOps

The power of DevOps is bringing developers, agile processes, TDD and continuous delivery all the way down the stack. A devops developer needs to confidently write tests against their ops automation, to iterate on it, and to feel confident that when all the tests pass that the code can ship off to production.

When it comes to testing code that modifies production systems you really want to run integration tests. If you're developing chef cookbooks or bosh releases, then you actually want to bring up running systems and then test that they are as you wish them to be.

And as developers, we want the ability to run these integration tests to fit into our existing workflow. That means it must all work locally from the terminal and work fast. We want to run the tests over and over. Slow tests are tests that developers won't run.

Test-kitchen 1.0 & Vagrant are a great start to 2013 for rapid devops.

Sharing the cookbook

I didn't show how to share a cookbook in the video. Sadly, the current chef/knife tool doesn't like the chef-hub folder name. Grrr. I think cookbooks and their repo/folder names should not be forced to be the same. I want a cookbook hub and the repo chef-hub.

To upload the cookbook:

git clone git@github.com:drnic/chef-hub.git hub # not, chef-hub  
cd hub  
knife cookbook site share hub Utilities -o ..  

That probably needs to go in a rake task rake share. Might go do that now[^rakeshare].

[^agnostic]: I haven't seen that feature in action yet [^rakeshare]: Here is rake share