Apache JMeter
Use secrets in Apache JMeter
In this section, you'll update the Apache JMeter script to use the secret that you specified earlier.
You first create a user-defined variable that retrieves the secret value. Then, you can use this variable in your test (for example, to pass an API token in an HTTP request header).
Create a user-defined variable in your JMX file and assign the secret value to it by using the
GetSecret
custom function.The
GetSecret(<my-secret-name>)
function takes the secret name as an argument. You use this same name when you configure the load test in a later step.You can create the user-defined variable by using the Apache JMeter IDE, as shown in the following image:
Alternatively, you can directly edit the JMX file, as shown in this example code snippet:
Reference the user-defined variable in the test script.
You can use the
${}
syntax to reference the variable in the script. In the following example, you use theudv_appToken
variable to set an HTTP header.
Configure load tests with environment variables
In this section, you use environment variables to pass parameters to your load test.
Update the Apache JMeter script to use the environment variable (for example, to configure the application endpoint hostname).
Configure the load test and pass the environment variable to the test script.
Use environment variables in Apache JMeter
In this section, you update the Apache JMeter script to use environment variables to control the script behavior.
You first define a user-defined variable that reads the environment variable, and then you can use this variable in the test execution (for example, to update the HTTP domain).
Create a user-defined variable in your JMX file, and assign the environment variable's value to it by using the
System.getenv
function.The
System.getenv("<my-variable-name>")
function takes the environment variable name as an argument. You'll use this same name when you configure the load test.You can create a user-defined variable by using the Apache JMeter IDE, as shown in the following image:
Alternatively, you can directly edit the JMX file, as shown in this example code snippet:
Reference the user-defined variable in the test script.
You can use the
${}
syntax to reference the variable in the script. In the following example, you use theudv_webapp
variable to configure the application endpoint URL.
Last updated