Surya Suravarapu has over 13 years of experience supporting customers in Development and QA areas. He has been part of the customer facing SWAT team with expertise in DevOps products for the last 4 years at CA Technologies, a Broadcom company.

Become a JMeter and Continuous Testing Pro

Start Learning
Slack

Test Your Website Performance NOW! |

arrowPlease enter a URL with http(s)
Dec 24 2020

How to Eliminate Software Testing Constraints with BlazeMeter Mockservices

Imagine you are flying in an airplane. What gives you the confidence that you will be able to reach your destination safely? It is the belief in the engineering that went behind building the plane. More importantly, it is the fact that this plane has been tested to not fail under various conditions. Airplanes just like enterprise software are complex with a lot of interconnected components. And just like airplanes have a number of constraints with testing, we face a similar situation with enterprise software.

 

Mockservices help eliminate constraints by simulating the behavior of the dependent systems. With mock services, we can single out components, integrations and performance, and test their stability and reliability. Mock services eliminate delays in testing, helping us perform better quality testing earlier in the cycle. Let’s break it down further. 

Build and Component Level Testing

Airplanes are built from a large number of components. These include the engine, flap, antenna, fuselage, rudder, slat, spoiler, etc. As these components are being built, they are tested to handle extreme conditions that airplanes are subject to in the real world. However, we cannot wait until the entire airplane is built to test them. Hence, we need to use a simulator to help replicate the real world conditions and test the components during their build. Another thing to note is that testing earlier makes it easier to fix issues, rather than after the components are assembled.

 

Likewise, with enterprise software, we cannot wait for all components to complete their build before testing. This is where build and component level testing come in.

What is build and component level testing?

Build and component level testing involve testing the individual components in isolation. To do this, we need to be able to parallel build. Each component will continue with the build and unit testing without waiting for the dependent systems to be built. This is where the power of mock services will come in handy.

How can mock services help with build and component level testing?

Mock services can simulate the dependent systems according to various scenarios. Eliminate constraints like unavailable systems, lack of data and environments. You might also have some more advanced scenarios. You might require custom matching and need complex protocols like mq, mainframes, Kafka etc.

How can we build mock services for build and component level tests with BlazeMeter?

Mock services can be created by using transactions. (A transaction is a request / response pair associated with a given service). This way, we can continue build and component level testing for components without being constrained by their dependencies. This helps test earlier and test better which is essential for quality testing. 

 

Transactions can be created with a variety of inputs such as Request / Response files, specification files like swagger and wsdl, wiremock and wirelab definitions, codesv definitions and har files. They also provide the ability to record transactions using the Blazemeter proxy recorder.

 

For advanced scenarios, you can take advantage of the mock services integration with enterprise service virtualization, aka DevTest. This provides you with the ability to upload mar files, which can then be used for deployment.

 

In addition, we also have a new offering called Blazemeter VSE, which provides the ability to configure a standalone VSE without the dependencies and ability to deploy devtest native files (mar files). This way, we have all of your service virtualization needs covered.

 

The transactions and mar files are stored in Asset Catalog, which is a repository that provides the ability to filter and search through. Search by using names or tags and use them to create mock services for the application.

 

Fig 1. Asset Catalog - Transactions tab

 

 

Fig 2. Asset Catalog - MAR Files tab

Negative Testing

What is Negative Testing?

There are some extreme conditions, like birds striking an airplane, which are not feasible to recreate in the real world (for obvious reasons). However, we cannot afford to not test for such conditions, because they could have devastating consequences in the real world. This illustrates the importance of negative testing. Hence, for negative scenarios like this, where it is not feasible to recreate, bird strike simulators are used. 

 

Likewise, in Enterprises, teams cannot afford to not perform negative testing. It takes just one incident to cause downtimes, bad customer experience and potential economic losses.

How can mock services help with negative testing?

To replicate scenarios that can be difficult to set up in live test environments, using mock services provides an easy way to simulate the negative conditions. By just replicating and modifying the transactions, users are able to create different data scenarios.

 

These could be boundary conditions or unique data scenarios, recreating timeout, or poor response time scenarios. The latter can be performed by changing the think time or by updating error responses. 

How can BlazeMeter mock services support negative tests?

Examples of negative scenarios:

 

For an S3 bucket retrieve object scenario, the below is a success scenario where retrieval is successful.

 

Fig 3. S3 Bucket retrieve object scenario - Successful transaction

 

If you need to replicate a negative scenario such as Invalid Bucket exception, you can clone the transaction (by clicking on the clone transaction button ). 

 

Fig 4. S3 Bucket retrieve object scenario - cloning the transaction

 

Once done, you can then change the responses to reflect the negative scenarios as shown below. In addition, you can also update the name, description and the tags of the transaction to correctly identify the transaction. 

 

