Arrrrcamp 2012: Testing Chef

Arrrrcamp 2012: Testing Chef

The state of testing chef recipes

8fafaf172a12f2b6aa3f55c48179a654?s=128

Bernard Grymonpon

October 04, 2012
Tweet

Transcript

  1. 4.

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

    dev • hosting company • managed setups for clients Friday 5 October 12
  2. 5.

    D vOp • buzzword (its a mindset, not a job

    title) • infra as code • sysadmins using git (hooray) Friday 5 October 12
  3. 6.

    Op C f • recipes / cookbooks • attributes •

    resources / providers / ... • Solo vs hosted Friday 5 October 12
  4. 7.

    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. 8.

    W T R p ? • ease of mind •

    avoid regression Friday 5 October 12
  6. 9.

    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. 12.

    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. 15.

    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. 18.

    C f p • hard to work with nested attributes

    • not all system attributes available (you can add them in) Friday 5 October 12
  10. 20.

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

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

    S p 1: v I v • spinning up machine

    • apply recipe(s)/role(s) • assertions • destroy machine Friday 5 October 12
  13. 23.

    V r • ruby wrapper around virtualbox • works with

    “base boxes” • pretty solid integration • solo and server Friday 5 October 12
  14. 24.

    f- -W • whyrun feature • will mock a run

    • not 100% correct Friday 5 October 12
  15. 25.

    - 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. 27.

    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. 28.

    F r • cucumber • vagrant • sahara for snapshotting

    • aruba (cucumber steps) Friday 5 October 12
  18. 30.

    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. 31.

    T • lxc linux • low-resource virtual machines • actually,

    close to what I want • https://github.com/exceedhl/toft Friday 5 October 12
  20. 32.

    T - • assembles everything • metadata contains the platforms

    • test/kitchen contains recipes for tests Friday 5 October 12
  21. 33.

    f • unused • unexplored • unknown • basis for

    what we can do (supports, parameters, recipes, ...) Friday 5 October 12
  22. 34.

    rr • I have a chef server • It has

    recipes • It has nodes with roles applied • Test it all Friday 5 October 12
  23. 35.

    I r • git commit • <magic> • “all green,

    carry on” Friday 5 October 12
  24. 36.

    I r • cucumber / rspec language • vagrant /

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