Table of contents
1.
Introduction
2.
Types of Practices for Performance Testing 
3.
Running Load Test from Maven 
3.1.
Maven 
3.2.
Requirement 
3.3.
POM File 
3.4.
Running Load Test 
4.
Memory Management 
5.
Refresh OAuth 2.0 Access Token 
5.1.
1. Disable automated refreshing 
5.2.
2. Create a script 
5.3.
3. Create a separate Scenario  
5.4.
4. Schedule Token refreshing 
6.
Frequently Asked Questions
6.1.
What is ReadyAPI?
6.2.
What is the difference between SOAP and REST services?
6.3.
What are some main features of ReadyAPI? 
6.4.
What is the architecture of ready API? 
6.5.
Explain How data-driven testing works in ready API? 
7.
Conclusion
Last Updated: Mar 27, 2024
Medium

Best Practice for Performance Testing in Ready API

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

An intuitive no-code API testing platform called ReadyAPI is intended to make your testing processes more efficient. Scale and automate your end-to-end tests for various API types. Compare your functional tests to compatible load tests. Enable virtualization to give your development teams quick and dependable integrations.

Introduction image

You may perform load testing with Ready API. In order to simulate a heavy load on a website or web service under test, Ready API employs functional test cases. It enables you to assess your server's performance under demand and determine its limitations.

Ready API functions upon virtual users for load simulation. Only a small number of virtual users may be used when doing load tests on your local machine. Depending on your licensing, you can simulate a maximum of a certain number of virtual users at once. You can run distributed load tests and distributed cloud tests if the simulation of many users is needed at once.

Types of Practices for Performance Testing 

Types of practices

There are 3 types of tests for performance testing: 

  • Running Load Tests From Maven
     
  • Memory Management
     
  • Refresh OAuth 2.0 Access Token

Running Load Test from Maven 

If your development environment uses Maven, you can incorporate ReadyAPI Performance tests in your builds. You instruct Maven to download and utilize the ReadyAPI Maven plugin in your project to accomplish this. 

Maven 

Maven is known to be a build automation tool that is used primarily for Java projects. Maven can also be helpful in building and organizing projects written in RubyScalaC#, and a few other languages. The Apache Software Foundation is the host of the Maven project.

If your development environment uses Maven, you can incorporate Ready API Performance tests in your builds. You can instruct Maven to download and utilize the Ready API Maven plugin in your project to accomplish this.

Requirement 

To run load tests via Maven, you must have the following on your computer where you want to run a Maven build:

  • A pom.xml file contains a reference to the Ready API Maven plugin.
     
  • Ready API.
     
  • Your Ready API project file
     

Configuring your environment specifically for running load tests is unnecessary, as Maven will be single-handedly responsible for any required dependencies.

POM File 

The pom.xml File contains information about the build that Maven reads. You must set it up, so it downloads the ReadyAPI plugin from the Maven repository and adds a load test to the build cycle's test phase. 

Running Load Test 

Use the Maven test command in the folder containing your pom.xml File to launch the load test. The load test will be done using this command, and reports will be produced. For instance:

C:/Work/MvnCoder>mvn test


Use the site command in its place if your tests generate reports using the Maven SureFire plugin.

C:/Work/MvnCoder> mvn site

Memory Management 

Memory Management

To understand how your web service responds to load, ReadyAPI gathers data on the target web service performance throughout test runs.

However, collecting and storing a lot of test data when ReadyAPI conducts a lengthy load test will use up a lot of your computer's RAM. This can make the test run take longer or result in other ReadyAPI performance issues.

To avoid possible performance issues and run large load tests more efficiently, reduce the amount of collected data by the given methods: 

  • Reduce the amount of information ReadyAPI gathers for claims: The assertions you include in your load tests check to see if the test results adhere to the given criteria and report errors if they don't. Set ReadyAPI up to only gather summary information on assertion errors:
    • Step 1: Choose File> Preferences from the main menu or click Preferences on the toolbar.
       
    • Step 2: Change to the ReadyAPI tabbed page in the ReadyAPI Preferences dialog.
       
    • Step 3: Uncheck the box next to Complete Error Logs.
       
  • Specify a maximum number of points for charts: To draw the complete charts during the lengthy load tests, a lot of memory may be needed. To limit the maximum number of points utilized to build a chart, use the Dloadui.charts.maxpoints=value> JVM option. The oldest point is deleted from memory when ReadyAPI reaches the predetermined amount of points, preventing the chart from starting at zero. It impacts graph views on the Statistics page, graphs converted to printable reports, and graphs displayed on the Load page. The only data impacted by this option is that used to create charts. Using table views, you can look at the test's overall statistics.
     

It should be noted that the load testing is unaffected by the underlying test case's option to discard successful results. Throughout the load test run, ReadyAPI always discards successful results. 
 

  • Discard the responses. Configure the functional test on which your load test step is based to throw away answers provided by the target web service to lessen the memory required to simulate test steps:

     
  • Step 1: Open the test case based on your load test in Functional Tests.
     
  • Step 2: Go to the REST Request Properties tab after selecting a test step.
     
  • Step 3: Set Discard Response to true under the REST Request Properties tab.
     
  • Close the response window while the test is running: Close the Response window to stop ReadyAPI from gathering response data throughout the test run. Otherwise, ReadyAPI will collect and display response data regardless of the settings you selected.

