5 Load test scripts for your API

Tram Ho

When downloading API tests, you need to use different loading conditions to see how the API handles them. Here are some questions your download test will answer:

How many users can work with the API at the same time? How long can users work with the API before rebooting is needed? What happens if a large number of users are working with the API for a long time? What happens if a user mutation that the API cannot handle happens? Here is an introduction to the five different scenarios you can test:

Basic test

You can use this load testing strategy to base your next load tests or to evaluate how your API works under a service level agreement (SLA).

Your test will help you determine which feedback is normal for the API. You can then use these values ​​to set up validation in other tests. You may also find API issues or TestCase goals that will prevent longer load tests from running correctly. This is also a good way to check if your API is working under SLA.

To estimate API performance, add assertions and the API monitor checks the response time, the size of the transmitted data, and other values ​​your SLA can reference.

The test for pressure

Stress testing means simulating heavy loads on the API to find the maximum number of users the API can handle. This number is also known as collision point

Crash score does not necessarily mean the API is crashing or hanging. That could mean the error started to occur either the API performance or the response time dropped below the level defined by your service level agreement (SLA).

You will need to create API validators and monitors to check API responses according to the limits specified in your SLA. When responses take longer than the specified SLA, your API is out of processing, or errors start to occur – you have reached the maximum capacity of the API.

Immersion test

You use the immersion test to find problems that arise during extended work with the API, such as API memory leaks.

Ideally, at the end of the test run, the API performance should have the same performance as the test started. A drop in performance may indicate that the API code has some problems.

Test parameters

To create an immersion test:

  • Use fixed load configuration, variance or a combination of both.
  • Configure the configuration settings to simulate a load slightly higher than the expected average load.
  • Set a very long test time. Ideally, immersion testing should run for more than a day
  • Generate API validators and validators that will help you evaluate API performance.

Check peak

Use peak testing to test how your API works during the busiest times. The peak test is similar to the immersion test, but with much heavier loads and shorter duration.

To create a peak test:

  • Use the Ramp Sequence or Variance load profile. You can also run tests with fixed parallel load configuration to simulate background load.
  • Simulate the load close to the expected maximum load on the API, while also providing some breathing space.
  • Set a long test duration, for example, half a day
  • Generate API validators and validators that will help you evaluate API performance.

Mutation test

Spike Testing helps you check how the tested API responds to a spike in the number of users. The API will be able to stabilize and return to normal operation after a spike.

To create a spike test, use the Burst load configuration. It helps you simulate a short group of users that exceed the maximum expected load. Later or in parallel, run another load test to test how the API handles spikes. If you simulate the Burst download configuration with Speed ​​download type, the test will generate a large number of virtual users coming to the API. This will simulate a spike that can easily overwhelm the API. If you simulate the Burst load configuration with the VU download type, you can specify the number of top correct users that will work with the API. The test will simulate the number of specified users, even if the API response slows down.

Performance tests require the right toolkit

As you can see, there are a number of tests you can run to ensure the performance of the API. Although load testing is necessary, your performance strategy will extend throughout the API’s life cycle. Fortunately, with a tool like the API ready, you can reuse functional tests to set up the screen for the API when it’s in production.

ReadyAPI combines the power of soapUI Pro, LoadUI Pro, ServiceV, and Monitoring API in AlertSite into one single application. From functional testing, performance testing to post-deployment monitoring, SmartBear’s API tools help you deliver accurate, fast and secure APIs.

Reference: https://www.soapui.org/learn/load-testing/5-load-testing-scenarios-for-your-api.html

Share the news now

Source : Viblo