| title | Configure JMeter user properties |
|---|---|
| titleSuffix | Azure Load Testing |
| description | Learn how to use JMeter user properties with Azure Load Testing. |
| services | load-testing |
| ms.service | azure-load-testing |
| ms.author | nandinim |
| author | nandinimurali |
| ms.date | 04/05/2023 |
| ms.topic | how-to |
In this article, learn how to configure and use Apache JMeter user properties with Azure Load Testing. With user properties, you can make your test configurable by keeping test settings outside of the JMeter test script. Use cases for user properties include:
- You want to use the JMX test script in multiple deployment environments with different application endpoints.
- Your test script needs to accommodate multiple load patterns, such as smoke tests, peak load, or soak tests.
- You want to override default JMeter behavior by configuring JMeter settings, such as the results file format.
Azure Load Testing supports the standard Apache JMeter properties and enables you to upload a user properties file. You can configure one user properties file per load test.
Alternately, you can also use environment variables and secrets in Azure Load Testing to make your tests configurable.
Note
Azure Load Testing overrides specific JMeter properties and ignores any values you specify for these properties. Learn more about the list of JMeter properties that Azure Load Testing overrides.
- 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.
You can define user properties for your JMeter test script by uploading a .properties file to the load test. Azure Load Testing supports a single JMeter properties file per load test. Additional property files are ignored.
The following code snippet shows an example user properties file that defines three user properties and configures the jmeter.save.saveservice.thread_name configuration setting:
# peak-load.properties
# User properties for testing peak load
threadCount=250
rampUpSeconds=30
durationSeconds=600
# Override default JMeter properties
jmeter.save.saveservice.thread_name=falseTo add a user properties file to your load test by using the Azure portal, follow these steps:
-
In the Azure portal, go to your Azure Load Testing resource.
-
On the left pane, select Tests to view the list of tests.
-
Select your test from the list by selecting the checkbox, and then select Edit. Alternately, select Create test to create a new load test.
-
Select the Test plan tab.
-
Select the properties file from your computer, and then select Upload to upload the file to Azure.
:::image type="content" source="media/how-to-configure-user-properties/edit-test-upload-properties.png" alt-text="Screenshot that shows the steps to upload a user properties file on the Test plan tab on the Edit test pane.":::
-
Select User properties in the File relevance dropdown list.
:::image type="content" source="media/how-to-configure-user-properties/edit-test-upload-properties-file-relevance.png" alt-text="Screenshot that highlights the file relevance dropdown for a user properties file on the Test plan pane.":::
You can select only one file as a user properties file for a load test.
-
Select Apply to modify the test, or Review + create, and then Create to create the new test.
If you run a load test within your CI/CD workflow, you add the user properties file to the source control repository. You then specify this properties file in the load test configuration YAML file.
For more information about running a load test in a CI/CD workflow, see the Automated regression testing quickstart.
To add a user properties file to your load test, follow these steps:
-
Add the .properties file to the source control repository.
-
Open your YAML test configuration file in Visual Studio Code or your editor of choice.
-
Specify the .properties file in the
properties.userPropertyFilesetting.testName: MyTest testPlan: SampleApp.jmx description: Configure a load test with peak load properties. engineInstances: 1 properties: userPropertyFile: peak-load.properties configurationFiles: - input-data.csv
[!NOTE] If you store the properties file in a separate folder, specify the file with a relative path name. For more information, see the Test configuration YAML syntax.
-
Save the YAML configuration file and commit it to your source control repository.
The next time the CI/CD workflow runs, it will use the updated configuration.
Azure Load Testing supports the built-in Apache JMeter functionality to reference user properties in your JMeter test script (JMX). You can use the __property or __P functions to retrieve the property values from the property file you uploaded previously.
The following code snippet shows an example of how to reference properties in a JMX file:
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Test home page" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<intProp name="LoopController.loops">-1</intProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">${__P(threadCount,1)}</stringProp>
<stringProp name="ThreadGroup.ramp_time">${__P(rampUpSeconds,1)}</stringProp>
<boolProp name="ThreadGroup.scheduler">true</boolProp>
<stringProp name="ThreadGroup.duration">${__P(durationSeconds,30)}</stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
</ThreadGroup>Alternately, you also specify properties in the JMeter user interface. The following image shows how to use properties to configure a JMeter thread group:
:::image type="content" source="media/how-to-configure-user-properties/jmeter-user-properties.png" alt-text="Screenshot that shows how to reference user properties in the JMeter user interface.":::
You can download the JMeter errors logs to troubleshoot errors during the load test.
- Learn more about JMeter properties that Azure Load Testing overrides.
- Learn more about parameterizing a load test by using environment variables and secrets.
- Learn more about diagnosing failing load tests.