Azure Load Testing Series - Accessing bearer token in Jmeter between different thread groups using BeanShell Assertion
Series - azureloadtesting
Contents
About this blog
Hey folks!, In this blog we will see how to pass bearer token dynamically between two different thread groups using bean shell assertions. We will continue with the same Mock API that we used in our previous blog
Mock API
In order to cover the scenarios, I have used a mock API that exposes token endpoint and a dummy GET endpoint.
Extract token between two thread groups using BeanShell assertions
Creating two thread groups
- Now we can move our existing “Get access token” HTTP request to newly created thread group
Create BeanShell assertion
- Now we can set a property similar to global variables that can be referenced in other thread groups
- In the script window type below command
|
|
Create BeanShell PreProcessor
- Now we can add a pre processor in the other thread group where we wanted to consume the auth_token by right clicking on ThreadGroup->Add->PreProcessors->BeanShell PreProcessor
- In the script window type below command
|
|
- Now click on Run , you will be able to see bearer token is passed as expected
Next steps
In our next blog we will see how to create test plan in Azure portal
Join us
Please go ahead and join our discord channel (https://discord.gg/8Cs82yNS) to give some valuable feedbacks