A blog

Errata for Test-Driven Infrastructure with Chef (2nd Ed)

Update: I’m very happy to update this post to note that Test Kitchen 1.0 has been released. See the announcement on the Opscode blog, and check out the KitchenCI home page.

A couple of years ago, Stephen Nelson-Smith wrote a little book called Test-Driven Infrastructure with Chef. Somewhat ahead of its time, it gave a brief introduction to the idea of outside-in, test-driven development, in the context of infrastructure code. Since then, the rest of the world has started to catch up, and a variety of tools and community practices have grown up around the idea.

Last month, the greatly revised and expanded second edition of the book was released. I mean to write a full review when I’ve spent some more time with the book, but here’s the short version: if you use Chef, buy it.

That having been said, nothing in life is perfect, and that’s true here. The book optimistically assumes that Opscode (or whoever) would have managed to make a 1.0 release of Test-Kitchen by now. They haven’t, so you’ll currently have issues following some of the instructions when the recommended toolchain is introduced in Chapter 7.

Berkshelf and Test Kitchen Installation

The book assumes that Berkshelf (installed with gem install berkshelf) will also install the test-kitchen gem. As of Berkshelf 2.0.10, that’s not the case – and if you don’t install it yourself, Berkshelf won’t generate the Gemfile you’ll see next.

You can fix this by installing test-kitchen yourself, but be warned – if you just run gem install test-kitchen, you’ll get a prehistoric version. You can tell gem to install the latest pre-release version by running gem install test-kitchen --pre. This won’t be required after the final 1.0 release is made.

Berkshelf – Gemfile

The book looks at the Gemfile created by berks init, which adds dependencies on test-kitchen and kitchen-vagrant. If you follow the output’s instructions to run bundle install, you’ll get a failure:

Bundler could not find compatible versions for gem "test-kitchen":
      In Gemfile:
        kitchen-vagrant (>= 0) ruby depends on
          test-kitchen (~> 1.0.0.alpha.0) ruby

        test-kitchen (0.5.0)

Again, this won’t be a problem after test-kitchen gets a a 1.0 release. Today, you’ll need to manually update the Gemfile to add a version constraint like so:

source ''

gem 'berkshelf'

# gem 'test-kitchen', :group => :integration
gem 'test-kitchen', '~> 1.0.0.beta.4', :group => :integration
gem 'kitchen-vagrant', :group => :integration

With that change, bundle install will run to completion.

Parting Thought

It’s a fact of life that books about software tools go out of date as those tools are improved, so it’s only a mild irritation that this book looks forward to a release that has yet to arrive.

Test Kitchen was discussed at Opscode’s “Chef Summit” last week, and the notes of that session suggest that a release is now waiting for documentation. That’s a well-intentioned reason, but a lousy excuse. A 1.0 release with documentation would be vastly superior to a 1.0 release without, but the current situation impedes the community’s ability to move forward and help each other out. This is particularly frustrating when I keep hearing that the software itself is awesome, stable, and generally ready for use.

I look forward to updating this post to note that it should be ignored in its entirety.