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

Arrrrcamp 2012: Testing Chef

Arrrrcamp 2012: Testing Chef

The state of testing chef recipes

Bernard Grymonpon

October 04, 2012
Tweet

More Decks by Bernard Grymonpon

Other Decks in Technology

Transcript

  1. M • Bernard Grymonpon - @wonko_be • 80% ops, 20%

    dev • hosting company • managed setups for clients Friday 5 October 12
  2. D vOp • buzzword (its a mindset, not a job

    title) • infra as code • sysadmins using git (hooray) Friday 5 October 12
  3. Op C f • recipes / cookbooks • attributes •

    resources / providers / ... • Solo vs hosted Friday 5 October 12
  4. package "apache2" service "apache2" do supports :status => true action

    [ :enable, :start ] end template "/etc/apache2/ports.conf" do source "ports.erb" owner "root" group "root" mode "0644" end Friday 5 October 12
  5. W T R p ? • ease of mind •

    avoid regression Friday 5 October 12
  6. T r p • does a recipe work as intended

    • is the end-result correct • does the “install me an apache webserver”, actually install apache Friday 5 October 12
  7. RSp - f • https://github.com/calavera/rspec-chef • 9 months ago commited

    • had to patch it to work with latest chef • doesn’t work Friday 5 October 12
  8. C f p • https://github.com/acrmp/chefspec • no real runs •

    no providers/resources/lwrp’s • mocks & all supported • feels like testing chef, not the recipe Friday 5 October 12
  9. C f p • hard to work with nested attributes

    • not all system attributes available (you can add them in) Friday 5 October 12
  10. W w v • if I ask chef to install

    a package • ...will it call the package resource • not ...is the package installed in the end Friday 5 October 12
  11. W I • Given a setup for a client •

    When I run chef-client • Then I want the webapp/site/service to work Friday 5 October 12
  12. S p 1: v I v • spinning up machine

    • apply recipe(s)/role(s) • assertions • destroy machine Friday 5 October 12
  13. V r • ruby wrapper around virtualbox • works with

    “base boxes” • pretty solid integration • solo and server Friday 5 October 12
  14. f- -W • whyrun feature • will mock a run

    • not 100% correct Friday 5 October 12
  15. - f- r • https://github.com/calavera/minitest-chef- handler • feedback after converge

    • only test end result after a run, in chef- running-window Friday 5 October 12
  16. C b r- f In its current incarnation, cucumber-chef makes

    two important assumptions. Firstly, we assume you’re using the Opscode platform rather than your own Chef server. Secondly, we assume that you are comfortable with using Amazon’s EC2 service for providing the ‘bare metal’ on which we set up the test lab. Future releases may well allow you to use your own Chef server, and will definitely look at offering alternative cloud providers. In the meantime, we welcome patches and pull requests! Friday 5 October 12
  17. F r • cucumber • vagrant • sahara for snapshotting

    • aruba (cucumber steps) Friday 5 October 12
  18. F r • 50% of time reading/fiddling Vagrant • 20%

    waiting for virtualbox • 20% wrapping vagrant in a helper class (BoxCollections, Box, etc...) • 5% tying it together Friday 5 October 12
  19. T • lxc linux • low-resource virtual machines • actually,

    close to what I want • https://github.com/exceedhl/toft Friday 5 October 12
  20. T - • assembles everything • metadata contains the platforms

    • test/kitchen contains recipes for tests Friday 5 October 12
  21. f • unused • unexplored • unknown • basis for

    what we can do (supports, parameters, recipes, ...) Friday 5 October 12
  22. rr • I have a chef server • It has

    recipes • It has nodes with roles applied • Test it all Friday 5 October 12
  23. I r • git commit • <magic> • “all green,

    carry on” Friday 5 October 12
  24. I r • cucumber / rspec language • vagrant /

    fog / libvirt / lxc / EC2 / ... • chef server (clone) • librarian • CI server Friday 5 October 12