Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.6k views
in Technique[技术] by (71.8m points)

jmeter - Performance Test- how to pass auth token generated once during test to next thread

I am using jmeter. I tried two options to pass the token( which needs to be run just once during the performance test) from one request to another. option 1 -I created two thread groups and used intercommunication thread post processor and thread process as you can see from the screenshot. The second concurrency thread group is just run once which needs to run at 1 rps for certain time initially( later this would be modified)

Option-2- I have one thread group which has a token request as once in a controller and post API request but the token request is not just run once it's been run multiple times during the test. please see the attached screenshot.

I have not tried the option of using a preprocessor and setting the token as property and getting the property value. is this a viable option or am I missing anything from option 1 why the second thread in option 1 is not running more than once?

option 1 test plan: https://i.stack.imgur.com/9Se4l.png result tree of option 1 -where post request is run once- https://i.stack.imgur.com/ESx3J.png once in a controller option 2: https://i.stack.imgur.com/MROok.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  1. Option 1: most probably your Post MPRequest is run only once because it "waits" for the next token, I think you should be reading this token only once instead of trying to do this before each request
  2. Option 2: you're seeing more than one Token Request because you're using more than one thread (virtual user), Once Only Controller's children are executed only once (during the first Thread Group iteration) per thread/virtual user

If you want to get the token only once and share it across all threads (virtual users) - you need to:

  1. Do it in a setUp Thread Group with 1 user and 1 loop
  2. Once you get the token use __setProperty() function to convert JMeter Variable holding the token into a JMeter Property
  3. In your main thread group use __P() function to read the token value

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...