Skip to content

Latest commit

 

History

History
514 lines (426 loc) · 27.3 KB

reference-test-config-yaml.md

File metadata and controls

514 lines (426 loc) · 27.3 KB
titletitleSuffixdescriptionservicesms.servicems.topicms.authorauthorms.dateadobe-target
Load test configuration YAML
Azure Load Testing
Learn how to configure a load test by using a YAML file. The YAML configuration is used for setting up automated load testing in a CI/CD pipeline.
load-testing
azure-load-testing
reference
ninallam
ninallam
12/06/2023
true

Configure a load test in YAML

Learn how to configure your load test in Azure Load Testing by using YAML. You use the test configuration YAML file to create and run load tests from your continuous integration and continuous delivery (CI/CD) workflow.

Load test YAML syntax

A load test configuration uses the following keys:

KeyTypeRequiredDefault valueDescription
versionstringYLoad test specification version. The only supported value is v0.1.
testIdstringYUnique identifier of the load test. The value must be between 2 and 50 characters ([a-z0-9_-]). For an existing test, you can get the testId from the test details page in the Azure portal.
testNamestringNDeprecated. Unique identifier of the load test. This setting is replaced by testId. You can still run existing tests with the testName field.
displayNamestringNDisplay name of the test. This value is shown in the list of tests in the Azure portal. If not provided, testId is used as the display name.
descriptionstringNShort description of the test. The value has a maximum length of 100 characters.
testTypestringYTest type. Possible values:
  • URL: URL-based load test
  • JMX: JMeter-based load test
  • Locust: Locust-based load test
testPlanstringYReference to the test plan file.
  • If testType: JMX: relative path to the JMeter test script.
  • If testType: Locust: relative path to the Locust test script.
  • If testType: URL: relative path to the requests JSON file.
engineInstancesintegerYNumber of parallel test engine instances for running the test plan. Learn more about configuring high-scale load.
configurationFilesarray of stringNList of external files, required by the test script. For example, JMX fragment files, CSV data files, images, or any other data file.
Azure Load Testing uploads all files in the same folder as the test script. In the JMeter script or the Locust script, only refer to external files using the file name, and remove any file path information.
failureCriteriaobjectNL oad test fail criteria. See failureCriteria for more details.
autoStopstring or objectNAutomatically stop the load test when the error percentage exceeds a value.
Possible values:
- disable: don't stop a load test automatically.
- object: see autostop configuration for more details.
propertiesobjectN
  • If testType: JMX: JMeter user property file references.
  • If testType: Locust: Locust configuration file references.
See properties for more details.
zipArtifactsarray of stringNSpecifies the list of zip artifact files. For files other than the main test script and user properties for JMeter-based tests and Locust script and configuration files for Locust-based tests, if the file size exceeds 50 MB, compress them into a ZIP file. Ensure that the ZIP file remains below 50 MB in size. Only 5 ZIP artifacts are allowed with a maximum of 1000 files in each and uncompressed size of 1 GB. Only applies for testType: JMX and testType: Locust.
splitAllCSVsbooleanNFalseSplit the input CSV files evenly across all test engine instances. For more information, see Read a CSV file in load tests.
secretsobjectNList of secrets that the Apache JMeter or Locust script references. See secrets for more details.
envobjectNList of environment variables that the Apache JMeter script or Locust references. See environment variables for more details.
certificatesobjectNList of client certificates for authenticating with application endpoints in the JMeter or Locust script. See certificates for more details.
appComponentsobjectNList of server -side resources to monitor during the load test. See appComponents for more details.
subnetIdstringNResource ID of the virtual network subnet for testing privately hosted endpoints. This subnet hosts the injected test engine VMs. For more information, see how to load test privately hosted endpoints.
publicIPDisabledbooleanNDisable the deployment of a public IP address, load balancer, and network security group while testing a private endpoint. For more information, see how to load test privately hosted endpoints.
regionalLoadTestConfigobjectNDistribute load across regions to simulate user traffic from multiple regions. For more information, See regional load test configuration for more details.
referenceIdentitiesobjectNList of managed identities used in the test for accessing the secrets from your Azure Key Vault, metrics for server-side failure criteria and authentication of your endpoints. See referenceIentities for more details.

