Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

disclaimer

Slide 3

Slide 3 text

Credits

Slide 4

Slide 4 text

Jim Hopp github.com/jimhopp

Slide 5

Slide 5 text

Bryan McLellan loftninjas.org

Slide 6

Slide 6 text

Seth Vargo sethvargo.com

Slide 7

Slide 7 text

foodfightshow.org

Slide 8

Slide 8 text

TDD cycle

Slide 9

Slide 9 text

Red Green Refactor

Slide 10

Slide 10 text

integration + UNIT Cycle

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Why??

Slide 13

Slide 13 text

vagrant test kitchen berkshelf chefspec minitest chef handler guard strainer foodcritic

Slide 14

Slide 14 text

vagrant

Slide 15

Slide 15 text

Vagrant::Config.run  do  |config|    config.vm.box  =  "precise64"    config.vm.box_url  =  "http://files.vagrantup.com/precise64.box"    config.vm.network  :hostonly,  "10.0.3.2"    config.vm.provision  :chef_solo  do  |chef|        chef.cookbooks_path  =  [  'cookbooks'  ]        chef.add_recipe  'minitest-­‐handler'        chef.add_recipe  'cube'    end end local VM automation Vagrantfile

Slide 16

Slide 16 text

berkshelf / librarian

Slide 17

Slide 17 text

cookbook 'cube', path: 'cookbooks-sources/cube' cookbook dependency management berksfile

Slide 18

Slide 18 text

strainer

Slide 19

Slide 19 text

knife test: bundle exec knife cookbook test $COOKBOOK foodcritic: bundle exec foodcritic $SANDBOX/$COOKBOOK chefspec: bundle exec rspec $SANDBOX/$COOKBOOK isolated cookbook test runner colanderfile

Slide 20

Slide 20 text

Guard

Slide 21

Slide 21 text

guard 'shell' do watch %r|^cookbooks-sources/cube| do system <<-SH set -e berks install --shims strain cube --fail-fast vagrant provision SH end end test runner automation guardfile

Slide 22

Slide 22 text

foodcritic

Slide 23

Slide 23 text

watches for common anti-patterns linting # Don't do this package "mysql-server" do version "#{node['mysql']['version']}" action :install end # Do this package "mysql-server" do version node['mysql']['version'] action :install end

Slide 24

Slide 24 text

Minitest chef handler

Slide 25

Slide 25 text

describe_recipe  'nginx:configuration'  do    it  'installs  version  1.0.15'  do        node[:nginx][:version].should  ==  '1.0.15'    end end testing after convergence files/default/tests/minitest/ default_test.rb

Slide 26

Slide 26 text

integration testing

Slide 27

Slide 27 text

chefspec

Slide 28

Slide 28 text

before convergence spec/default_spec.rb require  "chefspec"    describe  "example::default"  do    let  (:chef_run)  {        ChefSpec::ChefRunner.new.converge  'example::default'    }    it  "should  install  foo"  do        chef_run.should  install_package  'foo'    end end

Slide 29

Slide 29 text

unit testing

Slide 30

Slide 30 text

test kitchen

Slide 31

Slide 31 text

automated cross-OS testing cube/test/kitchen/kitchenfile # FIXME: Make this stuff work platform :ubuntu do version '12.04' do box "opscode-ubuntu-12.04" box_url "https://opscode-.../opscode-ubuntu-12.04.box" end end cookbook "cube" do configuration "server" end

Slide 32

Slide 32 text

Demo time

Slide 33

Slide 33 text

megaman.wikia.com Mat Schaffer about.me/matschaffer