Work in progress. Not done yet!
Testing Cookbooks
View Slide
Sean OMeara![email protected]!@someara
whoami
Writing Cookbooks
Are we done?
Slightly more involved.
The Basicshttp://www.flickr.com/photos/jronaldlee/5295169486/
Run the recipeSee what happens
Manual techniquesAutomated techniques
CLI ISBETTER
ChefDK
Our toolchain is in Ruby
Standard Ruby devsetups are tricky to install
System Ruby!RVM!chruby
cd project ; bundle install
Put the code in the can.
OMNIBUSChefDK!!Stable toolchain in anOmnibus installer
Ruby!Chef!Test Kitchen!kitchen-vagrant!Berkshelf!Foodcritic!Rubocop!ChefSpec
Converge Testing
CaaP!vs!IaaP
Cookbook as a Project!vs!Infrastructure as a Project
no chef-repo
battery not included
kitchen-vagrant!kitchen-docker!kitchen-ec2!kitchen-rackspace!kitchen-gce!kitchen-digitalocean!kitchen-openstack!kitchen-bluebox!kitchen-joyent!kitchen-lxcalso available
Integration Testingttps://www.flickr.com/photos/kitsa_sakurako/439652830
Test that a set of resources have achievedtheir combined goal
{testable intent
Test Kitchen runsintegration tests out ofband of Chef
It does this with bussers
Bats!Serverspec!Minitest!Cucumber
suite busser
kitchen test!!kitchen converge!kitchen verify!kitchen destroy
testtear down
Style Testing
Ruby level styleenforcement
single quotesspace after commano trailing whitespace
Chef level styleenforcement
http://www.flickr.com/photos/40389360@N00/2428706650/Regression Testing
ChefSpec makesassertions aboutcompiled resourcecollections
REFERENCE SLIDE
https://github.com/opscode-cookbooks/yumhttps://github.com/opscode-cookbooks/mysqlReference Cookbookshttps://github.com/opscode-cookbooks/jenkinshttps://github.com/opscode-cookbooks/yum-epel
Cookbook Dependencies
Often, a cookbook willdepend on another
include_recipe ‘another_cookbook::recipe’!!OR!!consume a resource shipped inanother_cookbook
For example
not in core Chef
ships in mysqlcookbook
Dependencies suck andyou don’t want to managethem manually.
Berkshelf is bundler forChef cookbooks
your chef-server here
Bundler installsdependencies into yourlocal gem cache
Berkshelf installsdependencies into yourlocal cookbook cache
needs moar ServerSpec
Continuous Integration
This is all driven from thecommand line
Which makes it super easyto wire into CI systems
CI should watch versioncontrol for commits
Polling!vs!Notifications
I ran out of slides!