Testing with Test Kitchen
Test Kitchen is a test harness tool that can test a wide variety of config management tools on a wide variety of platforms using a variety of test tools. Here we will test chef scripts on Vagrant.Install Pre-Requisites
To use vagrant with Test Kitchen install:
Oracle Virtual Box
Vagrant
Create an EC2Dream Environment
In a command line run ec2dream and create a new "Servers" environment called say test.
Create an Instance
Click on "Test Kitchen" and a list of kitchen instances are displayed.
Select instance "default-ubuntu-1204" and the Server will display.
Click on to create the instance. First time will be slow as the test kitchen and related software is automatically installed and the virtual box is downloaded for ubuntu 1204
Eventually the instance will be created and you will have a running instance in vagrant
Click on to ssh to the instance
Converge and Verify instance
Run the chef cookbooks by clicking on the converge buttonRun the integration tests by clicking on the verify button
NOTE: Instance Create, Converge and Verify can be run in one step by pressing the test button
Click on to display the kitchen and instance logs
Destroy instance
Click on to destroy to the instance.Configure Test Kitchen
Click on the edit button to configure the kitchen.yaml fileFoodcritic - Code Style and lint checking
Foodcritic can be run by entering the cookbook directory in the foodcritic parameter and pressing the foodcritic buttonNOTE: These run on your workstation and don't use test kitchen.
RSpec - unit tests
RSpec can be run by entering the rspec scripts in the rspec parameter and pressing the rspec buttonNOTE: These run on your workstation and don't use test kitchen.