Laplace'sDemon
Laplace'sDemon

Reputation: 138

JMeter does not pass token when executed in non-gui mode

I have two threads groups. The first one generate a token that is passed to the second thread group. I use a json extractor and a beanshell assertion in the first group to make the token visible for the second thread. It works perfectly in gui mode but in non-gui mode the token always is generated correctly but is not passed to the second thread so it fails, returns status 401.

Do you have any idea why this happen and a solution?

Edit: I have a global user defined variable element. There I have a var called token_type with the value global_token. Then in the second thread I have a http header manager where I have a header called Authorization with the value Bearer ${__V(${token_type})}

Upvotes: 1

Views: 164

Answers (1)

Dmitri T
Dmitri T

Reputation: 168122

  1. Since JMeter 3.1 it's recommended to use JSR223 test elements and Groovy language for scripting so consider migrating
  2. Unless you have a very specific use case it would be a better idea to move samplers into a single Thread Group, this way you won't have to pass the token between thread groups at all, moreover each thread (virtual user) would have its own token as JMeter Variables are local to the threads
  3. You may find Inter-Thread Communication plugin easier to use, in this case the 2nd thread group will "wait" until the token becomes available

Upvotes: 1

Related Questions