Open Source Testing for Microservices
These days product companies around the world depend on cloud technologies to sell products quickly and efficiently. With fewer people sitting in front of a computer to buy online these days, push notifications are used to urge users to sign into a mobile app and check out newly launched products. This push strategy has worked magically. Nowadays people buy products on the fly, which in turn has led to a huge increase in application server loads. Companies like Amazon, Netflix and eBay are responding by abandoning traditional software architectures and moving to microservices. Read more about this important trend below.
What Are Microservices?
Traditional software architectures stack all software features and modules into a single code base that connects to one underlying database. But this approach makes it a challenge to add new features to an existing application. Companies needed a new architecture that would make it easy to plug in new modules and modify existing features.
Netflix was one of the first to come up with a “microservices” architecture that lets software evolve and scale to meet business needs. This new approach splits the whole application into small, independent modules that can be separately tested and deployed.
Now large “e-tailers” like Amazon create different microservices for each of their features, such as Login, Signup, Checkout, Payments, Search, etc. This allows them to add more and more features and to support different devices and platforms – scaling up to meet -demand.
Anatomy of Microservices
Scalable microservices architectures allow a large application to be built from a number of decoupled modules. This approach is especially useful when you plan to support a range of devices, from web to mobile to IoT devices and more.
Though microservices are independent and are not coupled to each other, it's important that they communicate on regular basis – especially to share basic information about their state. This communication happens through an API interface and a lightweight communication/data transfer architecture called REST (REpresentational State Transfer). Data can then be transferred asynchronously between various microservices.
This approach makes microservices ideal for IoT and cloud-based systems and services. JSON, which is considered the preferred data interchange model for the cloud, further catalyzes the abilities of microservices.
In the microservices architecture illustrated below, the dotted lines represent asynchronous communication between the microservices modules, while the arrows represent REST communication.
What to Test in Microservices?
Since each microservice contains a small module or feature, it’s mighty important that they be tested independently. It’s also important that you consider various factors while testing a microservice.
Does It Function Properly? The most important thing to test is the functionality of the microservice. This can be carried out using API testing tools. Apache JMeter™ would be one great choice. JMeter has the power to drive the input data from a data source (such as csv file), which makes testing different scenarios for different sets of data very simple. This can be easily set up in a few steps as explained here.
Is It Scalable? A prime benefit of microservices is scalability. So it’s important to know that services scale to withstand increasing demand or load. This can be tested using a load-testing tool, and none is better than JMeter. The steps for load testing are the same as for functionality testing. You just use different load test patterns in the thread group in order to test for different scenarios.
Does Asynchronous Communication Work Properly? Microservices communicate with each other asynchronously to keep a basic understanding of each other. But this asynchronous dialog works a bit differently than an HTTP protocol. Asynchronous data transfer makes use of protocols such as JMS, where the client subscribes to a queue and consumes the data when it becomes available. This method allows microservices to be less dependent on each other. Asynchronous data transfer can be tested easily using JMeter. JMS samplers (JMS Publisher and Subscriber) in JMeter are specifically designed for this and are described here.
Microservices Testing Tools
Though there are many open-source and commercial testing tools available, JMeter is certainly the most popular. Let’s take a look at the advantages of JMeter over other tools when it comes to testing microservices:
Various Samplers to Test Different Protocols - For data transfer, microservices use both REST over HTTP and async (typically JMS protocol). To test these methods separately, we have both HTTP Request and JMS samplers available in JMeter.
Parameterization - Test data can be driven from a csv file, which can be supplied as input to any HTTP request. This parameterization is a powerful testing technique. It makes testing less time consuming, yet gives better test coverage. Test parameters can be easily set up in JMeter in a few seconds.
Powerful Data Extractors - As you do end-to-end testing of microservices, you may need to pass some data responses from previous requests to subsequent requests. JMeter provides powerful data processors – such as JSON extractor, Regex Extractor, etc. – that can be easily set up to extract the data needed.
Response Assertions - To validate the response of a microservice, you may need to compare the response to a reference output. JMeter has number of response assertion techniques to validate output.
Integration with Build and CI Tools - JMeter can be easily integrated with build tools like Gradle or Maven so that tests can be run as part of your builds. JMeter also can be integrated with CI tools like Jenkins to enable continuous deployment and testing, which is a key factor while testing microservices.
Scalability and Functionality Testing in One Tool - JMeter allows you to test both the performance and the functionality of the services using the same test configuration, which makes JMeter preferred over any other tool.
It’s Free! JMeter comes from the open-source community, so it’s free to use. Also, you have a lot of online courses available to teach you to use the tool easily, with very little learning curve. BlazeMeter provides an online learning portal called JMeter Academy that can help you become a JMeter pro within a few weeks!
How Does BlazeMeter Enhance JMeter Testing?
Running tests from local JMeter instances on your machine is not ideal if you plan to scale your tests for multiple configurations and thousands of users. When you use BlazeMeter, though, you can extend and expand your JMeter testing capabilities:
- Run your tests for hundreds of thousands of users from different geographic locations to simulate real user scenarios.
- Set up tests easily by uploading JMeter scripts to BlazeMeter.com.
- Use a Chrome plugin for easy recording of your test scenarios.
- Analyze results using real-time reports and interactive graphs.
- Share reports and collaborate with your colleagues.
- Easily integrate with CI tools.
The Bottom Line
BlazeMeter is the best choice to test your microservices since it blends with open-source tools such as JMeter really well. You can work offline on your local JMeter tool to build your script, and then simply upload it to the BlazeMeter cloud to run your tests. Well-written user manuals and talented support engineers help you achieve your testing goals.
Learn more about other challenges facing today’s testing Center of Excellence (CoE), and how making the move to an open-source testing platform can ensure your testing team’s future relevance. Visit www.blazemeter.com/shiftleft to understand how open-source tools can help you eliminate bottlenecks, provide decentralized test coverage for your Agile developers, broker appropriate test resources, integrate upstream and downstream workflows, and ensure continuous improvements that benefit both your developers and their customers.
Next try out BlazeMeter. Simply request a demo and see how your test starts in minutes!
You might also find these useful:
Interested in writing for our Blog? Send us a pitch!