The January 2005 issue of Dr. Dobb's Journal contains an article (unfortunately not available online) by Sam Tregar on using Perl and VMWare GSX to test builds of Krang. Rather than having a large farm of machines with various versions of perl and the OS on each machine, he used VMWare to build all of these environments on a single machine. A set of Perl scripts called Krang Farm that controls VMWare and automates the building and testing on each environment. He uses GSX since the personal version of VMWare isn't scriptable. GSX and ESX provide Perl and Com APIs that you can use to control the virtual machines.
Besides scriptability, one of the key features of VMWare that makes this application a perfect use of virtualization is VMWare's non-persistent mode. In non-persistent mode, any disk actions are simply forgotten when the machine is halted and the image returns to its original state. This is a great feature in a testing environment, where you always want to start in a known-good state.
The why comes down to this simple analysis:
- Building and hosting a farm of six machines costs $18,000 in capital expenditure and another $14,000 per year in operating costs (mostly hosting). Each new environment requires another machine which adds $3000 to the capital costs and $2400/year to the hosting bill.
- The virtual farm costs $6775 in capital costs and $2400 per year to host. Adding a new environment is free.
Moreover, the virtual solution is more flexible since new environments can be created at the drop of a hat whereas adding a new machine requires planning, staging, and deploying real hardware.
The downside is the rather obvious point that the virtual solution doesn't scale as well as the hardware solution. In this application, it doesn't need to. Your milage may vary.
Another use Sam gives for the farm, which is not yet implemented, is testing upgrades. Pretty easy to have an environment that represents each version of your software and automatically apply upgrades to them as part of your regression testing.
This is a great article on using virtualization as part of a software testing environment--made even better by its hands-on nature. If you do software testing and haven't started using virtualization, this article will help you understand why you should.