Microservices: The Trending Software Architecture – Part II

In our previous blog, Microservices: An Introduction, we provided a broad overview of the architectural composition of Microservices and talked about some of the benefits and challenges associated with it. In this conclusive part of the blog series, we will now discuss some of the key challenges associated with Microservices testing, and strategies to overcome these challenges.

Part 2 – Microservices: Software Testing Challenges and Strategies

The decentralized and independent nature of the development of Microservices poses a number of software testing challenges. Integration of services, preferably over lightweight protocols developed by varied teams in different programming languages using different technologies and frameworks, definitely makes testing a daunting task.

To begin with, Microservices normally display a similar kind of layered internal structure. The testing challenge is to offer test coverage to each layer, and in between the layers of the service, while remaining lightweight at the same time.

Secondly, with multiple teams and technologies involved, the timeframe for availability of each service for testing purposes cannot be specified. Hence, using Web API testing tools built around SOA architecture may not turn out to be a feasible option.

Next, comes the Integration part. For Integration tests, it is essential for QA testers to comprehend the individual services involved in order to create robust test cases. But as data storage is generally managed by individual units, the extraction of logs during testing and data verification becomes a complex task.

Interoperability is yet another challenge that requires Microservices to flawlessly communicate with each other, given the non-integrated independent service development scenario. And further, availability of a dedicated test environment is yet another challenge.

Additionally, understanding and clearly delineating the right type of individual unit testing, and the holistic software testing needed at each stage of the SDLC is not a straightforward task.

Finally, since we are dealing with multiple independent units dispersed in the multi-cloud environment and yet functioning as one, security is a big concern. Authentication is tricky, more ports are open and APIs are exposed making the app vulnerable to attacks.

Let us observe the testing strategies and types that can be employed for overcoming the above testing challenges. A need to reinvent the traditional test techniques along with a thorough architectural and design understanding is must for QA testers. A good approach could be to refer back to Mike Cohn’s Testing Pyramid. Taking a bottom-up approach to testing and delineating the automation efforts needed at each stage can be helpful.

Focusing mainly on automated software testing, five layers of tests can be performed on Microservices.

Unit Testing: This involves testing the smallest part of the testable software in the application to determine if it behaves as expected, hence the scope is internal to the service. These tests are the largest in terms of volume and should be automated, where possible, providing speed and requisite coverage at a granular level.

This testing further necessitates that the other types of tests must also be performed to ensure that the interactions these software pieces have, with each other and with external dependencies, work correctly.

Component Testing: A component here refers to a coherent and independently replaceable part of a larger system. Component Testing involves testing of the overall functionality of a Microservice, in isolation in a controlled testing environment, by replacing the external collaborators using test doubles and internal API endpoints.

This helps to test error cases in a repeatable fashion, in addition to reducing the build complexity, and provides assistance in better monitoring and debugging by exposing internal controls.

Integration Testing: These tests are conducted by integrating individual Microservices before they are deployed to verify that they collaborate as intended to offer the expected behavior. Basic interaction with data stores and external components is ensured and faster feedback is received.

These tests, along with the Unit tests, guide us if the underlying logic is correct, however, they are not enough to ascertain the overall expected outcomes to satisfy the final intended business requirements. Hence, further testing is needed.

Contract Testing: These tests treat each service as a black box, and are integral to Microservices testing. They test the agreed contract for APIs and other resources offered by the Microservice. All services are summoned independently to verify their responses.

Since consumers define the way in which they would consume the service via consumer driven contracts (a specific output against a given input), the aim of contract testing is to ensure that the Microservices meet the contract expectations, even when changes are made to the services.

End to End Testing: This type of testing includes testing the entire system from end to end, to ascertain that the process flows including services and database integrations operate correctly fulfilling the expected business requirements.

These tests can be difficult to write and maintain, have long execution time, and locating a point of failure at this juncture can be quite expensive to fix. Hence, they should be limited in number, and testing at the core levels must be conducted meticulously and judiciously. This level primarily verifies that the entire system meets the external requirements as a whole, and meets the business goals.

All these tests, when complemented with some level of complex manual QA testing or exploratory testing, can help deliver a quality end product– making the service reliable for the end user.

In a nutshell, testing in Microservices can be quite challenging and complex than the traditional monolithic architecture. It’s important to understand the layers and combine different test approaches for a superior end product. Happy Testing!

Leave a Comment

Your email address will not be published. Required fields are marked *