Virtualization and the cloud are changing how apps are deployed. Application orchestration and deployment is an order of magnitude more complex than ever before. IT operations staff members have been turned into virtual plumbers, ensuring all the bits of the underlying infrastructure are connected together properly and don’t leak. This is tedious work, and one mistake dooms the next rollout to failure and an unplanned outage. Now is the time to test before you deploy.
Chef is an infrastructure configuration management system. To help make the process of testing before deploying infrastructure and basic underlying services easier, they have created a suite of automated testing tools:
- Foodcritic is a part of the Chef Development Kit (ChefDK). Foodcritic is a Lint-like tool that will check your Chef cookbook for syntax and best practices. Testing with Foodcritic is a fast first step and can be scripted/automated with simple syntax.
- ChefSpec is an independent project that can be found in the ChefSpec GitHub repo. ChefSpec is a unit testing framework that allows you to rapidly produce unit testing coverage of your entire cookbook.ChefSpec and Foodcritic are quick checks to make sure everything is sane before running tests that will take more time. Because they are so fast, it is highly recommended that Foodcritic and ChefSpec be run against your cookbook before you go to the Test Kitchen. With a large enough OS/server/configuration testing grid, Test Kitchen can take quite a while.
- Test Kitchen — also found in the ChefDK — is an orchestration tool for testing Chef cookbooks in Docker, Vagrant, and dozens of other virtualization systems. Test Kitchen allows you to test the underlying infrastructure and reduce hardware costs, as your dev/staging environment can be run on a developer’s (or operations engineer’s) laptop if it has sufficient memory and CPU. It does take some time to run, though, as it generates every environment you want to test.
- Serverspec is an integration testing tool that can be run in Test Kitchen. Once you’ve configured Test Kitchen, you can use Serverspec tests (written in YAML and run automatically) to run integration tests against the virtual infrastructure that Test Kitchen has created. Serverspec examines the output and generates reports of what’s going on in Test Kitchen. As the list of combinations of operating systems and software increases, Serverspec shines by reducing output to what you need to know instead of what you had to search for.
Test IT Before You Deploy IT!
Now you have the tools to test your infrastructure before you deploy your app on it. You know the plumbing is all there, and all of it works. This knowledge is also repeatable on demand, automatically. This seems like the best way to avoid having Zenoss Core wake you up at 3 a.m. because something broke!