Search code examples
javajmeterperformance-testing

JMeter Variable Value Getting Lost In Same ThreadGroup And Simple Controller


I am using Jmeter to create a scenario for load testing. The format is like following.

1.Thread Group  
 1.1.Simple Controller  
  1.1.1 HTTP request 1---extract a certain variable X from the response  
  1.1.2.HTTP request 2( Send X as a parameter)  
  1.1.3 Simple Controller  
   1.1.3.1. HTTP request [Try to use X as parameter]

I am running it with only 1 thread, directly from Jmeter.

Problem: the value of the variable X becomes blank at 1.1.3.1.

Sometimes, even at the same level also the variable value seems lost in the next event. i.e. if there are two consecutive HTTP requests, in the second request the value is lost.

My question is: Why the value is getting lost and what is the solution to prevent it from being lost?

The way I have used before is like reorganizing the events. But it may not be possible all the time. Is there any way to retain the value through some global variable?


Solution

  • I think I have found the problem case and one solution.

    According to the scenario I tested, if there is a controller within another controller, the value of variable gets lost.

    i.e. in the format mentioned in the question, the value will be lost. The format can be restructured as below.

    • 1.Thread Group
    • 1.1 Simple Controller 1
    • 1.1.1 HTTP request 1---extract a certain variable X from the response
    • 1.2 Simple Controller 2
    • 1.2.1.HTTP request 2( Send X as a parameter)
    • 1.2.2. HTTP request 3 [Try to use X as parameter]--Works Perfectly This Way