Although this design is simple in concept and with a lot modern server systems straightforward to implement testing the failure scenarios is often a complex and demanding task. Typically this sort of testing is done manually by disconnecting a server from the network or terminating processes on the server.
Virtual hardware can provide a cost effective alternative and provides capabilities that are not available when using physical servers.
Lets take an example
- The customer clicks on the ‘Add to basket’ for a widget
- The request is serviced by server A and returns a page representing the basket containing the selected widget.
- The customer clicks the ‘Proceed to checkout’ button
- The request is serviced by server A and returns a page requesting payment details for the basket containing the widget.
- The customer clicks on the ‘Add to basket’ for a widget
- The request is serviced by server A and returns a page representing the basket containing the selected widget.
- The customer clicks the ‘Proceed to checkout’ button
- Server A has a network fault so the request is serviced by server B and returns a page requesting payment details for the basket containing the widget.
Virtual machines typically use a virtual network connection routed through a physical connection or completely virtualized on a single host server. With VMWare Server and Microsoft Virtual server this network connection can be controlled by the host or by an application controlling the host. The last option is the most interesting because it allows the connection to be controlled programatically in the test code.
A test might then look like (pseudo code)
result = http.request(“www.test.domain.com/AddToBasket?product=widget”)The ability to automate these tests should not be underestimated. More complex scenarios can be developed and executed easily. The test code can be run frequently perhaps as part of a continuous integration system. Execution time for the tests is now much faster - no manual interventions. Removing the manual steps makes the tests repeatable and less prone to execution error.
AssertWidgetInResult(result)
VirtualHost.ServerA.Network = disabled
result = http.request (“www.test.domain.com/Checkout?orderid=” + result.orderid)
AssertPaymentOptionsDisplayed(result)
Developers, Quality Analysts and Architects gain a much greater understanding of how resilient their application is to failure which leads to a greater confidence that the application will behave as expected in a production environment.
No comments:
Post a Comment