what is test kitchen

21
Test Kitchen Keep your cookbook in order

Upload: benoit-caron

Post on 10-May-2015

264 views

Category:

Software


3 download

DESCRIPTION

As presented to the Devops Montreal crowd, 2014-05-05.

TRANSCRIPT

Page 1: What is Test Kitchen

Test KitchenKeep your cookbook in order

Page 2: What is Test Kitchen

Who’s cooking?

Who is this guy? Sysadmin @ La Presse Been using Chef since 2011 (0.8.0) in a

team of 2 or a team of 10 bencaron @

Page 3: What is Test Kitchen

What is Test Kitchen?

• Doing Infrastructure as code?

• Code ❤️ tests

• Test Kitchen help you automate the testing of your cookbooks

Page 4: What is Test Kitchen

But why tests?

Tests helps you work as a team

Tests allows you to move faster, with more confidence

Your infrastructure is now code: manage it as code, using modern development best practices

Page 5: What is Test Kitchen

Test Kitchen helps you..

Test your cookbook under n platform, under m scenarios

Put your cookbooks under a CI pipeline

Use the best test framework for the job

Page 6: What is Test Kitchen

Test Kitchen vs Vagrant

Prevents you to build yet another huge custom Vagrantfile

Allows you to tests on other targets (cloud!)

Add a sane abstraction layer over your VM config and your tests

Page 7: What is Test Kitchen

Ok, how does this thing work?

Gem install test-kitchen

Use the kitchen command

Commands work like a pipeline where you can execute juste part of it

Kitchen test == kitchen create kitchen converge kitchen setup kitchen verify kitchen destroy

Page 8: What is Test Kitchen

Kitchen init

Setup your cookbook

Configuration is done in .kitchen.yml

Your tests lives under:

test/ integration/ [suitename]/ [tool]

Page 9: What is Test Kitchen

.kitchen.yml

Driver:How to launch your VM. Default is Vagrant

Provisioner:How to run your test Solo or Zero

Platforms: What to test

SuitesScenarios to test

Page 10: What is Test Kitchen

More tricks

Exclude/include platforms in scenarios (for e.g. platform-specific recipes)

Uses environments, roles, data bags

Thin documentation: use kitchen diagnose for list of possible configs

Page 11: What is Test Kitchen

Kitchen-*

There’s already a lot of drivers Kitchen-docker: fast

testing environment with docker, even on OSX

Lots of others

Page 12: What is Test Kitchen

Ok, so what kind of tests? Bats Serverspecs Minitests Cucumber Others!

Page 14: What is Test Kitchen

Serverspecs

RSpec tests for checking your servers are configured correctly

http://serverspec.org/

Follow rspec patterns and test your server state through SSH (or local) access

Page 15: What is Test Kitchen

Rspec form

Serverspec tests are rspec tests

Page 16: What is Test Kitchen

Serverspec example

A more typical serverspec example

Page 17: What is Test Kitchen

More on serverspec

Reusable outside of Test Kitchen

Turn it into monitoring?

Reuse your tests on your current/old servers. Even on REAL hardware!

Page 18: What is Test Kitchen

More testing

FoodcriticCheck your cookbook stylehttp://acrmp.github.io/foodcritic/

RubocopStatic code analyzerhttps://github.com/bbatsov/rubocop

Page 19: What is Test Kitchen

Chefspec

ChefSpec Unit testing for Chef

cookbooks Rspec Check without

convergence Puppet users?

Check rspec-puppet rspec-puppet.com

Page 20: What is Test Kitchen

Questions?

Page 21: What is Test Kitchen

Photos credits – Thank you!

Crisco:http://en.wikipedia.org/wiki/File:Crisco_Cookbook_1912.jpgFront cover of the first Crisco cookbook, published in 1912. This file was obtained from the crisco website in the timeline section [1]. This work is in the public domain in the US per Wikipedia:Public domain because it was published before 1923.

Kitchen Scene-Joachim Wtewael.jpghttp://en.wikipedia.org/wiki/File:Kitchen_Scene-Joachim_Wtewael.jpgPublic Domain

http://en.wikipedia.org/wiki/Automatic_fire_suppressionhttp://en.wikipedia.org/wiki/File:COMPUTER_ROOM_DISCHARGE.JPGWikiCommon

Good Housekeepinghttp://en.wikipedia.org/wiki/File:Good_housekeeping_1908_08_a.jpgPublic Domain

Julia Child Kitchenhttp://en.wikipedia.org/wiki/File:Julia_Child%27s_kitchen_by_Matthew_Bisanz.JPGGNU Documentation License

Pig Slaughterhttp://en.wikipedia.org/wiki/File:Medieval_pig_slaughter.jpgPublic Domain

Gouteur de vinhttp://fr.wikipedia.org/wiki/Go%C3%BBteur#mediaviewer/Fichier:Jan_David_Col_%281822-1900%29%2C_Les_go%C3%BBteurs_de_vin.jpgDomaine public

Joan Post kitchen firehttps://www.flickr.com/photos/quinnanya/11698730705/11698730705_42e623db7c_z.jpghttps://creativecommons.org/licenses/by-sa/2.0/

Fire buildinghttp://en.wikipedia.org/wiki/File:FirePhotography.jpgby-sa 3.0

Lego kitchenhttps://www.flickr.com/photos/kwl/5527716890https://creativecommons.org/licenses/by/2.0/

Kitchen disasterhttps://www.flickr.com/photos/donnunn/165101829/165101829_cf087a4541_zhttps://creativecommons.org/licenses/by-sa/2.0/