Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Test Driven Deployment

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

Test Driven Deployment

Avatar for Mat Schaffer

Mat Schaffer

August 22, 2012
Tweet

More Decks by Mat Schaffer

Other Decks in Technology

Transcript

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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