Refresh OAuth 2.0 Access Token 

An access token is used to authorize a request in OAuth 2.0 authorization. You must refresh an access token because it eventually expires. When an access token needs to be updated during a load test, ReadyAPI can do it automatically, but automated refreshing might fail. This leads to issues since several virtual users simultaneously attempt to obtain a fresh access token. The method for refreshing an access token during a load test is described in this topic.
Disable automated refreshing to prevent several virtual users from refreshing an access token. Refresh an access token from a different scenario that is only being used by one virtual user instead. Use the Groovy script test step to renew an access token while it's running unattended. 

  1. Disable automated refreshing
     
  2. Create a script
     
  3. Create a separate scenario
     
  4. Schedule token refreshing 

1. Disable automated refreshing 

Set the Refresh Access Token advanced option to Manual to stop an access token from being automatically refreshed. Either the Auth Manager or the Auth panel can be used to accomplish this: 

  1. Open the Auth Manager.
     
  2. Click Advanced after choosing the required profile.
     
  3. Click OK after setting the Refresh Access Token to Manual. 

2. Create a script 

Using the Groovy script test step from a different test case, update the access token: 

  1. Create a new test case. 
     
  2. the step for testing the Groovy script.
     
  3. The script below should be used to update an access token. 
// Import the required classes
import com.eviware.soapui.impl.rest.actions.oauth.OltuOAuth2ClientFacade;
import com.eviware.soapui.support.editor.inspectors.auth.TokenType;
import com.eviware.soapui.model.support.ModelSupport;


// Get a project
def project = ModelSupport.getModelItemProject(context.getModelItem());


// Get the needed authorization profile
def authProfile = project.getAuthRepository().getEntry("Ora Bannet");


//Create a facade object
def tokenType = TokenType.ACCESS;
def oAuthFacade = new OltuOAuth2ClientFacade(tokenType);


// Request an access token in headless mode and assign it to the authorization profile we got earlier
oAuthFacade.requestAccessToken(authProfile, true, true);


// Access token retrieval may take time, so we need to pause the execution for 3 seconds to finish it. You may increase this value if needed.
sleep(3000);


// Posts a new token to the script log
log.info("Set new token: " + authProfile.getAccessToken());

3. Create a separate Scenario  

You must execute the prepared test case from a different scenario that is executed by a single virtual user if you want to run the script just once.
 

  1. Open a new scenario in the load test 
     
  2. As a new target, including the test case that contains the Groovy script test step 
     
  3. In the scenario, choose a different target, and then click delete to eliminate it. 
     
  4. Set the Load Allocation to Per Scenario 
     
  5. Set VUs to 1 and choose the newly constructed scenario. To prevent the scenario from occurring again, increase the Wait time setting as well. 

4. Schedule Token refreshing 

  1. Select the created scenario when you open the Scheduler page.
     
  2. Enter the following choices in the Inspector
  • Custom Scheduling should be enabled.
     
  • Choose a Delay Before Start number that is just a little bit less than the access token lifetime. If your access token, for instance, expires after 20 minutes, enter 19 instead.
    Note: Be sure the procedure for obtaining the new token is completed before the current one expires.
    Tip: Use the Time units option to alter the time units.
     
  • Set the Duration option's value to be less than the scenario's Wait Time option.
     
  • Turn on the Repeat setting.

Frequently Asked Questions

What is ReadyAPI?

A tool for functional and load testing of web services is called ReadyAPI.

What is the difference between SOAP and REST services?

The SOAP protocol, which outlines a set of guidelines for data formatting and exchange, is the foundation upon which SOAP services are built. The REST architectural style, which outlines a set of guidelines for how data should be arranged and accessed, is the foundation upon which REST services are built. 

What are some main features of ReadyAPI? 

A tool for creating and running API tests is called ReadyAPI. It has tools for building test plans, executing tests, and producing reports. Additionally, it includes a mocking tool that can be used to simulate API responses while testing.

What is the architecture of ready API? 

Built on top of SoapUI is the API testing platform known as ReadyAPI. While ReadyAPI offers extra features for load testing, security testing, and virtualization, SoapUI is used for functional testing. 

Explain How data-driven testing works in ready API? 

With ReadyAPI's data-driven testing, you can write a test case that can be executed multiple times with various data sets. This is helpful when testing web services or APIs because you may need to test them with various inputs to see how they react. You must first construct a data source, which might be a file or database, in order to set up data-driven testing. The next step is to develop a test case that takes advantage of the data source. Last but not least, you can run the test case numerous times with various data sets to observe how the system behaves.

Conclusion

In this article, we discussed the best practices for performance testing in ready API such as maven, memory management, and refreshing access token. 

Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. Enrol in our courses and refer to the mock test and problems available; look at the Top 150 Interview Puzzles interview experiences, and interview bundle for placement preparations. Read our blogs on aptitudecompetitive programminginterview questionsIT certifications, and data structures and algorithms for the best practices. 

Live masterclass