Save 37% off PRO during our Black Friday Sale! »

Test Driven Deployment

Test Driven Deployment

9b26cb404fe1fdae235e476c55fb2cdd?s=128

Mat Schaffer

August 22, 2012
Tweet

Transcript

  1. None
  2. disclaimer

  3. Credits

  4. Jim Hopp github.com/jimhopp

  5. Bryan McLellan loftninjas.org

  6. Seth Vargo sethvargo.com

  7. foodfightshow.org

  8. TDD cycle

  9. Red Green Refactor

  10. integration + UNIT Cycle

  11. None
  12. Why??

  13. vagrant test kitchen berkshelf chefspec minitest chef handler guard strainer

    foodcritic
  14. vagrant

  15. 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
  16. berkshelf / librarian

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

  18. strainer

  19. 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
  20. Guard

  21. 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
  22. foodcritic

  23. 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
  24. Minitest chef handler

  25. 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
  26. integration testing

  27. chefspec

  28. 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
  29. unit testing

  30. test kitchen

  31. 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
  32. Demo time

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