Chef:Powerful Infrastructure Automation
上QQ阅读APP看书,第一时间看更新

Chapter 5. Testing Your Recipes

So far, you have seen how to model your infrastructure, provision hosts in the cloud, and what goes into a cookbook. One important aspect of developing cookbooks is writing tests so that your recipes do not degrade over time or have bugs introduced into them in the future. This chapter introduces you to the following concepts:

  • Understanding test methodologies
  • How RSpec structures your tests
  • Using ChefSpec to test recipes
  • Running your tests
  • Writing tests that cover multiple platforms

These techniques will prove to be very useful to write robust, maintainable cookbooks that you can use to confidently manage your infrastructure. Tests enable you to perform the following:

  • Identify mistakes in your recipe logic
  • Test your recipes against multiple platforms locally
  • Develop recipes faster with local test execution before running them on a host
  • Catch the changes in dependencies that will otherwise break your infrastructure before they get deployed
  • Write tests for bugs to prevent them from happening again in the future (regression)