Fig 5. S3 Bucket retrieve object scenario - Error transaction

 

Once you create the mock service by choosing the transactions, you can also update the Think Time of the service to a desired value to induce delays in the response. 

 

Fig 6. Updating Think Time for a mock service

Integration Testing

Once the components of an airplane are built, they need to be integrated and tested to ensure they function well in isolation and with each other. However, as stated before, there is the constraint of cost and the time it takes to test in flight. Simulators help reduce the number of hours it takes to test planes in flight and also reduces cost involved helping test early and better. For this purpose, the components in the simulated plane are arranged just like in the actual plane and are tested to ensure they work well together. This type of testing in aviation terms is called iron bird. This helps test the functions of systems in correlation with others. The integral part of this testing is the simulator that helps simulate various environmental conditions that the plane will go through. 

What is Integration Testing?

Likewise, integration testing in enterprises is essential to ensure the components work well together. There are a number of constraints organizations go through with integration testing, for example:

  1. Unavailability of systems
  2. Cost associated with 3rd party systems
  3. Data related constraints
  4. Environment related challenges

How can mock services help with integration testing?

With mock services, you have the ability to simulate third party services and dependent systems to eliminate constraints relating to availability, cost, data and environments. 

 

For instance, let’s say we have a third party visa transfer as part of a digital bank application. It is possible that the third party is unavailable. This could be due to maintenance, the cost per transaction for testing or the environment is not available for integration testing. That may lead to errors. 

 

Fig 7. Error in bank application due to unavailable 3rd party API.

How can BlazeMeter mock services support integration tests?

We can capture the transactions for the visa transfer scenario using one of the methods described earlier in this blog (such as  request / response files, specification files like swagger and wsdl, wiremock and wirelab definitions, codesv definitions, har files, mar files or using a proxy recorder). Once done, the transactions can then be used to create the mock service as shown below. 

 

Fig 8. Creating a mock service using transactions. 

 

The next step is to update this endpoint in the application and continue testing just like with the real system. This will help continue testing.

 

Fig 9. Successful transfer in the application with mock service in place of 3rd party API.

Performance Testing

It is important to test the airplane for not just the normal conditions but also under stress. It’s important to ensure they are able to handle such conditions in the real world, like increased load on the wings or extreme temperatures. Real world replication is extremely difficult and can also be quite expensive. For this purpose, manufacturers use wind tunnels, load tests for wings, altitude tests, etc. to simulate the extreme stress conditions to ensure the planes can handle the same. 

What is Performance Testing?

Similarly, enterprise applications are subject to varying levels of traffic. The application must be built for optimal performance to handle different load scenarios without impacting the user experience. We all know that bad user experience on the applications can cause loss of revenue and hurt the brand. 

How can mock services help with performance testing?

These load and stress conditions might be difficult to replicate, due to:

  1. Unavailable systems
  2. Cost per transaction for third party services
  3. Lack of dedicated performance environment
  4. Lack of scalability of environments
  5. Limited windows for testing
  6. Lack of environments for shift left performance testing

 

Mockservices have the ability to simulate the load and provide scalability and ease of setup.

How can BlazeMeter mock services support performance tests?

In Blazemeter, link mock services directly to performance and load tests as shown in the following images. This helps configure the transactions and bring up mock services in runtime for the tests, and for supporting the tests. There is also the ability to use transaction templates to choose which transactions (scenarios) you would like to configure. This dependency can also be configured in the test yaml file.

 

The integration with Enterprise solution (VSE) and BlazeVSE also support native devtest files (mar) and support for advanced use cases like mq, kafka etc. and support for custom matching and scripting scenarios. 

 

A test generated by Blazemeter Chrome plugin for the sample digital bank application is as shown below. The dependencies are defined as highlighted.

 

Fig 10. YAML file for performance test with mock service dependencies defined.

 

 

Fig 11. Mock service defined as dependency in the yaml along with the template

 

Once done, the test can be loaded in BlazeMeter and it will show the dependencies automatically. This can also be configured manually in the BlazeMeter screen. 

 

Fig 12. Test created using the yaml for which the mock service is configured automatically (based on dependency in yaml) as shown in the UI.

 

You can also directly configure the mock service endpoint in your application and start testing. This can be done to simulate multiple services that are constrained within your application.
 

Simulators are not necessarily a replacement for your real world testing but will complement and enhance your testing by eliminating constraints faced day to day with your applications and dependent environments. Simulators are a trusted resource with complex machines like airplanes which carry a number of passengers across the world everyday. Likewise, mockservices can help your enterprise applications deliver good user experience and quality applications for end users and in turn help your business. 

 

Ready to get started? Sign up now!

   
arrowPlease enter a URL with http(s)

Interested in writing for our Blog?Send us a pitch!