This is why we need modern service virtualisation
As we work more with distributed systems, microservices and legacy services, we introduce a web of inter-service dependencies that cause us to face many challenges across our development and deployment pipeline. Resource consumption, deployment time, our testing feedback cycle, third party service flakiness and costing can cause problems. We talked to Andrew Morgan, Consultant at OpenCredo and speaker at the upcoming JAX London about how the technique of ‘API Simulation’ (modern service virtualisation) can be used to overcome these issues.
Andrew Morgan, consultant at OpenCredo and JAX London speaker, claims that the technique of ‘API Simulation’ (modern service virtualisation) can be used to overcome issues such as resource consumption, deployment time, our testing feedback cycle, third party service flakiness and costing which appear across our development and deployment pipeline when we introduce a web of inter-service dependencies. We invited him to talk about (micro)service virtualisation in the 21st century.
JAXenter: Your session at JAX London is called Simulating APIs for Effective Testing: (Micro)Service Virtualisation in the 21st Century. What does (micro)service virtualization in the 21st century mean?
Andrew Morgan: “Service Virtualisation” is a term more commonly used in enterprise space – it’s basically the act of emulating an external service. It’s also mainly associated with clunky and expensive desktop applications that are hard to manage.
Modern service virtualisation means adopting this practice in a modern development environment – so open source tooling, high degrees of automation, CLI or API-driven etc.
JAXenter: Do you have some tips that can help users improve their application testing?
Andrew Morgan: Over the last few years, I have seen some microservice projects where the distributed monolith anti-pattern has been implemented. This basically means that even if you make a change to a single service, you have to deploy everything to an end-to-end test environment and run all the tests before releasing. This is because you simply don’t know whether services are going to collaborate until communication between real instances occurs.
Applications are becoming more and more distributed so things are only going to get more complex.
I’d recommend trying the consumer-driven contract testing pattern, which enables you to define contracts containing your expectations of a producer by the consumers. With the right framework, stub (or virtual) versions of the producer are created for you from these contracts, allowing you to test your consumer in isolation of the producer. On the opposite side, you can auto-generate tests from these contracts and then run them against the producer to make sure it complies. This means you can test and release a consumer or producer independently, as collaboration is ensured by the CDC – removing reliance in end-to-end testing and achieving one of the main goals of microservices, which is to be able to build and release a service independently.
JAXenter: Why do interservice dependencies cause us to face many challenges across our development and deployment pipeline and how can we solve this problem?
Andrew Morgan: I’ve already covered problems with the distributed monolith anti-pattern, but there are others as well. Some of these are often issues around testing with third party services, such licensing costs, rate limits, unreliability etc. There’s also the situation where you have ownership of an API and need to consider how to allow consumers to be able to test against you with ease. Applications are becoming more and more distributed so things are only going to get more complex.
API simulation involves creating a lightweight copy of an external service and using it under test.
JAXenter: How can we use the technique of “API Simulation” to overcome these issues? Could you give me some examples?
Andrew Morgan: API simulation involves creating a lightweight copy of an external service and using it under test. For example, if you wanted to check your integration points with an airline reservation service, you might not want to use their sandbox instance as it’s non-deterministic and flaky.
JAXenter: Why should people come to your talk?
Andrew Morgan: I feel most developers will have some sort of experiencing stubbing web servers in order to run some tests, but I want to look at the problem space in more detail. I’ll cover a lot of examples of testing problems, give an overview of service virtualisation, apply some patterns to improve our tests, and also talk about the problems of stale data in tests.
Thank you very much!
Andrew Morgan will be delivering one talk at JAX London which will focus on demonstrating how the technique of ‘API Simulation’ (modern service virtualization) can be used to overcome issues such as resource consumption, deployment time, our testing feedback cycle, third party service flakiness and costing.