'Jmeter - How to pass multiple tokens from http login request to another http request

I am currently designing a test case for multiple users testing using jmeter and I kind of need some help. Here's the scenario: Suppose I have 2 different login portals with 500 different users on each portal. I want to do login, access getExamSchedule, startExam, getListQuestion, getOneQuestion, submitOneQuestion and finishExam so I create one new thread group for each request. Each thread has 2 samplers (1 for portal A, 2 for portal B). My question is how am I supposed to pass the multiple generated tokens from login thread so that I can access the rest of the thread with different tokens. And also each http request has some response I need to extract to be used on another thread. I tried to extract the tokens and the responses to csv file but somehow it didn't work. Let me know if there's any best practice for this scenario. Thank you in advance! jmeter script



Solution 1:[1]

so I create one new thread group for each request - normally you should create separate/different Thread Groups only for new logical groups of virtual users, for your use case I think everything could be in one Thread Group.

As per JMeter Documentation:

Properties are not the same as variables. Variables are local to a thread; properties are common to all threads, and need to be referenced using the __P or __property function.

So if you really need to pass values across different Thread Groups - you can take a look at following solutions:

  1. __setProperty(), __threadNum() and __P() functions combination like:

    • To set the property:

      ${__setProperty(token_${__threadNum},${jmeter-variable-holding-the-token},)}
      
    • To read the property: ${__P(token_${__threadNum},)}

  2. Use Inter-Thread Communication Plugin

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dmitri T