7 Open Source Tools to Test Microservices
A hybrid architecture based on microservices and container-based infrastructure require different testing strategies since a microservice architecture relies less on in-process components and more on remote dependencies. That means that testing the connections between microservices becomes more time-consuming when there is more remote communication.
Taking the time to test a microservices architecture will help your business ensure that a new release of service will not disrupt the whole system. In this article, we will present the challenges when testing microservices, what kind of tests should be done, and we will present seven open source tools to help you test your microservices.
What are the challenges when testing microservices?
When choosing your testing techniques, time to market, cost, and risk should all be taken into account. In addition to that, it is essential to consider other variables that will certainly affect the way of decoupling a microservice from its dependencies for testing purposes .
On one side, testing microservices is somehow different from testing monolithic applications. First, in a microservices architecture, there is decentralized governance, meaning that every team will choose a different tool to develop their microservices. Consequently, it is not necessary to have a homogeneous testing stack since each team will use the testing techniques that fit their needs. Second, there is a decentralized data management that allows each microservice to manage its own data. Finally, testing, deployment, and infrastructure are typically automated.
On the other side, there might exist some similarities between testing microservices and monolithic applications. For example, testing REST APIs and message brokers (an architectural pattern that mediates communication among applications) is something that software developers are already used to and there are well-established testing tools and practices for that .
Now, you might be wondering, what are the challenges that microservices present. In fact, there are three main challenges: (i) the larger the number of microservices in an application, the harder it is to test, (ii) the microservices are interdependent, and (iii) they should work properly even when other services they depend on are not available or properly working .
So, what should you guarantee when testing microservices?
Microservices should be tested independently. The first thing to check is if the microservice is functioning properly. Normally, this step can be done with API testing tools, such as Apache JMeter. Then, it is essential to test if the microservice is scalable since scalability is one of the advantages of using microservices. Load-testing tools can test if the microservice standup to increasing demand or load . Finally, check if asynchronous communication is working properly. Asynchronous communication in microservices uses specific protocols in which the client is part of a queue and consumes the data when it becomes available.
Hence, there are three main types of tests for microservices :
- Functional tests should be used for testing the business logic and behavior of the service. However, different from monolithic architecture, the interface to be tested is a remote client communicating over a protocol, such as HTTP.
- Resiliency tests will help you determine how well a microservice will react to possible failures of the infrastructure, such as what happens if a server is running a service that is not available?
- Load tests will test the scalability of the service. Hence, many calls are made and with that, the goal is to test if the microservice will crash due to high traffic volume.
Other than that, other types of tests should be taken into account:
- Unit tests to verify if the methods and classes of each microservices work as expected.
- Component tests consist of testing the REST service through automated tests that act as clients, send many requests to the service and verify the response returned by the service. The problem of component testing is that one microservice might need to have other services deployed and available for testing. To mitigate this problem, developers should use service virtualization tools that will allow testers to simulate other microservices and test the microservice itself in isolation.
- Integration tests mean testing if the microservice works with the other real microservices involved. In this test, all required services are deployed and integrated together
- System tests are used to test the microservices interactions with other platforms. For example, the Youtube app on your TV connects to microservices within Youtube’s data center. To do these tests, you need to simulate API calls that the user interface makes to the microservices architecture.
Open Source Testing Tools
We present below some examples of open source testing tools that you could use to test your microservices.
- Apache JMeter is an open source software to do functional tests and measure performance.
- Selenium is an automation testing tool for web apps.
- SoapUI is an open source API test automation framework.
- K6 is a load and performance testing tool for testing cloud-native applications.
- Tsung is a load and stress testing tool.
- Testcontainers supports JUnit tests to test databases, Selenium web browsers, and everything that can run in a Docker container.
- TARS Benchmark is a tool for testing microservices. TARS benchmark is also integrated into the TARS microservices framework.
About the author:
Isabella Ferreira is an Ambassador at TARS Foundation, a cloud-native open-source microservice foundation under the Linux Foundation.