Testing cookbooks?

In our previous posts we are done with Chef-workstation model, Chef objects and recipes, default and customized chef cookbooks and runlist. If you have missed reading it, kindly check:
Start Automation with Chef?
Chef objects and Recipes?
Chef Cookbooks?
Chef Cookbooks Part-II
Chef run-list?

Chef Automation

Before releasing/merging the code into production, its very important to do a regress testing of the code. In general if we have to think about the testing of a code we need to follow a proper process. The steps involved in the process to verify a cookbook code will be:

Create a Virtual Machine/Node/Instance

Install Chef Tools

Copy/Move the cookbooks to test

Apply/Run the cookbooks

Verify the run

And finally delete/destroy your Virtual Machine/Node/Instance

The problem is we have to perform all these tasks manually to confirm we are releasing/merging/pushing a right code in our production environment. What can be done to automate this?. Is there a way provide by Chef?. Can we automate this whole code testing process?.

Chef says: Yes to all our concerns. We can automate and test whole process of testing cookbooks. The utility which helps us to accomplish this automation is “Kitchen command-line utility” and the process is called “Test Kitchen”. Below is the diagrammatic view of the whole process.


Commands and files:

kitchen.yml: It defines configuration entries which kitchen command line utility use during execution, this files gets automatically generated when we create cookbook using “chef generate” command or you can create it using “kitchen init” command.

kitchen -help

kitchen help init

kitchen create

kitchen converge

kitchen verify

kitchen destroy

This process will ensure about the code and we can use the code in our production environment without fear.

In our next post we will move towards the Chef Server installation and will start our journey towards advanced Chef.

Leave a Comment

Your email address will not be published.