Define fail criteria for load tests by using Azure Load Testing

In this article, you learn how to define fail criteria or auto stop criteria for your load tests with Azure Load Testing. Fail criteria let you define performance and quality expectations for your application under load. Azure Load Testing supports various client metrics for defining fail criteria, such as error rate or response time. Auto stop criteria enable you to automatically stop your load test when the error rate surpasses a given threshold.

Prerequisites

  • An Azure account with an active subscription. If you don't have an Azure subscription, create a free account before you begin.
  • An Azure load testing resource. If you need to create an Azure Load Testing resource, see the quickstart Create and run a load test.

Load test fail criteria

Load test fail criteria are conditions for client-side metrics, that your test should meet. You define test criteria at the load test level in Azure Load Testing. A load test can have one or more test criteria. When at least one of the test criteria evaluates to true, the load test gets the failed status.

You can define test criteria at two levels. A load test can combine criteria at the different levels.

  • At the load test level. For example, to ensure that the total error percentage doesn't exceed a threshold.
  • At the JMeter request level (JMeter sampler). For example, you could specify a response time threshold of the getProducts request, but disregard the response time of the sign in request.

You can define a maximum of 50 test criteria for a load test. If there are multiple criteria for the same client metric, the criterion with the lowest threshold value is used.

Fail criteria structure

The format of fail criteria in Azure Load Testing follows that of a conditional statement for a supported metric. For example, ensure that the average number of requests per second is greater than 500.

Fail criteria have the following structure:

  • Test criteria at the load test level: Aggregate_function (client_metric) condition threshold.
  • Test criteria applied to specific JMeter requests: Request: Aggregate_function (client_metric) condition threshold.

The following table describes the different components:

Parameter Description
Client metric Required. The client metric on which the condition should be applied.
Aggregate function Required. The aggregate function to be applied on the client metric.
Condition Required. The comparison operator, such as greater than, or less than.
Threshold Required. The numeric value to compare with the client metric.
Request Optional. Name of the sampler in the JMeter script to which the criterion applies. If you don't specify a request name, the criterion applies to the aggregate of all the requests in the script.
Don't include any personal data in the sampler name in your JMeter script. The sampler names appear in the Azure Load Testing results dashboard.

Supported client metrics for fail criteria

Azure Load Testing supports the following client metrics:

Metric Aggregate function Threshold Condition Description
response_time_ms avg (average)
min (minimum)
max (maximum)
pxx (percentile), xx can be 50, 90, 95, 99
Integer value, representing number of milliseconds (ms). > (greater than)
< (less than)
Response time or elapsed time, in milliseconds. Learn more about elapsed time in the Apache JMeter documentation.
latency avg (average)
min (minimum)
max (maximum)
pxx (percentile), xx can be 50, 90, 95, 99
Integer value, representing number of milliseconds (ms). > (greater than)
< (less than)
Latency, in milliseconds. Learn more about latency in the Apache JMeter documentation.
error percentage Numerical value in the range 0-100, representing a percentage. > (greater than) Percentage of failed requests.
requests_per_sec avg (average) Numerical value with up to two decimal places. > (greater than)
< (less than)
Number of requests per second.
requests count Integer value. > (greater than)
< (less than)
Total number of requests.

Define load test fail criteria

In this section, you configure test criteria for a load test in the Azure portal.

  1. In the Azure portal, go to your Azure Load Testing resource.

  2. On the left pane, select Tests to view the list of load tests.

  3. Select your load test from the list, and then select Edit.

    Screenshot of the list of tests for an Azure load testing resource in the Azure portal, highlighting the 'Edit' button.

  4. On the Test criteria pane, fill the Metric, Aggregate function, Condition, and Threshold values for your test.

    Screenshot of the 'Test criteria' pane for a load test in the Azure portal and highlights the fields for adding a test criterion.

    Optionally, enter the Request name information to add a test criterion for a specific JMeter request. The value should match the name of the JMeter sampler in the JMX file.

    Screenshot of the JMeter user interface, highlighting the request name.

  5. Select Apply to save the changes.

    When you now run the load test, Azure Load Testing uses the test criteria to determine the status of the load test run.

  6. Run the test and view the status in the load test dashboard.

    The dashboard shows each of the test criteria and their status. The overall test status is failed if at least one criterion was met.

    Screenshot that shows the test criteria on the load test dashboard.

Auto stop configuration

Azure Load Testing automatically stops a load test if the error percentage exceeds a given threshold for a certain time window. Automatically stopping safeguards you against failing tests further incurring costs, for example, because of an incorrectly configured endpoint URL.

In the load test configuration, you can enable or disable the auto stop functionality and configure the error percentage threshold and time window. By default, Azure Load Testing automatically stops a load test that has an error percentage that is at least 90% during any 60-second time window.

You can use the Azure Load Testing auto stop functionality in combination with an AutoStop listener in your JMeter script. The load test automatically stops when one of the criteria in either the auto stop configuration or the JMeter AutoStop listener is met.

Caution

If you disable auto stop for your load test, you may incur costs even when your load test is configured incorrectly.

To configure auto stop for your load test in the Azure portal:

  1. In the Azure portal, go to your Azure Load Testing resource.

  2. On the left pane, select Tests to view the list of load tests.

  3. Select your load test from the list, and then select Edit. Alternately, select Create > Upload a JMeter script to create a new test.

  4. Go to the Test criteria tab to configure the auto stop functionality.

    • Enable or disable automatically stopping of the load test by using the Auto-stop test control.

    • If you enable auto stop, you can fill the Error percentage and Time window fields. Specify the time window in seconds.

      Screenshot of the 'Test criteria' pane for a load test in the Azure portal, highlighting the auto stop functionality.

  5. Select Apply, or Review + create if you're creating a new load test, to save the changes.

Next steps