Save 37% off PRO during our Black Friday Sale! »

TDI with ChefDK 0.0.1

Ea72b50eef37ebe730c37d96c5b5dd51?s=47 someara
August 12, 2014

TDI with ChefDK 0.0.1

Work in progress. Not done yet!

Ea72b50eef37ebe730c37d96c5b5dd51?s=128

someara

August 12, 2014
Tweet

Transcript

  1. Testing Cookbooks

  2. Sean OMeara! someara@getchef.com! @someara

  3. whoami

  4. Writing Cookbooks

  5. None
  6. None
  7. None
  8. Are we done?

  9. Testing Cookbooks

  10. Slightly more involved.

  11. The Basics http://www.flickr.com/photos/jronaldlee/5295169486/

  12. Run the recipe See what happens

  13. Manual techniques Automated techniques

  14. None
  15. None
  16. CLI IS BETTER

  17. ChefDK

  18. Our toolchain is in Ruby

  19. Standard Ruby dev setups are tricky to install

  20. System Ruby! RVM! chruby

  21. cd project ; bundle install

  22. None
  23. None
  24. Put the code in the can.

  25. OMNIBUS ChefDK! ! Stable toolchain in an Omnibus installer

  26. None
  27. None
  28. Ruby! Chef! Test Kitchen! kitchen-vagrant! Berkshelf! Foodcritic! Rubocop! ChefSpec

  29. None
  30. Converge Testing

  31. None
  32. CaaP! vs! IaaP

  33. Cookbook as a Project! vs! Infrastructure as a Project

  34. no chef-repo

  35. battery not included

  36. kitchen-vagrant! kitchen-docker! kitchen-ec2! kitchen-rackspace! kitchen-gce! kitchen-digitalocean! kitchen-openstack! kitchen-bluebox! kitchen-joyent! kitchen-lxc

    also available
  37. None
  38. None
  39. None
  40. None
  41. None
  42. None
  43. None
  44. None
  45. None
  46. None
  47. Integration Testing ttps://www.flickr.com/photos/kitsa_sakurako/439652830

  48. Test that a set of resources have achieved their combined

    goal
  49. { testable intent

  50. None
  51. None
  52. Test Kitchen runs integration tests out of band of Chef

  53. It does this with bussers

  54. Bats! Serverspec! Minitest! Cucumber

  55. None
  56. suite busser

  57. None
  58. None
  59. kitchen test! ! kitchen converge! kitchen verify! kitchen destroy

  60. test tear down

  61. Style Testing

  62. None
  63. Ruby level style enforcement

  64. None
  65. None
  66. None
  67. None
  68. None
  69. None
  70. single quotes space after comma no trailing whitespace

  71. None
  72. None
  73. Chef level style enforcement

  74. None
  75. None
  76. None
  77. None
  78. None
  79. http://www.flickr.com/photos/40389360@N00/2428706650/ Regression Testing

  80. ChefSpec makes assertions about compiled resource collections

  81. None
  82. None
  83. None
  84. None
  85. None
  86. REFERENCE SLIDE

  87. None
  88. None
  89. None
  90. 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

  91. Cookbook Dependencies

  92. Often, a cookbook will depend on another

  93. include_recipe ‘another_cookbook::recipe’! ! OR! ! consume a resource shipped in

    another_cookbook
  94. For example

  95. None
  96. None
  97. not in core Chef

  98. ships in mysql cookbook

  99. None
  100. None
  101. Dependencies suck and you don’t want to manage them manually.

  102. None
  103. Berkshelf is bundler for Chef cookbooks

  104. None
  105. your chef-server here

  106. None
  107. Bundler installs dependencies into your local gem cache

  108. Berkshelf installs dependencies into your local cookbook cache

  109. None
  110. None
  111. None
  112. None
  113. None
  114. None
  115. needs moar ServerSpec

  116. Continuous Integration

  117. This is all driven from the command line

  118. Which makes it super easy to wire into CI systems

  119. CI should watch version control for commits

  120. Polling! vs! Notifications

  121. I ran out of slides!