Virtualization: A Tester’s Dream?
Virtualization: A Tester’s Dream?
Are virtual machines a silver bullet for testers or just another tool in their arsenal? Read this article to find out more.
Join the DZone community and get the full member experience.Join For Free
Read why times series is the fastest growing database category.
Virtualization has been around for a long time. As early as the 1960s, IBM was supporting virtualization on mainframes to ease the cost of migration among multiple generations of their systems. Languages like Pascal, Java, and C# translate into virtual machine languages that are then either interpreted or further compiled (“just in time compilation”) into actual machine code.
Shielding applications from the details of underlying configurations is still a driver for virtualization — in particular, the use of virtual machines. This has the added advantage of providing more efficient physical hardware use. For testers, virtual machines can be a game changer. To what degree the game really changes depends largely on how an organization decides to work with virtual machines and how active the testers themselves are in recognizing and leveraging virtual machines’ possibilities.
Virtual machines often need to be requested from IT departments, essentially making a test team be at the mercy of IT’s request. A tester won’t be able to write a script to dynamically generate virtual machines from images, run tests on them, and bring them back down as effectively without access to the virtual machine. An IT department might dimension virtual machines on physical machines based on manual use, but an automated test is typically more demanding than a human user.
Another issue is that it is often hard to predict timing behaviors of virtual machines. Automated tests often rely significantly on timing. Virtual machines might be swapped out during an operation, which then can take longer than the automation expects. We see tests break on virtual machines that previously were always running stably on physical machines. To address this, make sure to use “active timing,” wait for something measurable, don’t use hard-coded sleeps, and do allow a high maximum wait threshold for your tests.
Managing virtual machines and their images can become a job in itself — in particular when virtual machines are used at a large scale, such as to mimic the many configurations of the application under test. Work with a plan and have a designated person own it. Some questions to be answered involve what configuration you need to and run virtual machines, when to run them, and what hardware to run them on.
An exciting new wave of virtualization is containers. These are processes that have their own pre-defined environment — file system, libraries, and settings. The containers have been made popular by the open-source tool Docker, which allows them to be moved around and quickly instantiated and started on any machine. Organized this way, the containers form mini-virtual machines with sizes measuring in megabytes rather than the gigabytes that full-blown virtual machines need.
The natural use of containers is running servers in a service-oriented architecture (SOA). The containers give operations a great tool to organize configurations and run instances of the system and its components. For testers, containers make it easier to build and maintain environments that are functionally equivalent to production. These benefits work even better if an ambassador pattern is used for the containers. It allows for easy replacement of major service providers, such as databases or external REST services, by mock-ups. When you use action-based testing, you can even consider controlling the behavior of the mock-up with actions. You could use them to let the mock-up capture requests coming from the process under test and to generate predefined replies.
Virtual machines and containers can offer a great deal of opportunities to testers, in particular for the operations side of their work. A well-thought approach with the support of all involved can be very helpful in achieving these benefits.
This article originally appeared in Techwell.
Published at DZone with permission of Thanh Phan , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.