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

TDI with ChefDK 0.0.1

someara
August 12, 2014

TDI with ChefDK 0.0.1

Work in progress. Not done yet!

someara

August 12, 2014
Tweet

More Decks by someara

Other Decks in Technology

Transcript

  1. Testing Cookbooks

    View full-size slide

  2. Writing Cookbooks

    View full-size slide

  3. Are we done?

    View full-size slide

  4. Testing Cookbooks

    View full-size slide

  5. Slightly more involved.

    View full-size slide

  6. The Basics
    http://www.flickr.com/photos/jronaldlee/5295169486/

    View full-size slide

  7. Run the recipe
    See what happens

    View full-size slide

  8. Manual techniques
    Automated techniques

    View full-size slide

  9. CLI IS
    BETTER

    View full-size slide

  10. Our toolchain is in Ruby

    View full-size slide

  11. Standard Ruby dev
    setups are tricky to install

    View full-size slide

  12. System Ruby!
    RVM!
    chruby

    View full-size slide

  13. cd project ; bundle install

    View full-size slide

  14. Put the code in the can.

    View full-size slide

  15. OMNIBUS
    ChefDK!
    !
    Stable toolchain in an
    Omnibus installer

    View full-size slide

  16. Ruby!
    Chef!
    Test Kitchen!
    kitchen-vagrant!
    Berkshelf!
    Foodcritic!
    Rubocop!
    ChefSpec

    View full-size slide

  17. Converge Testing

    View full-size slide

  18. CaaP!
    vs!
    IaaP

    View full-size slide

  19. Cookbook as a Project!
    vs!
    Infrastructure as a Project

    View full-size slide

  20. no chef-repo

    View full-size slide

  21. battery not included

    View full-size slide

  22. kitchen-vagrant!
    kitchen-docker!
    kitchen-ec2!
    kitchen-rackspace!
    kitchen-gce!
    kitchen-digitalocean!
    kitchen-openstack!
    kitchen-bluebox!
    kitchen-joyent!
    kitchen-lxc
    also available

    View full-size slide

  23. Integration Testing
    ttps://www.flickr.com/photos/kitsa_sakurako/439652830

    View full-size slide

  24. Test that a set of resources have achieved
    their combined goal

    View full-size slide

  25. {
    testable

    intent

    View full-size slide

  26. Test Kitchen runs
    integration tests out of
    band of Chef

    View full-size slide

  27. It does this with bussers

    View full-size slide

  28. Bats!
    Serverspec!
    Minitest!
    Cucumber

    View full-size slide

  29. suite busser

    View full-size slide

  30. kitchen test!
    !
    kitchen converge!
    kitchen verify!
    kitchen destroy

    View full-size slide

  31. test
    tear down

    View full-size slide

  32. Style Testing

    View full-size slide

  33. Ruby level style
    enforcement

    View full-size slide

  34. single quotes
    space after comma
    no trailing whitespace

    View full-size slide

  35. Chef level style
    enforcement

    View full-size slide

  36. http://www.flickr.com/photos/40389360@N00/2428706650/
    Regression Testing

    View full-size slide

  37. ChefSpec makes
    assertions about
    compiled resource
    collections

    View full-size slide

  38. REFERENCE SLIDE

    View full-size slide

  39. https://github.com/opscode-cookbooks/yum
    https://github.com/opscode-cookbooks/mysql
    Reference Cookbooks
    https://github.com/opscode-cookbooks/jenkins
    https://github.com/opscode-cookbooks/yum-epel

    View full-size slide

  40. Cookbook Dependencies

    View full-size slide

  41. Often, a cookbook will
    depend on another

    View full-size slide

  42. include_recipe ‘another_cookbook::recipe’!
    !
    OR!
    !
    consume a resource shipped in
    another_cookbook

    View full-size slide

  43. not in core Chef

    View full-size slide

  44. ships in mysql
    cookbook

    View full-size slide

  45. Dependencies suck and
    you don’t want to manage
    them manually.

    View full-size slide

  46. Berkshelf is bundler for
    Chef cookbooks

    View full-size slide

  47. your chef-server here

    View full-size slide

  48. Bundler installs
    dependencies into your
    local gem cache

    View full-size slide

  49. Berkshelf installs
    dependencies into your
    local cookbook cache

    View full-size slide

  50. needs moar ServerSpec

    View full-size slide

  51. Continuous Integration

    View full-size slide

  52. This is all driven from the
    command line

    View full-size slide

  53. Which makes it super easy
    to wire into CI systems

    View full-size slide

  54. CI should watch version
    control for commits

    View full-size slide

  55. Polling!
    vs!
    Notifications

    View full-size slide

  56. I ran out of slides!

    View full-size slide