azurejmeterautomated-testsazure-pipelinesaccess-token

Run JMeter script in AzureDevOps - Bearer Access Token generation


Automating run and monitor Jmeter API based load tests in Azure DevOps Pipelines

The application to be tested needs to login using clientid, client secret and bearer access token that expires every 24 hours.

The JMeter script is ready and it runs well in GUI mode and in local machine CLI.

The same script is used in Azure DevOps Pipelines with password protection using Azure. The client id and secret in the script is replaced by variable name which will be substituted with its real values from Azure environment variable manager. The Bearer access token portion in the script is replaced with this : "Bearer ${AccessToken}"

The Pipeline has JMeter, CLI, Upload Release Artifact.Deployment happens successfully. When i download and the opne the logs, i get the below error:

  1. HTTP request : 400/Bad Request
  2. ReportRequest_viewChart : 401/Unauthorized

In the log, i do get messages like: All thread groups have been started.

After retry, The Bearer access token portion in the script is replaced with this ${__groovy(System.getenv('AccessToken'),)}

Still the same error:'400/Bad Request' and '401/Unauthorized'.

What should I do differently? Does the problem lie in access token part or somewhere else?

I did try to run this test for other websites where login is not needed. They work well. Please help


Solution

  • Your __groovy() function syntax is correct and it will return the environment variable value (given it's defined)

    enter image description here

    So make sure that you properly define your environment variable in your pipeline.

    Also I think the Bearer token shouldn't be provided via environment variable, you should rather correlate it (simulate the login flow and extract it from the response using a suitable JMeter Post-Processor)