Load test configuration sample

The following YAML snippet contains an example load test configuration.

version: v0.1testId: SampleTestdisplayName: Sample Testdescription: Load test website home pagetestPlan: SampleTest.jmxtestType: JMXengineInstances: 1subnetId: /subscriptions/abcdef01-2345-6789-0abc-def012345678/resourceGroups/sample-rg/providers/Microsoft.Network/virtualNetworks/load-testing-vnet/subnets/load-testingconfigurationFiles: - 'sampledata.csv' - ‘testfragment.jmx’zipArtifacts: - bigdata.zipsplitAllCSVs: TruefailureCriteria: - avg(response_time_ms) > 300 - percentage(error) > 50 - GetCustomerDetails: avg(latency) >200autoStop: errorPercentage: 80timeWindow: 60secrets: - name: my-secretvalue: https://akv-contoso.vault.azure.net/secrets/MySecret/abc1234567890def12345keyVaultReferenceIdentity: /subscriptions/abcdef01-2345-6789-0abc-def012345678/resourceGroups/sample-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/sample-identity

failureCriteria configuration

Test fail criteria enable you to define conditions to determine if a load test run was successful or not. If one or more fail criteria are met, the test gets a failed test result. Learn more about using load test fail criteria. You can define failure criteria on client metrics, such as response time, latency, etc., and on server-side metricc for your server-side app components.

Client metrics

You can define fail criteria that apply to the entire load test, or that apply to a specific request. Fail criteria have the following structure:

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

Azure Load Testing supports the following client metrics:

