Testing on the Chef Platform: Overview

Introduction to Test Automation with Chef


Types of Testing

Static Analysis

Unit Test

Integration Testing

  • Single Cookbook Integration: testing only a single cookbook, like Apache cookbook or a MySQL cookbook. The integration tests would live with the cookbook code.
  • Multiple Cookbook Integration: testing several cookbooks together, such as a LAMP stack, which would use an Apache cookbook and MySQL cookbook on separate systems, and test the full integration of all the components working together. The integration test would exist outside the cookbook directory.

Systems Testing

The Testing Tools






Practices and Trends

Practices for Unit Tests

package 'apache2' { action: install }
it { expect(chef_run).to install_package 'apache2' } # <= Bad! 

Practices for Integration Tests

describe port(80) do
it { should be_listening }
describe http('localhost') do
its('status') { should eq 200 }
its('headers.Content-Type') { should include 'text/html' }
its('body') { should include 'Hello World!' }



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Joaquín Menchaca (智裕)

Linux NinjaPants Automation Engineering Mutant — exploring DevOps, o11y, k8s, progressive deployment (ci/cd), cloud native infra, infra as code