118
Cookbook Testing with TravisCI, Test Kitchen and Digital Ocean

Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Embed Size (px)

DESCRIPTION

Testing cookbooks on Digital Ocean with Test Kitchen, Serverspec, and ChefSpec

Citation preview

Page 1: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Cookbook Testing with TravisCI, Test Kitchen and Digital Ocean

Page 2: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Sean [email protected]!

@someara

Page 3: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

whoami

Page 4: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Writing Cookbooks

Page 5: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 6: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 7: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 8: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Are we done?

Page 9: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Testing Cookbooks

Page 10: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Slightly more involved.

Page 11: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

The Basics

http://www.flickr.com/photos/jronaldlee/5295169486/

Page 12: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Run the recipe See what happens

Page 13: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Manual techniques Automated techniques

Page 14: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 15: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 16: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

CLI IS BETTER

Page 17: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Converge Testing

Page 18: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 19: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 20: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 21: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 22: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 23: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 24: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 25: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 26: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 27: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 28: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 29: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 30: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 31: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 32: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Integration Testing

https://www.flickr.com/photos/kitsa_sakurako/439652830

Page 33: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Test that a set of resources has achieved their combined goal

Page 34: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

{testable intent

Page 35: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 36: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 37: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Test Kitchen runs integration tests out of band of Chef

Page 38: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

It does this with bussers

Page 39: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Bats!Serverspec!Minitest!Cucumber

Page 40: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 41: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

suite busser

Page 42: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 43: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 44: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

kitchen test!!

kitchen converge!run integration tests!kitchen destroy

Page 45: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

test

tear down

Page 46: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Style Testing

Page 47: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 48: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Ruby level style enforcement

Page 49: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 50: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 51: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 52: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 53: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 54: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 55: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 56: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 57: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 58: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 59: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 60: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

single quotes

space after comma

no trailing whitespace

Page 61: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 62: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 63: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Chef level style enforcement

Page 64: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 65: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 66: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 67: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 68: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 69: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 70: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 71: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 72: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

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

Regression Testing

Page 73: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

ChefSpec makes assertions about compiled resource collections

Page 74: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 75: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 76: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 77: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 78: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 79: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 80: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 81: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 82: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

REFERENCE SLIDE

Page 83: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 84: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 85: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 86: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

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

Page 87: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Cookbook Dependencies

Page 88: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Often, a cookbook will depend on another

Page 89: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

include_recipe ‘another_cookbook::recipe’!!

OR!!

consume a resource shipped in another_cookbook

Page 90: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

For example

Page 91: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 92: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 93: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

not in core Chef

Page 94: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

ships in mysql cookbook

Page 95: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 96: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 97: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

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

Page 98: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 99: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 100: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 101: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 102: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Berkshelf is bundler for Chef cookbooks

Page 103: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 104: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

your chef-server here

Page 105: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 106: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Bundler installs dependencies into your local gem cache

Page 107: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Berkshelf installs dependencies into your local cookbook cache

Page 108: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 109: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 110: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 111: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 112: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 113: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean
Page 114: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

needs moar ServerSpec

Page 115: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Travis CI

Page 116: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

Because I like to close my laptop sometimes

Page 117: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean

I ran out of slides.

Page 118: Chef-NYC June-2014 - Testing cookbooks on Digital Ocean