MetricAggregate functionThresholdConditionDescription
response_time_msavg (average)
min (minimum)
max (maximum)
pxx (percentile), xx can be 50, 75, 90, 95, 96, 97, 98, 99, 999 and 9999
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.
latencyavg (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.
errorpercentageNumerical value in the range 0-100, representing a percentage.> (greater than)Percentage of failed requests.
requests_per_secavg (average)Numerical value with up to two decimal places.> (greater than)
< (less than)
Number of requests per second.
requestscountInteger value.> (greater than)
< (less than)
Total number of requests.

Server-side metrics

You can define fail criteria on server-side metrics for your server-side app components.

The following table describes the different fields in the serverMetrics: configuration:

ParameterDescription
resourceIdRequired. The resource ID of app component on which the criteria should be applied
metricNamespaceRequired. The server-side metric namespace.
metricNameRequired. The server-side metrics on which the criteria should be applied.
aggregationRequired. The aggregation to apply on the server-side metrics.
conditionOptional. The comparison operator, such as greater than, or less than.
valueRequired. The numeric value to compare with the metric.

Failure criteria configuration sample

The following code snippet shows a load test configuration, which has three load test fail criteria.

version: v0.1testId: SampleTestdisplayName: Sample Testdescription: Load test website home pagetestPlan: SampleTest.jmxtestType: JMXengineInstances: 1failureCriteria: clientMetrics: - avg(responseTimeMs) > 300 - percentage(error) > 50 - getCustomerDetails: avg(latency) > 200serverMetrics: - resourceId: /subscriptions/abcdef01-2345-6789-0abc-def012345678/resourceGroups/sample-rg/providers/Microsoft.Compute/virtualMachines/sample-vmmetricNamespace: Microsoft.Compute/virtualMachinesmetricName: Percentage CPUaggregation: Averagecondition: GreaterThanvalue: 80 - resourceId: /subscriptions/abcdef01-2345-6789-0abc-def012345678/resourceGroups/sample-rg/providers/Microsoft.Compute/virtualMachines/sample-vmmetricNamespace: Microsoft.Compute/virtualMachinesmetricName: Available Memoryaggregation: Averagecondition: LessThanvalue: 20

appComponents configuration

You can monitor server-side resources during the load test. Learn more about monitoring server-side resources. When you run a load test for an Azure-hosted application, Azure Load Testing collects resource metrics for your application components and presents them in the load testing dashboard.

The following table describes the different fields in the appComponents: configuration:

ParameterDescription
resourceIdRequired. The resource ID of app component on which the criteria should be applied.
resourceNameOptional. The name of the resource to be monitored.
kindOptional. The kind of the resource to be monitired.
metricsRequired. The list of metrics to be monitored for the app component. This contains the name, namespace, and aggregation for the metric.

App Components configuration sample

The following code snippet shows a load test configuration, which has two app components.

version: v0.1testId: SampleTestdisplayName: Sample Testdescription: Load test website home pagetestPlan: SampleTest.jmxtestType: JMXengineInstances: 1appComponents: - resourceId: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appComponentResource"resourceName: appComponentResource #Optionalkind: web # Optionalmetrics: - name: "requests/duration"namespace: microsoft.insights/components aggregation: "Average" - name: "requests/count"aggregation: "Total"namespace: microsoft.insights/components  - resourceId: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appComponentResource"resourceName: appComponentResource #Optionalkind: web # Optionalmetrics: - name: "requests/duration"aggregation: "Average"namespace: microsoft.insights/components - name: "requests/count"aggregation: "Total"namespace: microsoft.insights/components

autoStop configuration

The load test autostop functionality enables you to automatically stop a load test when the error percentage exceeds a specific threshold during a given time window. Learn more about the load test autostop functionality.

KeyTypeDefault valueDescription
errorPercentageinteger90Threshold for the error percentage, during the timeWindow. If the error percentage exceeds this percentage during any given time window, the test run stops automatically.
timeWindowinteger60Time window in seconds for calculating the errorPercentage.

Autostop configuration sample

The following code snippet shows a load test configuration, which has three load test fail criteria.

version: v0.1testId: SampleTestdisplayName: Sample Testdescription: Load test website home pagetestPlan: SampleTest.jmxtestType: JMXengineInstances: 1autoStop: errorPercentage: 80timeWindow: 60

properties configuration

You can specify a JMeter user properties file for your load test. The user properties file is uploaded alongside the test plan and other files. Learn more about using JMeter user properties in Azure Load Testing.

KeyTypeDefault valueDescription
userPropertyFilestringFile to use as an Apache JMeter user properties file or a Locust configuration file. For Locust, files with extensions .conf, .ini and .toml are supported as a configuration file. The file is uploaded to the Azure Load Testing resource alongside the test script and other configuration files. If the file is in a subfolder on your local machine, use a path relative to the location of the test script.

User property file configuration sample

The following code snippet shows a load test configuration, which specifies a user properties file.

version: v0.1testId: SampleTestdisplayName: Sample Testdescription: Load test website home pagetestPlan: SampleTest.jmxtestType: JMXengineInstances: 1properties: userPropertyFile: 'user.properties'

The following code snippet shows a load test configuration, which specifies a Locust configuration file.

version: v0.1testId: SampleTestdisplayName: Sample Testdescription: Load test website home pagetestPlan: SampleTest.pytestType: LocustengineInstances: 1properties: userPropertyFile: 'locust.conf'

secrets configuration

You can store secret values in Azure Key Vault and reference them in your test plan. Learn more about using secrets with Azure Load Testing.

KeyTypeDefault valueDescription
namestringName of the secret. This name should match the secret name that you use in the test plan requests.
valuestringURI (secret identifier) for the Azure Key Vault secret.

Secrets configuration sample

The following code snippet shows a load test configuration, which references a secret my-secret in Azure Key Vault.

version: v0.1testId: SampleTestdisplayName: Sample Testdescription: Load test website home pagetestPlan: SampleTest.jmxtestType: JMXengineInstances: 1secrets: - name: my-secretvalue: https://akv-contoso.vault.azure.net/secrets/MySecret/abc1234567890def12345

env configuration

You can specify environment variables and reference them in your test plan. Learn more about using environment variables with Azure Load Testing.

KeyTypeDefault valueDescription
namestringName of the environment variable. This name should match the variable name that you use in the test plan requests.
valuestringValue of the environment variable.

Environment variable configuration sample

The following code snippet shows a load test configuration, which specifies an environment variable my-variable and value my-value.

version: v0.1testId: SampleTestdisplayName: Sample Testdescription: Load test website home pagetestPlan: SampleTest.jmxtestType: JMXengineInstances: 1env: - name: my-variablevalue: my-value

certificates configuration

You can pass client certificates to your load test. The certificate is stored in Azure Key Vault. Learn more about using client certificates with Azure Load Testing.

KeyTypeDefault valueDescription
namestringName of the certificate.
valuestringURI (secret identifier) for the certificate in Azure Key Vault.

Certificate configuration sample

The following code snippet shows a load test configuration, which references a client certificate in Azure Key Vault.

version: v0.1testId: SampleTestdisplayName: Sample Testdescription: Load test website home pagetestPlan: SampleTest.jmxtestType: JMXengineInstances: 1certificates: - name: my-certificatevalue: https://akv-contoso.vault.azure.net/certificates/MyCertificate/abc1234567890def12345

referenceIdentities configuration

You can use managed identities for various scenarios in your load test. Managed identities can be used in the test for accessing the secrets or certificates from your Azure Key Vault, fetching metrics for server-side failure criteria and authentication of your endpoints.

The following table describes the different fields in the referenceIdentities: configuration:

ParameterDescription
kindRequired. This defines the scenario for which the managed identity is being used. This can be one of the following KeyVault, Metricsor Engine. There can be multiple items for the kind Engine.
typeRequired. The type of identity. This can be UserAssigned or SystemAssigned.
valueRequired. The resource ID of the managed identity. This need not be provided if the type is SystemAssigned.

Reference identities configuration sample

The following code snippet shows a load test configuration, for multiple identities.

version: v0.1testId: SampleTestdisplayName: Sample Testdescription: Load test website home pagetestPlan: SampleTest.jmxtestType: JMXengineInstances: 1secrets: - name: my-secretvalue: https://akv-contoso.vault.azure.net/secrets/MySecret/abc1234567890def12345failureCriteria: serverMetrics: - resourceId: /subscriptions/abcdef01-2345-6789-0abc-def012345678/resourceGroups/sample-rg/providers/Microsoft.Compute/virtualMachines/sample-vmmetricNamespace: Microsoft.Compute/virtualMachinesmetricName: Percentage CPUaggregation: Averagecondition: GreaterThanvalue: 80referenceIdentities: - kind: KeyVaulttype: UserAssignedvalue: /subscriptions/abcdef01-2345-6789-0abc-def012345678/resourceGroups/sample-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/sample-identity - kind: Metricstype: SystemAssigned - kind: Enginetype: UserAssignedvalue: /subscriptions/abcdef01-2345-6789-0abc-def012345678/resourceGroups/sample-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/sample-identity - kind: Enginetype: UserAssignedvalue: /subscriptions/abcdef01-2345-6789-0abc-def012345678/resourceGroups/sample-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/sample-identity1

Requests JSON file

If you use a URL-based test, you can specify the HTTP requests in a JSON file instead of using a test script. Make sure to set the testType to URL in the test configuration YAML file and reference the requests JSON file.

HTTP requests

The requests JSON file uses the following properties for defining requests in the requests property:

PropertyTypeDescription
requestNamestringUnique request name. You can reference the request name when you configure test fail criteria.
responseVariablesarrayList of response variables. Use response variables to extract a value from the request and reference it in a subsequent request. Learn more about response variables.
responseVariables.extractorTypestringMechanism to extract a value from the response output. Supported values are XPathExtractor, JSONExtractor, and RegularExpression.
responseVariables.expressionstringExpression to retrieve the response output. The expression depends on the extractor type value.
responseVariables.variableNamestringUnique response variable name. You can reference this variable in a subsequent request by using the {$variable-name} syntax.
queryParametersarrayList of query string parameters to pass to the endpoint.
queryParameters.keystringQuery string parameter name.
queryParameters.valuestringQuery string parameter value.
requestTypestringType of request. Supported values are: URL or CURL.
endpointstringURL of the application endpoint to test.
headersarrayList of HTTP headers to pass to the application endpoint. Specify a key-value pair for each header.
bodystringBody text for the HTTP request. You can use the requestBodyFormat to specify the format of the body content.
requestBodyFormatstringFormat of the body content. Supported values are: Text, JSON, JavaScript, HTML, and XML.
methodstringHTTP method to invoke the endpoint. Supported values are: GET, POST, PUT, DELETE, PATCH, HEAD, and OPTIONS.
curlCommandstringcURL command to run. Requires that the requestType is CURL.

The following JSON snippet contains an example requests JSON file:

{ "version": "1.0", "scenarios": { "requestGroup1": { "requests": [ { "requestName": "add", "responseVariables": [], "queryParameters": [ { "key": "param1", "value": "value1" } ], "requestType": "URL", "endpoint": "https://www.contoso.com/orders", "headers": { "api-token": "my-token" }, "body": "{\r\n\"customer\": \"Contoso\",\r\n\"items\": {\r\n\t\"product_id\": 321,\r\n\t\"count\": 50,\r\n\t\"amount\": 245.95\r\n }\r\n}", "method": "POST", "requestBodyFormat": "JSON" }, { "requestName": "get", "responseVariables": [], "requestType": "CURL", "curlCommand": "curl --request GET 'https://www.contoso.com/orders'" }, ], "csvDataSetConfigList": [] } }, "testSetup": [ { "virtualUsersPerEngine": 1, "durationInSeconds": 600, "loadType": "Linear", "scenario": "requestGroup1", "rampUpTimeInSeconds": 30 } ] }

Load configuration

The requests JSON file uses the following properties for defining the load configuration in the testSetup property:

PropertyTypeLoad typeDescription
loadTypestringLoad pattern type. Supported values are: linear, step, and spike.
scenariostringReference to the request group, specified in the scenarios property.
virtualUsersPerEngineintegerAllNumber of virtual users per test engine instance.
durationInSecondsintegerAllTotal duration of the load test in seconds.
rampUpTimeInSecondsintegerLinear, StepDuration in seconds to ramp up to the target number of virtual users.
rampUpStepsintegerStepThe number of steps to reach the target number of virtual users.
spikeMultiplierintegerSpikeThe factor to multiply the number of target users with during the spike duration.
spikeHoldTimeInSecondsintegerSpikeTotal duration in seconds to maintain the spike load.

Regional load test configuration

You can distribute load across regions to better simulate real life traffic patterns. You can specify the regions that you want to generate the load from and the amount of load that you want to simulate from each region. You can do that by specifying the region name and the number of engine instances that you want in that region. Learn more about generating load from multiple regions.

KeyTypeDefault valueDescription
regionstringName of the Azure region.
engineInstancesintegerNumber of engine instances for that Azure region.

Regional load test configuration sample

The following code snippet shows a load test configuration, which specifies two Azure regions eastus and eastasia and the number of engine instances for each region.

displayName: Sample TesttestPlan: sampleScript.jmxdescription: 'Load test website home page'engineInstances: 4testId: SampleTesttestType: LocustsplitAllCSVs: FalseregionalLoadTestConfig: - region: eastusengineInstances: 2 - region: eastasiaengineInstances: 2failureCriteria: - p90(response_time_ms) > 10000autoStop: errorPercentage: 90timeWindow: 60

Related content

close