I added two request one for login to store the session id and another request to check the load test which requires session id.
I made login request as once only, by ad
In the new versions of JMeter you can add a "setUp Thread Group" that does exactly what you need.
A special type of ThreadGroup that can be utilized to perform Pre-Test Actions. The behavior of these threads is exactly like a normal Thread Group element. The difference is that these type of threads execute before the test proceeds to the executing of regular Thread Groups.
http://jmeter.apache.org/usermanual/component_reference.html#setUp_Thread_Group
${__groovy(${__threadNum} == 1 && vars.getIteration() == 1)}
In Jmeter 2.9, you can use the "Once only Controller" and "Loop Controller" to do that.
It is wonderful!
Frankie
Only once controller works the way BlackGaff explained it.
What you are trying to do seems wrong as it would mean you authenticate your 100 users with same login/password.
But if you still want to do it, you can use setupThread with one user, it is usually useful for some init task on test but in no mean it answers your requirement which seems wrong to me.
The "ONLY ONCE" controller doesn't work the way you think it does.
It runs "only once" PER THREAD. Thus, if you have 100 threads, it will run 100 times.
If you want it to run ONCE PER TEST, do the following:
Test Plan (Set thread groups to "run consecutively"
- Cookie Manager
- Thread Group A (1 thread, 1 loop)
- - - Login Logic
- Thread Group B
- - - Rest of test
Please note, if you need to share any variables between threadgroups A and B, you need to set them as properties. Variables cannot be shared between thread groups, but properties can. You'll need to use the properties function for this.
The function __setProperty automatically stores the value as a global variable. The cleanest way to initiate __setProperty would be to create a POST-processor Beanshell script as a child to the sampler that creates the cookie in THREAD A. To retrieve the value in THREAD B, you add the __property function as the VALUE for the parameter that needs the cookie value.
The Beanshell script would look something like this:
props.put("COOKIENAME","COOKIEVALUE"); //creates a property "COOKIENAME" with value "COOKIEVALUE"
print(props.get("COOKIENAME")); //prints the value out to the console
The code above would always have the same value for COOKIENAME, less then idea. So, we need to make sure "COOKIEVALUE" is dynamic. I would recommend putting a POST-PROCESSOR regular expression to extract the cookie value, and then pass that into the beanshell script.
So, our test plan now looks like this:
Test Plan (Set thread groups to "run consecutively"
- Thread Group A (1 thread, 1 loop)
- - - Login Logic
- - - - - Regex to grab cookie, store as "regexCookie"
- - - - - Beanshell to set property
- Thread Group B
- - - Rest of test
And our beanshell script now looks like:
props.put("COOKIENAME",vars.get("regexCookie")); //creates a property "COOKIENAME" with value from "regexCookie"
print(props.get("COOKIENAME")); //prints the value out to the console
Links to the User Manual:
You can put the "Login HTTP request" in the Once Only controller and the normal "HTTP request" in a Loop controller. Now you can set the loop to execute the HTTP request 100 or 200 times. See: jmeter.apache.org/usermanual/component_reference.html#Loop_Controller
Use Timers to make a more realistic test. Say you want the 200 requests to happen in 120 seconds then you can make each request pause for 120/200 seconds. Most timers work with miliseconds so you can make that number (120/200 * 1000) miliseconds. See: jmeter.apache.org/usermanual/component_reference.html#timers
You could also create a separate Setup threadgroup where you do your login and do the 200 threads in an another threadgroup. Check this article: http://www.informit.com/guides/content.aspx?g=java&seqNum=520
All this information should help you in the right direction. Good luck!