[chef] Re: TDD recommendations


Chronological Thread 
  • From: Cassiano Leal < >
  • To:
  • Subject: [chef] Re: TDD recommendations
  • Date: Sat, 8 Feb 2014 12:16:02 +0000

Hi Gregory,

I’d recommend you start by having a look at meez [0]. It will put all the basics together for you and will help you by skipping over that “where the hell should I put these files in?” initial confusion.

I would also recommend watching this video [1] by Dr Nic. That’s what made me start writing better test code for Chef. It’s a few months old, but most things are still the same. It will also introduce you to BATS, which is a handy test framework using Bash.

A few things to notice:

* chefspec [2] is for unit testing: it won’t actually run anything. It “compiles” your recipes the same way that Chef would do, and check to see if the required resources are present given the node attributes fed into the test case;
* Test-kitchen [3] is a test harness that helps you run integration/functional (however you want to call those) tests across multiple OSs. That said, it’s still the best tool to use even if you’re targeting a single platform. Test-kitchen uses “busser” to load plugins for the test frameworks, such as:
** BATS [4] (as mentioned before, uses Bash and is great for things that can be done easily through the shell);
** serverspec [5] is a great tool for checking for the existence of files with some content, to check for services listening on some port and much more. Great tool.
** Others?

I also recommend reading Test-Driven Infrastructure with Chef [6] by Stephen Nelson-Smith. It will help clarify what you should and specially what you should not be testing, and help you understand better the tools and workflows available.

[0] https://github.com/paulczar/meez
[1] http://www.youtube.com/watch?v=0sPuAb6nB2o
[2] https://github.com/sethvargo/chefspec
[3] https://github.com/test-kitchen/test-kitchen
[4] https://github.com/sstephenson/bats
[5] http://serverspec.org

-- 
Cassiano Leal
Sent with Sparrow

On Friday, February 7, 2014 at 23:23, Gregory Patmore wrote:

Hi all, I've been trying to research best practices and sane/practical processes for moving into a TDD flow for chef cookbook development. There seems to be a few different ways to approach it, so I wanted to reach out to the gang here and see what you all are doing, how you like it, etc.

I could use all the good tips you can dish :)

Sent from my iPhone




Archive powered by MHonArc 2.6.16.

§