Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to Test Kitchen

1,541 views

Published on

Test Kitchen is a test harness to execute infrastructure code on one or more platforms in isolation.

Easily create, automate, verify, and destroy infrastructure using Test Kitchen in your automation engineering development process.

This talk was given at the Devops Columbia Meetup in July, 2018 - https://www.meetup.com/devops-columbia/events/zrszlpyxkbjc/

Code from the presentation is available at https://github.com/nathenharvey/intro-to-test-kitchen

Learn more about Test Kitchen - https://kitchen.ci/

Published in: Technology
  • Be the first to comment

Introduction to Test Kitchen

  1. 1. @nathenharvey Introduction to Test Kitchen
  2. 2. @nathenharvey Hello! Nathen Harvey VP, Community Development Chef @nathenharvey
  3. 3. @nathenharvey Why Testing? • Move fast with a safety net • Decrease feedback cycles • Increase confidence • Prevent regressions • Scale
  4. 4. @nathenharvey Developing Infrastructure Automation • Write the automation • Static analysis • Unit testing • Local integration testing Create an infrastructure that matches production Run automation Validate results Destroy • Commit to version control • Submit to pipeline
  5. 5. @nathenharvey Zoom-in on Integration Testing • Create infrastructure that matches production • Run the automation • Verify the results • Destroy the infrastructure
  6. 6. @nathenharvey Test Kitchen Test harness to execute infrastructure code on one or more platforms in isolation.
  7. 7. @nathenharvey The Test Kitchen platforms: - name: ubuntu-16.04 - name: centos-7 platforms
  8. 8. @nathenharvey The Test Kitchen driver: name: vagrant platforms: - name: ubuntu-16.04 - name: centos-7 kitchen create driver platforms
  9. 9. @nathenharvey Zoom-in on Integration Testing Create infrastructure that matches production • Run the automation • Verify the results • Destroy the infrastructure
  10. 10. @nathenharvey The Test Kitchen driver: name: vagrant platforms: - name: ubuntu-16.04 - name: centos-7 provisioner: name: chef_zero kitchen create driver platforms kitchen converge provisioner
  11. 11. @nathenharvey Chef Recipe package 'git' do action :install end
  12. 12. @nathenharvey Zoom-in on Integration Testing Create infrastructure that matches production Run the automation • Verify the results • Destroy the infrastructure
  13. 13. @nathenharvey InSpec • Open-source framework • Infrastructure testing • Make assertions about state of resources in the infrastructure
  14. 14. @nathenharvey Sample InSpec code describe service('apache2') do it { should be_running } end describe port(80) do it { should be_listening } end describe http('http://localhost', enable_remote_worker: true) do its('status') { should cmp 200 } its('body') { should match /Welcome to / } end
  15. 15. @nathenharvey The Test Kitchen driver: name: vagrant platforms: - name: ubuntu-16.04 - name: centos-7 provisioner: name: chef_zero verifier: name: inspec kitchen create driver platforms kitchen converge provisioner kitchen verify verifier
  16. 16. @nathenharvey Verify the results with InSpec describe package('git') do it { should be_installed } end describe command('git') do it { should exist } end describe command('which git') do its('exit_status') { should eq 0 } end
  17. 17. @nathenharvey Zoom-in on Integration Testing Create infrastructure that matches production Run the automation Verify the results • Destroy the infrastructure
  18. 18. @nathenharvey The Test Kitchen driver: name: vagrant platforms: - name: ubuntu-16.04 - name: centos-7 provisioner: name: chef_zero verifier: name: inspec kitchen create driver platforms kitchen converge provisioner kitchen verify verifier kitchen destroy
  19. 19. @nathenharvey Zoom-in on Integration Testing Create infrastructure that matches production Run the automation Verify the results Destroy the infrastructure
  20. 20. @nathenharvey The Test Kitchen kitchen create driver platforms kitchen converge provisioner kitchen verify verifier kitchen destroy kitchen test
  21. 21. @nathenharvey The Test Kitchen kitchen create driver platforms kitchen converge provisioner kitchen verify verifier kitchen destroy kitchen test kitchen destroy
  22. 22. @nathenharvey The Test Kitchen kitchen create driver platforms kitchen converge provisioner kitchen verify verifier kitchen destroy kitchen test kitchen destroy kitchen create
  23. 23. @nathenharvey The Test Kitchen kitchen create driver platforms kitchen converge provisioner kitchen verify verifier kitchen destroy kitchen test kitchen destroy kitchen create kitchen converge
  24. 24. @nathenharvey The Test Kitchen kitchen create driver platforms kitchen converge provisioner kitchen verify verifier kitchen destroy kitchen test kitchen destroy kitchen create kitchen converge kitchen verify
  25. 25. @nathenharvey The Test Kitchen kitchen create driver platforms kitchen converge provisioner kitchen verify verifier kitchen destroy kitchen test kitchen destroy kitchen create kitchen converge kitchen verify kitchen destroy
  26. 26. @nathenharvey More Test Kitchen <3
  27. 27. @nathenharvey The Test Kitchen driver: name: kitchen create driver
  28. 28. @nathenharvey The Test Kitchen provisioner: name: kitchen converge provisioner
  29. 29. @nathenharvey The Test Kitchen verifier: name: kitchen verify verifier
  30. 30. @nathenharvey Get Started with Test Kitchen • Install Chef Development Kit - https://downloads.chef.io/chefdk Test Kitchen InSpec • Install Driver Requirements Vagrant – VirtualBox & Vagrant Docker – Docker GCE – None, but best to Google Cloud SDK installed EC2 – None, but you need an AWS account
  31. 31. @nathenharvey Use, Share, Contribute! • Test Kitchen https://kitchen.ci/ https://github.com/test-kitchen • InSpec https://www.inspec.io/ https://github.com/chef/inspec • Code from this presentation - https://github.com/nathenharvey/intro-to-test- kitchen
  32. 32. @nathenharvey Join us on Slack • http://community-slack.chef.io • #general (for Chef stuff) • #test-kitchen • #inspec The Chef community believes that diversity is one of our biggest strengths! YOU are welcome here!
  33. 33. @nathenharvey What questions can I answer for you? Nathen Harvey VP, Community Development Chef @nathenharvey

×