Microservices Continuous Testing with Talend API services

Applying continuous integration and deployment (CI/CD) to microservices has been very popular over the years. However, complex applications require many microservices, thus leading to even more complexity. Today, automating the integration and deployment of such microservices has become the norm for most development teams but continuous testing is often overlooked in the CI/CD workflow.

 

In this article we will refer to microservices as implementing APIs. And more specifically, RESTful APIs. However, many of the same principles that apply here are also relevant for other types of APIs.

 

Microservices were introduced to replace monolithic applications that were hard to understand and test and certainly microservices allow you to maintain and test each logical function of your application more efficiently. However, one of the most significant drawbacks is the overall effort required to test the end-to-end application. While, microservices give you more scalability, they also raise new concerns such as network bandwidth resilience among other bottlenecks.

 

So, when it comes to testing microservices your options remain limited. Testing your development with unit tests is valuable but at some point, you need to deploy your microservices and test them in some real-world scenarios. This is even more evident when deploying several microservices that depend on each other through different testing environments.

 

Let’s look at the different testing strategies you can adopt to test your microservices and APIs and how Talend can help.

 

Microservice testing strategies

I chose to present the different testing strategies through the two main steps of CI/CD. Indeed, automating your tests makes more sense if your software lifecycle is also automated.

 

Continuous Integration Continuous Deployment
Staging Environment Production Environment

Unit Testing

Meant to test a small piece of behavior. Typically, unit tests are designed at the class level.


 

 

 

Component Testing

Test a whole service deployed in a staging environment (network calls, and basic features). Dependencies on other services are mocked.

Resilience Testing

Stress a system or application to test how it reacts to failures. It includes scaling testing and fault tolerance testing.

Contract Testing

Based on API contracts defined upfront, contract testing is meant to test the API boundaries with a defined set of inputs and outputs.

Integration Testing

Tests all interactions between services deployed in a staging environment.

End-to-End Testing

End-to-end scenario testing including UI and sanity tests.

 

As you can notice, continuous testing is present at every step in the CI/CD process. Depending on your needs you may choose not to implement all of them, rather, focus on the most relevant tests for your application.

 

How Talend API services can help you

Talend API services offers you several possibilities to help you test your API microservices. Talend has two main products around API Services: Talend API Designer and Talend API Tester.

api_designer.png

 

While our focus will be on Talend API Tester as its very purpose is testing, the Talend API Designer has a part to play in our testing journey and especially in a contract first API development.

Talend API Designer

Talend API Designer is a web-based product allowing you to define your API contracts. What does that mean? The contracts describe how your API must behave including expected responses and format as well as error handling. Basically, it’s the technical documentation of your APIs. Working upfront on your API contracts will help you build your microservices as well as develop the right tests.

And that’s not all! Talend API Designer also let you generate mocks from the API contracts you create. By enabling mocks, you can really test your API behavior during the design phase as well as during the test phase with Talend API Tester. It’s particularly interesting in order to achieve component testing and contract testing where some parts can be mocked.

In contract first API development, the contract also helps the developers understand the business logic behind the API microservices. This allows them to create a well-designed microservice with greater collaboration between the different teams.

Talend API Tester

Talend API Tester is an application allowing you to create test scenarios that simulate real use cases and test every boundary of your microservices. While you would think that creating your test scenarios would come after the microservices are developed and built, a best practice is to think of your tests upfront as well. Why? If the contracts help developers understand the business logic, the tests help them understand the boundaries of the APIs behavior. How many times do we see developers finding out a new edge case during the quality assurance phase? Establishing test scenarios even before starting to develop the microservice APIs will improve development and reduce edge case errors.

Talend API Tester is the tool that you are going to use to create component tests, contract tests and integration tests. These tests can be automated in your CI/CD workflow thanks to our integration with Maven and therefore most of the relevant CI/CD tool such as Jenkins, GitLab, Azure DevOps or GitHub Actions.

Conclusion

To sum up, continuous testing has a significant role in your continuous integration and continuous deployment workflow. Ideally, defining API contracts and test scenarios upfront will simplify and improve your productivity and quality in terms of API microservices. Both Talend API Designer and Talend API Tester are easy-to-use, web-based applications. API Designer allows you to design and document API contracts while Talend API Tester gives you the flexibility to produce relevant API tests and real-world scenarios for a comprehensive API solution.

Version history
Revision #:
2 of 2
Last update:
‎03-20-2020 02:03 PM
Updated by:
 
Labels (1)
Contributors