A very much work in progress example of writing a test suite against an Infrastructure as a Service, in this case DigitalOcean.
TDD, ie. using tests to help describe and design your code, is a well-practices approach to software development. If we really are treating out infrastructure as code then how about a test suite picking on certain aspects of a provisioned infrastructure as a service?
This example completely separates the actual testing from the creation of virtual resources. This isn't a declarative provisioning tool. The utility I see with that approach is that you could write a simple test suite and then anyone can create an environment to pass those tests. This makes certain aspects of portability easier, as well as greatly simplying the testing half.
The tests are just clojure, although you could implement the same idea in any language with a suitable IaaS client. The syntax uses expectations which leads to some pretty expressive code:
(expect 2 (count nodes))
The current full test suite is available in the repository.
In order to run the tests yourself you'll need a DigitalOcean account.
The underlying client uses the V2 API so you need to set a
DIGITALOCEAN-ACCESS-TOKEN environment variables. Alternatively you can use
.lein-env if you know what you're doing.
You can run the tests with the following. Note that the specific tests here are unlikely to pass with anything but the small test dataset I was using.
Much more fun is running the tests everytime you make a change to the test file.
Thanks to the digitalocean Clojure client for dealing with the DigitalOcean interface so I could get on with the job at hand.